# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
550676 | 2022-04-18T19:34:01 Z | LucaDantas | Cultivation (JOI17_cultivation) | C++17 | 2000 ms | 1012 KB |
#include <bits/stdc++.h> using namespace std; constexpr int maxr = 41, maxn = 310, inf = 0x3f3f3f3f; int n, r, c; set<int> mark[maxr]; // salvo pra cada linha quais colunas tão ativas struct par { int r, c; } pares[maxn]; int get(int cima, int baixo) { // painting for(int i = 0; i < maxr; i++) mark[i].clear(); for(int i = 0; i < n; i++) mark[pares[i].r].insert(pares[i].c); for(int row = 1; row < r; row++) for(int coluna : mark[row]) for(int j = 1; j <= cima && row - j >= 0 && !mark[row-j].count(coluna); j++) mark[row-j].insert(coluna); for(int row = r-2; row >= 0; row--) for(int coluna : mark[row]) for(int j = 1; j <= baixo && row + j < r && !mark[row+j].count(coluna); j++) mark[row+j].insert(coluna); // Tudo pintado pra cima e pra baixo agora vou ver quanto eu preciso pra pintar pros lados // Calculo a resposta separadamente pra cada linha int minSum = 0, minL = 0, minR = 0; for(int row = 0; row < r; row++) { if(!mark[row].size()) return inf; // pessimo minL = max(minL, *mark[row].begin()); minR = max(minR, c-1 - *mark[row].rbegin()); while(mark[row].size() >= 2) minSum = max(minSum, *next(mark[row].begin()) - *mark[row].begin() - 1), mark[row].erase(mark[row].begin()); } return max(minSum, minL + minR); } int main() { scanf("%d %d", &r, &c); scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d %d", &pares[i].r, &pares[i].c), --pares[i].r, --pares[i].c; // printf("%d\n", get(0, 2)); int ans = inf; for(int cima = 0; cima < maxr; cima++) for(int baixo = 0; baixo < maxr; baixo++) ans = min(ans, cima + baixo + get(cima, baixo)); printf("%d\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 3 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 2 ms | 308 KB | Output is correct |
8 | Correct | 3 ms | 212 KB | Output is correct |
9 | Correct | 2 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 3 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 2 ms | 308 KB | Output is correct |
8 | Correct | 3 ms | 212 KB | Output is correct |
9 | Correct | 2 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 16 ms | 212 KB | Output is correct |
18 | Correct | 84 ms | 212 KB | Output is correct |
19 | Correct | 66 ms | 328 KB | Output is correct |
20 | Correct | 18 ms | 312 KB | Output is correct |
21 | Correct | 108 ms | 332 KB | Output is correct |
22 | Correct | 269 ms | 348 KB | Output is correct |
23 | Correct | 79 ms | 348 KB | Output is correct |
24 | Correct | 317 ms | 480 KB | Output is correct |
25 | Correct | 292 ms | 356 KB | Output is correct |
26 | Correct | 341 ms | 360 KB | Output is correct |
27 | Correct | 345 ms | 360 KB | Output is correct |
28 | Correct | 354 ms | 360 KB | Output is correct |
29 | Correct | 314 ms | 348 KB | Output is correct |
30 | Correct | 429 ms | 480 KB | Output is correct |
31 | Correct | 343 ms | 360 KB | Output is correct |
32 | Correct | 403 ms | 480 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 3 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 2 ms | 308 KB | Output is correct |
8 | Correct | 3 ms | 212 KB | Output is correct |
9 | Correct | 2 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 16 ms | 212 KB | Output is correct |
18 | Correct | 84 ms | 212 KB | Output is correct |
19 | Correct | 66 ms | 328 KB | Output is correct |
20 | Correct | 18 ms | 312 KB | Output is correct |
21 | Correct | 108 ms | 332 KB | Output is correct |
22 | Correct | 269 ms | 348 KB | Output is correct |
23 | Correct | 79 ms | 348 KB | Output is correct |
24 | Correct | 317 ms | 480 KB | Output is correct |
25 | Correct | 292 ms | 356 KB | Output is correct |
26 | Correct | 341 ms | 360 KB | Output is correct |
27 | Correct | 345 ms | 360 KB | Output is correct |
28 | Correct | 354 ms | 360 KB | Output is correct |
29 | Correct | 314 ms | 348 KB | Output is correct |
30 | Correct | 429 ms | 480 KB | Output is correct |
31 | Correct | 343 ms | 360 KB | Output is correct |
32 | Correct | 403 ms | 480 KB | Output is correct |
33 | Correct | 114 ms | 212 KB | Output is correct |
34 | Execution timed out | 2075 ms | 1012 KB | Time limit exceeded |
35 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 3 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 2 ms | 308 KB | Output is correct |
8 | Correct | 3 ms | 212 KB | Output is correct |
9 | Correct | 2 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 16 ms | 212 KB | Output is correct |
18 | Correct | 84 ms | 212 KB | Output is correct |
19 | Correct | 66 ms | 328 KB | Output is correct |
20 | Correct | 18 ms | 312 KB | Output is correct |
21 | Correct | 108 ms | 332 KB | Output is correct |
22 | Correct | 269 ms | 348 KB | Output is correct |
23 | Correct | 79 ms | 348 KB | Output is correct |
24 | Correct | 317 ms | 480 KB | Output is correct |
25 | Correct | 292 ms | 356 KB | Output is correct |
26 | Correct | 341 ms | 360 KB | Output is correct |
27 | Correct | 345 ms | 360 KB | Output is correct |
28 | Correct | 354 ms | 360 KB | Output is correct |
29 | Correct | 314 ms | 348 KB | Output is correct |
30 | Correct | 429 ms | 480 KB | Output is correct |
31 | Correct | 343 ms | 360 KB | Output is correct |
32 | Correct | 403 ms | 480 KB | Output is correct |
33 | Correct | 114 ms | 212 KB | Output is correct |
34 | Execution timed out | 2075 ms | 1012 KB | Time limit exceeded |
35 | Halted | 0 ms | 0 KB | - |