# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27809 | 2017-07-14T06:51:30 Z | 상수조아(#1181) | Cultivation (JOI17_cultivation) | C++11 | 2000 ms | 1176 KB |
#include <stdio.h> #include <vector> #include <algorithm> #include <set> #include <bitset> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define pb(x) push_back(x) #define rep(i, n) for(int i=0;i<n;i++) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define Fi first #define Se second int R, C, N; pii P[320]; int Do(ll L) { for(int i=0;i<R&&i<=L;i++) { for(int j=0;j<R&&i+j<=L;j++) { int left = 0, right = 0; int g = 0; int ok = 1; for(int r=1;r<=R;r++){ vector <int> v; for(int k=1;k<=N;k++) { int x = P[k].Fi, y = P[k].Se; if(x-j <= r && r <= x+i) { v.pb(y); } } if(sz(v) == 0) { ok = 0; break; } left = max(left, v[0] - 1); right = max(right, C - v.back()); for(int i=1;i<sz(v);i++) g = max(g, v[i] - v[i-1] - 1); } if(ok) { ll f = max(g, left + right); if(f + i + j <= L) return 1; } } } return 0; } int main(){ scanf("%d%d%d", &R, &C, &N); if(R > 40) return 0; for(int i=1;i<=N;i++) scanf("%d%d", &P[i].Fi, &P[i].Se); sort(P+1, P+1+N, [](pii a, pii b) { return a.Se < b.Se; }); ll low = 0, high = R + C - 2, res = 0; while(low <= high) { ll mid = (low + high) >> 1; if(Do(mid)) res = mid, high = mid - 1; else low = mid + 1; } printf("%lld\n", res); return 0; };
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1176 KB | Output is correct |
2 | Correct | 0 ms | 1176 KB | Output is correct |
3 | Correct | 0 ms | 1176 KB | Output is correct |
4 | Correct | 0 ms | 1176 KB | Output is correct |
5 | Correct | 0 ms | 1176 KB | Output is correct |
6 | Correct | 0 ms | 1176 KB | Output is correct |
7 | Correct | 0 ms | 1176 KB | Output is correct |
8 | Correct | 0 ms | 1176 KB | Output is correct |
9 | Correct | 0 ms | 1176 KB | Output is correct |
10 | Correct | 0 ms | 1176 KB | Output is correct |
11 | Correct | 0 ms | 1176 KB | Output is correct |
12 | Correct | 0 ms | 1176 KB | Output is correct |
13 | Correct | 0 ms | 1176 KB | Output is correct |
14 | Correct | 0 ms | 1176 KB | Output is correct |
15 | Correct | 0 ms | 1176 KB | Output is correct |
16 | Correct | 0 ms | 1176 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1176 KB | Output is correct |
2 | Correct | 0 ms | 1176 KB | Output is correct |
3 | Correct | 0 ms | 1176 KB | Output is correct |
4 | Correct | 0 ms | 1176 KB | Output is correct |
5 | Correct | 0 ms | 1176 KB | Output is correct |
6 | Correct | 0 ms | 1176 KB | Output is correct |
7 | Correct | 0 ms | 1176 KB | Output is correct |
8 | Correct | 0 ms | 1176 KB | Output is correct |
9 | Correct | 0 ms | 1176 KB | Output is correct |
10 | Correct | 0 ms | 1176 KB | Output is correct |
11 | Correct | 0 ms | 1176 KB | Output is correct |
12 | Correct | 0 ms | 1176 KB | Output is correct |
13 | Correct | 0 ms | 1176 KB | Output is correct |
14 | Correct | 0 ms | 1176 KB | Output is correct |
15 | Correct | 0 ms | 1176 KB | Output is correct |
16 | Correct | 0 ms | 1176 KB | Output is correct |
17 | Correct | 0 ms | 1176 KB | Output is correct |
18 | Correct | 0 ms | 1176 KB | Output is correct |
19 | Correct | 29 ms | 1176 KB | Output is correct |
20 | Correct | 0 ms | 1176 KB | Output is correct |
21 | Correct | 96 ms | 1176 KB | Output is correct |
22 | Correct | 16 ms | 1176 KB | Output is correct |
23 | Correct | 63 ms | 1176 KB | Output is correct |
24 | Correct | 33 ms | 1176 KB | Output is correct |
25 | Correct | 23 ms | 1176 KB | Output is correct |
26 | Correct | 69 ms | 1176 KB | Output is correct |
27 | Correct | 33 ms | 1176 KB | Output is correct |
28 | Correct | 29 ms | 1176 KB | Output is correct |
29 | Correct | 6 ms | 1176 KB | Output is correct |
30 | Correct | 9 ms | 1176 KB | Output is correct |
31 | Correct | 13 ms | 1176 KB | Output is correct |
32 | Correct | 19 ms | 1176 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1176 KB | Output is correct |
2 | Correct | 0 ms | 1176 KB | Output is correct |
3 | Correct | 0 ms | 1176 KB | Output is correct |
4 | Correct | 0 ms | 1176 KB | Output is correct |
5 | Correct | 0 ms | 1176 KB | Output is correct |
6 | Correct | 0 ms | 1176 KB | Output is correct |
7 | Correct | 0 ms | 1176 KB | Output is correct |
8 | Correct | 0 ms | 1176 KB | Output is correct |
9 | Correct | 0 ms | 1176 KB | Output is correct |
10 | Correct | 0 ms | 1176 KB | Output is correct |
11 | Correct | 0 ms | 1176 KB | Output is correct |
12 | Correct | 0 ms | 1176 KB | Output is correct |
13 | Correct | 0 ms | 1176 KB | Output is correct |
14 | Correct | 0 ms | 1176 KB | Output is correct |
15 | Correct | 0 ms | 1176 KB | Output is correct |
16 | Correct | 0 ms | 1176 KB | Output is correct |
17 | Correct | 0 ms | 1176 KB | Output is correct |
18 | Correct | 0 ms | 1176 KB | Output is correct |
19 | Correct | 29 ms | 1176 KB | Output is correct |
20 | Correct | 0 ms | 1176 KB | Output is correct |
21 | Correct | 96 ms | 1176 KB | Output is correct |
22 | Correct | 16 ms | 1176 KB | Output is correct |
23 | Correct | 63 ms | 1176 KB | Output is correct |
24 | Correct | 33 ms | 1176 KB | Output is correct |
25 | Correct | 23 ms | 1176 KB | Output is correct |
26 | Correct | 69 ms | 1176 KB | Output is correct |
27 | Correct | 33 ms | 1176 KB | Output is correct |
28 | Correct | 29 ms | 1176 KB | Output is correct |
29 | Correct | 6 ms | 1176 KB | Output is correct |
30 | Correct | 9 ms | 1176 KB | Output is correct |
31 | Correct | 13 ms | 1176 KB | Output is correct |
32 | Correct | 19 ms | 1176 KB | Output is correct |
33 | Correct | 0 ms | 1176 KB | Output is correct |
34 | Execution timed out | 2000 ms | 1176 KB | Execution timed out |
35 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 1176 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 1176 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1176 KB | Output is correct |
2 | Correct | 0 ms | 1176 KB | Output is correct |
3 | Correct | 0 ms | 1176 KB | Output is correct |
4 | Correct | 0 ms | 1176 KB | Output is correct |
5 | Correct | 0 ms | 1176 KB | Output is correct |
6 | Correct | 0 ms | 1176 KB | Output is correct |
7 | Correct | 0 ms | 1176 KB | Output is correct |
8 | Correct | 0 ms | 1176 KB | Output is correct |
9 | Correct | 0 ms | 1176 KB | Output is correct |
10 | Correct | 0 ms | 1176 KB | Output is correct |
11 | Correct | 0 ms | 1176 KB | Output is correct |
12 | Correct | 0 ms | 1176 KB | Output is correct |
13 | Correct | 0 ms | 1176 KB | Output is correct |
14 | Correct | 0 ms | 1176 KB | Output is correct |
15 | Correct | 0 ms | 1176 KB | Output is correct |
16 | Correct | 0 ms | 1176 KB | Output is correct |
17 | Correct | 0 ms | 1176 KB | Output is correct |
18 | Correct | 0 ms | 1176 KB | Output is correct |
19 | Correct | 29 ms | 1176 KB | Output is correct |
20 | Correct | 0 ms | 1176 KB | Output is correct |
21 | Correct | 96 ms | 1176 KB | Output is correct |
22 | Correct | 16 ms | 1176 KB | Output is correct |
23 | Correct | 63 ms | 1176 KB | Output is correct |
24 | Correct | 33 ms | 1176 KB | Output is correct |
25 | Correct | 23 ms | 1176 KB | Output is correct |
26 | Correct | 69 ms | 1176 KB | Output is correct |
27 | Correct | 33 ms | 1176 KB | Output is correct |
28 | Correct | 29 ms | 1176 KB | Output is correct |
29 | Correct | 6 ms | 1176 KB | Output is correct |
30 | Correct | 9 ms | 1176 KB | Output is correct |
31 | Correct | 13 ms | 1176 KB | Output is correct |
32 | Correct | 19 ms | 1176 KB | Output is correct |
33 | Correct | 0 ms | 1176 KB | Output is correct |
34 | Execution timed out | 2000 ms | 1176 KB | Execution timed out |
35 | Halted | 0 ms | 0 KB | - |