# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
801521 |
2023-08-02T06:27:08 Z |
이동현(#10092) |
Cultivation (JOI17_cultivation) |
C++17 |
|
2000 ms |
2556 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int r, c, n;
cin >> r >> c >> n;
vector<array<int, 2>> a(n);
for(int i = 0; i < n; ++i){
cin >> a[i][0] >> a[i][1];
--a[i][0];
--a[i][1];
}
vector<int> dpu;
sort(a.begin(), a.end());
for(int i = 0; i < n; ++i){
dpu.push_back(a[i][0]);
dpu.push_back(a[i][0] + 1);
dpu.push_back(a[i][0] + 2);
dpu.push_back(r - a[i][0] - 1);
dpu.push_back(r - a[i][0]);
dpu.push_back(r - a[i][0] + 1);
for(int j = i + 1; j < n; ++j){
dpu.push_back(a[j][0] - a[i][0]);
dpu.push_back(a[j][0] - a[i][0] + 1);
dpu.push_back(a[j][0] - a[i][0] + 2);
}
}
sort(dpu.begin(), dpu.end());
dpu.erase(unique(dpu.begin(), dpu.end()), dpu.end());
auto sol = [&](int dulen)->int{
int rv = (int)1e18;
for(int st = 0; st < n; ++st){
int lmx = 0, rmx = 0, lenmx = 0;
for(int i = a[st][0]; i < a[st][0] + r; ++i){
vector<int> x;
for(int j = 0; j < n; ++j){
if(a[j][0] > i - dulen && a[j][0] <= i){
x.push_back(a[j][1]);
}
}
sort(x.begin(), x.end());
if(!(int)x.size()){
lenmx = (int)1e9;
}
else{
lmx = max(lmx, x[0]);
rmx = max(rmx, c - x.back() - 1);
for(int j = 0; j + 1 < (int)x.size(); ++j){
lenmx = max(lenmx, x[j + 1] - x[j]);
}
}
}
// cout << dulen << ' ' << a[st][0] << ' ' << max(lenmx - 1, lmx + rmx) << endl;
rv = min(rv, max(lenmx - 1, lmx + rmx));
}
return rv;
};
int ans = (int)1e18;
for(auto&dulen:dpu){
// cout << dulen << endl;
ans = min(ans, dulen - 1 + sol(dulen));
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
18 ms |
440 KB |
Output is correct |
19 |
Correct |
8 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
28 ms |
340 KB |
Output is correct |
22 |
Correct |
158 ms |
596 KB |
Output is correct |
23 |
Correct |
8 ms |
344 KB |
Output is correct |
24 |
Correct |
560 ms |
852 KB |
Output is correct |
25 |
Correct |
288 ms |
852 KB |
Output is correct |
26 |
Correct |
1458 ms |
2512 KB |
Output is correct |
27 |
Correct |
1356 ms |
2556 KB |
Output is correct |
28 |
Correct |
539 ms |
852 KB |
Output is correct |
29 |
Correct |
1241 ms |
2512 KB |
Output is correct |
30 |
Correct |
1407 ms |
2512 KB |
Output is correct |
31 |
Correct |
1469 ms |
2512 KB |
Output is correct |
32 |
Correct |
1416 ms |
2512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
18 ms |
440 KB |
Output is correct |
19 |
Correct |
8 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
28 ms |
340 KB |
Output is correct |
22 |
Correct |
158 ms |
596 KB |
Output is correct |
23 |
Correct |
8 ms |
344 KB |
Output is correct |
24 |
Correct |
560 ms |
852 KB |
Output is correct |
25 |
Correct |
288 ms |
852 KB |
Output is correct |
26 |
Correct |
1458 ms |
2512 KB |
Output is correct |
27 |
Correct |
1356 ms |
2556 KB |
Output is correct |
28 |
Correct |
539 ms |
852 KB |
Output is correct |
29 |
Correct |
1241 ms |
2512 KB |
Output is correct |
30 |
Correct |
1407 ms |
2512 KB |
Output is correct |
31 |
Correct |
1469 ms |
2512 KB |
Output is correct |
32 |
Correct |
1416 ms |
2512 KB |
Output is correct |
33 |
Correct |
8 ms |
2512 KB |
Output is correct |
34 |
Incorrect |
549 ms |
2512 KB |
Output isn't correct |
35 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2068 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2068 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
18 ms |
440 KB |
Output is correct |
19 |
Correct |
8 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
28 ms |
340 KB |
Output is correct |
22 |
Correct |
158 ms |
596 KB |
Output is correct |
23 |
Correct |
8 ms |
344 KB |
Output is correct |
24 |
Correct |
560 ms |
852 KB |
Output is correct |
25 |
Correct |
288 ms |
852 KB |
Output is correct |
26 |
Correct |
1458 ms |
2512 KB |
Output is correct |
27 |
Correct |
1356 ms |
2556 KB |
Output is correct |
28 |
Correct |
539 ms |
852 KB |
Output is correct |
29 |
Correct |
1241 ms |
2512 KB |
Output is correct |
30 |
Correct |
1407 ms |
2512 KB |
Output is correct |
31 |
Correct |
1469 ms |
2512 KB |
Output is correct |
32 |
Correct |
1416 ms |
2512 KB |
Output is correct |
33 |
Correct |
8 ms |
2512 KB |
Output is correct |
34 |
Incorrect |
549 ms |
2512 KB |
Output isn't correct |
35 |
Halted |
0 ms |
0 KB |
- |