#include #include inline void fastRead_int(long long int *number) { int chr = getchar_unlocked(); bool negate = false; while((chr < 48 || chr > 57) && chr != '-') { chr = getchar_unlocked(); } *number = 0; if(chr == '-') { negate = true; chr = getchar_unlocked(); } while(chr > 47 && chr < 58) { *number = (*number) * 10 + chr - 48; chr = getchar_unlocked(); } if(negate) { *number=-(*number); } } int main() { long long int size = 0; long long int pos = 0; std::map abstracts; int i = 0; int i2 = 0; long long int pos1 = 0; long long int pos2 = 0; long long int pos3 = 0; long long int pos4 = 0; long long int tmp = 0; long long int sum = 0; long long int max = 0; long long int count = 0; fastRead_int(&size); fastRead_int(&pos); int** mat = new int*[size + 1]; while(i <= size) { mat[i] = new int[size + 1]; mat[0][i] = 0; mat[i][0] = 0; ++i; } i = 0; while(i < size) { i2 = 0; while(i2 < size) { fastRead_int(&pos1); mat[i+1][i2+1] = pos1 + mat[i+1][i2] + mat[i][i2+1] - mat[i][i2]; ++i2; } ++i; } i = 0; while(i < pos) { fastRead_int(&pos1); fastRead_int(&pos2); fastRead_int(&pos3); fastRead_int(&pos4); tmp = mat[pos3+1][pos4+1] + mat[pos1][pos2] - mat[pos1][pos4+1] - mat[pos3+1][pos2]; sum += tmp; ++abstracts[tmp]; ++i; } for(std::map::iterator it = abstracts.begin(); it != abstracts.end(); ++it) { if(it->second > max) { count = 1; max = it->second; } else if(it->second == max) { ++count; } } printf("%u %lld %lld", abstracts.size(), count, sum / pos); }