CSES - Leirikisa 1 - Results
Submission details
Task:ratar
Sender:Kuha
Submission time:2016-07-27 16:06:24 +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++) {
                       ^
output/ccadBlmJ.o: In function `main':
code.cpp:(.text.startup+0x43): relocation truncated to fit: R_X86_64_32 against symbol `v' defined in .bss section in output/ccadBlmJ.o
code.cpp:(.text.startup+0xad): relocation truncated to fit: R_X86_64_32 against symbol `v' defined in .bss section in output/ccadBlmJ.o
code.cpp:(.text.startup+0xcb): relocation truncated to fit: R_X86_64_32S against symbol `v' defined in .bss section in output/ccadBlmJ.o
code.cpp:(.text.startup+0x110): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in output/ccadBlmJ.o
code.cpp:(.text.startup+0x119): relocatio...

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][y1][sum(x1, x, y1, y) % C]++;
	  m2[x1][y + 1][sum(x1, x, y1, y) % C]++;
	  ans +=  m[x + 1][y + 1][sum(x1, x, y1, y) % C];
	  ans += m2[x + 1][y1][sum(x1, x, y1, y) % C];
	}
      }
    }
  }
  cout<<ans<<endl;
}