CSES - Leirikisa 1 - Results
Submission details
Task:ratar
Sender:Kuha
Submission time:2016-07-27 15:27:24 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.06 sdetails
#3ACCEPTED0.05 sdetails
#4ACCEPTED0.06 sdetails
#5ACCEPTED0.05 sdetails
#6ACCEPTED0.05 sdetails
#7ACCEPTED0.06 sdetails
#8--details
#9--details
#10--details
#11--details
#12--details
#13--details

Code

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

using namespace std;

int ans = 0;
  int v[50][50];
int sum (int x1, int x2, int y1, int y2) {
  int s = 0;
  for (int y = y1; y <= y2; y++) {
   for (int x = x1; x<= x2;x++) s +=v[y][x]; 
  }
  return s;
}

int main () {
  int n;
  cin>>n;
  for (int y = 0; y < n; y++) {
    for (int x = 0; x <n; x++) {
      cin>>v[y][x];
    }
  }
  for (int y = 0; y < n; y++) {
    for (int x = 0; x <n; x++) {
      for (int y1 = 0; y1 <= y; y1++) {
	for (int x1 = 0; x1 <= x; x1++) {
	  for (int y2 = y + 1; y2 < n; y2++) {
	    for (int x2 = x + 1; x2 < n; x2++) {
	      if (sum(x1, x, y1, y) == sum(x + 1, x2, y + 1, y2)) ans++;
	    }
	  }
	}
      }
      for (int y1 = 0; y1 <= y; y1++) {
	for (int x1 = 0; x1 <= x; x1++) {
	  for (int y2 = y + 1; y2 < n; y2++) {
	    for (int x2 = x + 1; x2 < n; x2++) {
	      if (sum(x1, x, y + 1, y2) == sum(x + 1, x2, y1, y)) ans++;
	    }
	  }
	}
      }
    }
  }
  cout<<ans<<endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
3
1 2 3
2 3 4
3 4 8

correct output
7

user output
7

Test 2

Verdict: ACCEPTED

input
4
-1 -1 -1 -1
1 2 3 4
1 2 3 4
1 2 3 4

correct output
10

user output
10

Test 3

Verdict: ACCEPTED

input
5
-1 -1 -1 -1 -1
-2 -2 -2 -2 -2
-3 -3 -3 -3 -3
-4 -4 -4 -4 -4
...

correct output
36

user output
36

Test 4

Verdict: ACCEPTED

input
2
1 -1
-1 1

correct output
2

user output
2

Test 5

Verdict: ACCEPTED

input
5
1 -1 1 -1 1
-1 1 -1 1 -1
1 -1 1 -1 1
-1 1 -1 1 -1
...

correct output
380

user output
380

Test 6

Verdict: ACCEPTED

input
10
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 1 0
0 1 1 0 0 0 0 1 1 0
...

correct output
7354

user output
7354

Test 7

Verdict: ACCEPTED

input
10
420 425 490 727 888 391 514 82...

correct output
5

user output
5

Test 8

Verdict:

input
31
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
667480

user output
(empty)

Test 9

Verdict:

input
41
475 533 -726 -189 401 -389 667...

correct output
17456

user output
(empty)

Test 10

Verdict:

input
49
495 -512 159 -874 751 -817 567...

correct output
48443

user output
(empty)

Test 11

Verdict:

input
49
521 -51 -778 -977 955 -172 695...

correct output
39082

user output
(empty)

Test 12

Verdict:

input
50
500 500 500 500 500 500 500 50...

correct output
4236645

user output
(empty)

Test 13

Verdict:

input
50
933 -493 -881 936 -889 -922 -5...

correct output
37917

user output
(empty)