# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59876 | 2018-07-23T08:26:03 Z | ainta(#1720) | Cultivation (JOI17_cultivation) | C++11 | 2000 ms | 263168 KB |
#include<cstdio> #include<algorithm> #include<set> using namespace std; int W, H, n, S[130][130], M[130][130], D[130][130]; set<int>X, Y; struct point { int x, y; }w[330]; bool Pos(int dx, int dy) { int i, j; for (i = 0; i < 130; i++)for (j = 0; j < 130; j++)S[i][j] = 0; for (i = 1; i <= n; i++) { S[w[i].x][w[i].y]++; S[w[i].x][w[i].y+dy+1]--; S[w[i].x+dx+1][w[i].y]--; S[w[i].x+dx+1][w[i].y+dy+1]++; } for (i = 1; i < 130; i++)for (j = 1; j < 130; j++)S[i][j] += S[i][j - 1]; for (i = 1; i < 130; i++)for (j = 1; j < 130; j++)S[i][j] += S[i-1][j]; for (i = 1; i < 130; i++) { for (j = 1; j < 130; j++) { if (!S[i][j])M[i][j] = 0; else M[i][j] = M[i][j - 1] + 1; } } for (i = 1; i < 130; i++) { for (j = 1; j < 130; j++) { if (M[i][j] < H)D[i][j] = 0; else D[i][j] = D[i - 1][j] + 1; if (D[i][j] >= W) { return true; } } } return false; } int main() { int i, j; scanf("%d%d%d", &W, &H, &n); for (i = 1; i <= n; i++) { scanf("%d%d", &w[i].x, &w[i].y); } for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (w[i].x <= w[j].x) { if(w[j].x>w[i].x)X.insert(w[j].x - w[i].x - 1); X.insert(w[i].x - 1 + W - w[j].x); } if (w[i].y <= w[j].y) { if (w[j].y>w[i].y)Y.insert(w[j].y - w[i].y - 1); Y.insert(w[i].y - 1 + H - w[j].y); } } } for (i = 0; i <= max(2*W, 2*H); i++)X.insert(i),Y.insert(i); int res = 1e9; for (auto &x : X) { for (auto &y : Y) { if (Pos(x, y)) { res = min(res, x + y); } } } printf("%d\n", res); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 504 KB | Output is correct |
2 | Correct | 12 ms | 504 KB | Output is correct |
3 | Correct | 7 ms | 520 KB | Output is correct |
4 | Correct | 4 ms | 596 KB | Output is correct |
5 | Correct | 9 ms | 596 KB | Output is correct |
6 | Correct | 13 ms | 644 KB | Output is correct |
7 | Correct | 10 ms | 644 KB | Output is correct |
8 | Correct | 10 ms | 772 KB | Output is correct |
9 | Correct | 11 ms | 836 KB | Output is correct |
10 | Correct | 10 ms | 836 KB | Output is correct |
11 | Correct | 14 ms | 836 KB | Output is correct |
12 | Correct | 7 ms | 836 KB | Output is correct |
13 | Correct | 9 ms | 836 KB | Output is correct |
14 | Correct | 11 ms | 836 KB | Output is correct |
15 | Correct | 10 ms | 836 KB | Output is correct |
16 | Correct | 12 ms | 836 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 504 KB | Output is correct |
2 | Correct | 12 ms | 504 KB | Output is correct |
3 | Correct | 7 ms | 520 KB | Output is correct |
4 | Correct | 4 ms | 596 KB | Output is correct |
5 | Correct | 9 ms | 596 KB | Output is correct |
6 | Correct | 13 ms | 644 KB | Output is correct |
7 | Correct | 10 ms | 644 KB | Output is correct |
8 | Correct | 10 ms | 772 KB | Output is correct |
9 | Correct | 11 ms | 836 KB | Output is correct |
10 | Correct | 10 ms | 836 KB | Output is correct |
11 | Correct | 14 ms | 836 KB | Output is correct |
12 | Correct | 7 ms | 836 KB | Output is correct |
13 | Correct | 9 ms | 836 KB | Output is correct |
14 | Correct | 11 ms | 836 KB | Output is correct |
15 | Correct | 10 ms | 836 KB | Output is correct |
16 | Correct | 12 ms | 836 KB | Output is correct |
17 | Correct | 97 ms | 836 KB | Output is correct |
18 | Correct | 248 ms | 836 KB | Output is correct |
19 | Correct | 573 ms | 836 KB | Output is correct |
20 | Correct | 583 ms | 836 KB | Output is correct |
21 | Correct | 753 ms | 836 KB | Output is correct |
22 | Correct | 708 ms | 892 KB | Output is correct |
23 | Correct | 778 ms | 892 KB | Output is correct |
24 | Correct | 688 ms | 892 KB | Output is correct |
25 | Correct | 679 ms | 892 KB | Output is correct |
26 | Correct | 694 ms | 892 KB | Output is correct |
27 | Correct | 654 ms | 892 KB | Output is correct |
28 | Correct | 716 ms | 892 KB | Output is correct |
29 | Correct | 641 ms | 892 KB | Output is correct |
30 | Correct | 678 ms | 892 KB | Output is correct |
31 | Correct | 648 ms | 892 KB | Output is correct |
32 | Correct | 797 ms | 892 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 504 KB | Output is correct |
2 | Correct | 12 ms | 504 KB | Output is correct |
3 | Correct | 7 ms | 520 KB | Output is correct |
4 | Correct | 4 ms | 596 KB | Output is correct |
5 | Correct | 9 ms | 596 KB | Output is correct |
6 | Correct | 13 ms | 644 KB | Output is correct |
7 | Correct | 10 ms | 644 KB | Output is correct |
8 | Correct | 10 ms | 772 KB | Output is correct |
9 | Correct | 11 ms | 836 KB | Output is correct |
10 | Correct | 10 ms | 836 KB | Output is correct |
11 | Correct | 14 ms | 836 KB | Output is correct |
12 | Correct | 7 ms | 836 KB | Output is correct |
13 | Correct | 9 ms | 836 KB | Output is correct |
14 | Correct | 11 ms | 836 KB | Output is correct |
15 | Correct | 10 ms | 836 KB | Output is correct |
16 | Correct | 12 ms | 836 KB | Output is correct |
17 | Correct | 97 ms | 836 KB | Output is correct |
18 | Correct | 248 ms | 836 KB | Output is correct |
19 | Correct | 573 ms | 836 KB | Output is correct |
20 | Correct | 583 ms | 836 KB | Output is correct |
21 | Correct | 753 ms | 836 KB | Output is correct |
22 | Correct | 708 ms | 892 KB | Output is correct |
23 | Correct | 778 ms | 892 KB | Output is correct |
24 | Correct | 688 ms | 892 KB | Output is correct |
25 | Correct | 679 ms | 892 KB | Output is correct |
26 | Correct | 694 ms | 892 KB | Output is correct |
27 | Correct | 654 ms | 892 KB | Output is correct |
28 | Correct | 716 ms | 892 KB | Output is correct |
29 | Correct | 641 ms | 892 KB | Output is correct |
30 | Correct | 678 ms | 892 KB | Output is correct |
31 | Correct | 648 ms | 892 KB | Output is correct |
32 | Correct | 797 ms | 892 KB | Output is correct |
33 | Execution timed out | 2089 ms | 263168 KB | Time limit exceeded |
34 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2060 ms | 263168 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2060 ms | 263168 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 504 KB | Output is correct |
2 | Correct | 12 ms | 504 KB | Output is correct |
3 | Correct | 7 ms | 520 KB | Output is correct |
4 | Correct | 4 ms | 596 KB | Output is correct |
5 | Correct | 9 ms | 596 KB | Output is correct |
6 | Correct | 13 ms | 644 KB | Output is correct |
7 | Correct | 10 ms | 644 KB | Output is correct |
8 | Correct | 10 ms | 772 KB | Output is correct |
9 | Correct | 11 ms | 836 KB | Output is correct |
10 | Correct | 10 ms | 836 KB | Output is correct |
11 | Correct | 14 ms | 836 KB | Output is correct |
12 | Correct | 7 ms | 836 KB | Output is correct |
13 | Correct | 9 ms | 836 KB | Output is correct |
14 | Correct | 11 ms | 836 KB | Output is correct |
15 | Correct | 10 ms | 836 KB | Output is correct |
16 | Correct | 12 ms | 836 KB | Output is correct |
17 | Correct | 97 ms | 836 KB | Output is correct |
18 | Correct | 248 ms | 836 KB | Output is correct |
19 | Correct | 573 ms | 836 KB | Output is correct |
20 | Correct | 583 ms | 836 KB | Output is correct |
21 | Correct | 753 ms | 836 KB | Output is correct |
22 | Correct | 708 ms | 892 KB | Output is correct |
23 | Correct | 778 ms | 892 KB | Output is correct |
24 | Correct | 688 ms | 892 KB | Output is correct |
25 | Correct | 679 ms | 892 KB | Output is correct |
26 | Correct | 694 ms | 892 KB | Output is correct |
27 | Correct | 654 ms | 892 KB | Output is correct |
28 | Correct | 716 ms | 892 KB | Output is correct |
29 | Correct | 641 ms | 892 KB | Output is correct |
30 | Correct | 678 ms | 892 KB | Output is correct |
31 | Correct | 648 ms | 892 KB | Output is correct |
32 | Correct | 797 ms | 892 KB | Output is correct |
33 | Execution timed out | 2089 ms | 263168 KB | Time limit exceeded |
34 | Halted | 0 ms | 0 KB | - |