| Task: | ratar |
| Sender: | ollpu |
| Submission time: | 2016-07-27 16:08:49 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | TIME LIMIT EXCEEDED | 0 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.06 s | details |
| #2 | ACCEPTED | 0.06 s | details |
| #3 | ACCEPTED | 0.05 s | details |
| #4 | ACCEPTED | 0.06 s | details |
| #5 | ACCEPTED | 0.05 s | details |
| #6 | ACCEPTED | 0.05 s | details |
| #7 | ACCEPTED | 0.05 s | details |
| #8 | ACCEPTED | 0.13 s | details |
| #9 | TIME LIMIT EXCEEDED | -- | details |
| #10 | TIME LIMIT EXCEEDED | -- | details |
| #11 | TIME LIMIT EXCEEDED | -- | details |
| #12 | TIME LIMIT EXCEEDED | -- | details |
| #13 | TIME LIMIT EXCEEDED | -- | details |
Code
// Siistitty koodi :D
#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int st[n+1][n+1];
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
int v;
cin >> v;
v += st[i-1][j] + st[i][j-1] - st[i-1][j-1];
st[i][j] = v;
}
}
#define sta(x1, y1, x2, y2) (st[x2][y2]-st[x1-1][y2]-st[x2][y1-1]+st[x1-1][y1-1])
int amount = 0;
for (int i1 = 1; i1 <= n; ++i1) // Upper rectangle, top-left corner
for (int j1 = 1; j1 <= n; ++j1) {
for (int i2 = i1; i2 <= n; ++i2) // Upper rectangle, bottom-right corner
for (int j2 = j1; j2 <= n; ++j2) {
int target = sta(i1, j1, i2, j2);
for (int i3 = i2+1; i3 <= n; ++i3) // Lower rectangle on the right, bottom-right corner
for (int j3 = j2+1; j3 <= n; ++j3) {
if (sta(i2+1, j2+1, i3, j3) == target) amount++;
}
for (int i3 = i2+1; i3 <= n; ++i3) // Lower rectangle on the left, bottom-left corner
for (int j3 = j1-1; j3 > 0; --j3) {
if (sta(i2+1, j3, i3, j1-1) == target) amount++;
}
}
}
cout << amount;
}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: ACCEPTED
| input |
|---|
| 31
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... |
| correct output |
|---|
| 667480 |
| user output |
|---|
| 667480 |
Test 9
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 41
475 533 -726 -189 401 -389 667... |
| correct output |
|---|
| 17456 |
| user output |
|---|
| (empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 49
495 -512 159 -874 751 -817 567... |
| correct output |
|---|
| 48443 |
| user output |
|---|
| (empty) |
Test 11
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 49
521 -51 -778 -977 955 -172 695... |
| correct output |
|---|
| 39082 |
| user output |
|---|
| (empty) |
Test 12
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 50
500 500 500 500 500 500 500 50... |
| correct output |
|---|
| 4236645 |
| user output |
|---|
| (empty) |
Test 13
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 50
933 -493 -881 936 -889 -922 -5... |
| correct output |
|---|
| 37917 |
| user output |
|---|
| (empty) |
