CSES - Leirikisa 1 - Results
Submission details
Task:ratar
Sender:Kuha
Submission time:2016-07-27 16:04:25 +0300
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:38:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (ll y = 0; y < n; y++) {
                      ^
input/code.cpp:39:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (ll x = 0; x <n; x++) {
                       ^
input/code.cpp:42:64: error: lvalue required as increment operand
    m[(x1 * 4821397500 + y1 * 96427950 + sum(x1, x, y1, y)) % C]++;
                                                                ^
input/code.cpp:43:70: error: lvalue required as increment operand
    m2[(x1 * 4821397500 + (y + 1) * 96427950 + sum(x1, x, y1, y)) % C]++;
                                                                      ^
input/code.cpp:44:8: error: invalid use of non-lvalue array
    ans += m[((x+1) * 4821397500 + (y+1) * 96427950 + sum(x1, x, y1, y)) % C];
        ^
input/code.cpp:44:8: error:   in evaluation of 'operator+=(unsigned i...

Code

#include <bits/stdc++.h>
#define ll unsigned int//long long
#define INF 999999999
#define N (1<<17)
#define M 1000000007
#define C 250000

using namespace std;

ll ans = 0;
ll v[50][50];
ll m[50][50][250000];
ll m2[50][50][250000];
const inline ll sum (const ll x1, const ll x2, const ll y1, const ll y2) {
  ll s = v[y2][x2];
  if (x1) s -= v[y2][x1-1];
  if (y1) s -= v[y1-1][x2];
  if (x1 && y1) s += v[y1-1][x1-1];
  return s;
}

int main () {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  for (int y = 0; y < n; y++) {
    for (int x = 0; x <n; x++) {
      cin>>v[y][x];
      if (x) v[y][x] += v[y][x - 1];
    }
  }
  for(int y = 1; y < n; y++) {
    for (int x = 0; x < n; x++) {
     v[y][x] += v[y - 1][x]; 
    }
  }
  for (ll y = 0; y < n; y++) {
    for (ll x = 0; x <n; x++) {
      for (ll y1 = 0; y1 <= y; y1++) {
	for (ll x1 = 0; x1 <= x; x1++) {
	  m[(x1 * 4821397500 + y1 * 96427950 + sum(x1, x, y1, y)) % C]++;
	  m2[(x1 * 4821397500 + (y + 1) * 96427950 + sum(x1, x, y1, y)) % C]++;
	  ans += m[((x+1) * 4821397500 + (y+1) * 96427950 + sum(x1, x, y1, y)) % C];
	  ans += m2[((x+1) * 4821397500 + (y1) * 96427950 + sum(x1, x, y1, y)) % C];
	}
      }
    }
  }
  cout<<ans<<endl;
}