Submission #1071055

# Submission time Handle Problem Language Result Execution time Memory
1071055 2024-08-23T03:53:09 Z thinknoexit Cultivation (JOI17_cultivation) C++17
30 / 100
315 ms 796 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 303;
int s[N], e[N];
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int r, c;
    cin >> r >> c;
    int n;
    cin >> n;
    for (int i = 1;i <= n;i++) cin >> s[i] >> e[i];
    // iterate for all O(n ^ 2)
    ll mn = LLONG_MAX;
    for (int u = 0;u < r;u++) {
        for (int d = 0;d < r;d++) {
            bool ch = 1;
            int mx = 0;
            int dl = 0, dr = 0;
            multiset<int> ms;
            vector<vector<int>> event(r + 1);
            for (int i = 1;i <= n;i++) {
                for (int j = max(1, s[i] - u);j <= min(r, s[i] + d);j++)
                    event[j].push_back(e[i]);
            }
            for (int i = 1;i <= r;i++) {
                sort(event[i].begin(), event[i].end());
                event[i].resize(unique(event[i].begin(), event[i].end()) - event[i].begin());
                if (event[i].empty()) {
                    ch = 0;
                    break;
                }
                int sz = event[i].size();
                for (int j = 0;j < sz - 1;j++) {
                    mx = max(mx, event[i][j + 1] - event[i][j] - 1);
                }
                dl = max(dl, event[i][0] - 1);
                dr = max(dr, c - event[i][sz - 1]);
            }
            if (ch) {
                mn = min(mn, 0ll + u + d + max(dl + dr, mx));
                //cout << u << ' ' << d << ' ' << dl << ' ' << dr << ' ' << mx << '\n';
            }
        }
    }
    cout << mn << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 14 ms 492 KB Output is correct
19 Correct 13 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 33 ms 488 KB Output is correct
22 Correct 75 ms 484 KB Output is correct
23 Correct 20 ms 348 KB Output is correct
24 Correct 153 ms 456 KB Output is correct
25 Correct 104 ms 348 KB Output is correct
26 Correct 288 ms 348 KB Output is correct
27 Correct 277 ms 348 KB Output is correct
28 Correct 139 ms 508 KB Output is correct
29 Correct 239 ms 344 KB Output is correct
30 Correct 284 ms 348 KB Output is correct
31 Correct 291 ms 796 KB Output is correct
32 Correct 298 ms 536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 14 ms 492 KB Output is correct
19 Correct 13 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 33 ms 488 KB Output is correct
22 Correct 75 ms 484 KB Output is correct
23 Correct 20 ms 348 KB Output is correct
24 Correct 153 ms 456 KB Output is correct
25 Correct 104 ms 348 KB Output is correct
26 Correct 288 ms 348 KB Output is correct
27 Correct 277 ms 348 KB Output is correct
28 Correct 139 ms 508 KB Output is correct
29 Correct 239 ms 344 KB Output is correct
30 Correct 284 ms 348 KB Output is correct
31 Correct 291 ms 796 KB Output is correct
32 Correct 298 ms 536 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 299 ms 528 KB Output is correct
35 Correct 312 ms 520 KB Output is correct
36 Correct 308 ms 548 KB Output is correct
37 Correct 191 ms 496 KB Output is correct
38 Correct 301 ms 348 KB Output is correct
39 Correct 272 ms 344 KB Output is correct
40 Correct 311 ms 344 KB Output is correct
41 Correct 144 ms 344 KB Output is correct
42 Correct 194 ms 540 KB Output is correct
43 Correct 266 ms 528 KB Output is correct
44 Correct 315 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 14 ms 492 KB Output is correct
19 Correct 13 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 33 ms 488 KB Output is correct
22 Correct 75 ms 484 KB Output is correct
23 Correct 20 ms 348 KB Output is correct
24 Correct 153 ms 456 KB Output is correct
25 Correct 104 ms 348 KB Output is correct
26 Correct 288 ms 348 KB Output is correct
27 Correct 277 ms 348 KB Output is correct
28 Correct 139 ms 508 KB Output is correct
29 Correct 239 ms 344 KB Output is correct
30 Correct 284 ms 348 KB Output is correct
31 Correct 291 ms 796 KB Output is correct
32 Correct 298 ms 536 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 299 ms 528 KB Output is correct
35 Correct 312 ms 520 KB Output is correct
36 Correct 308 ms 548 KB Output is correct
37 Correct 191 ms 496 KB Output is correct
38 Correct 301 ms 348 KB Output is correct
39 Correct 272 ms 344 KB Output is correct
40 Correct 311 ms 344 KB Output is correct
41 Correct 144 ms 344 KB Output is correct
42 Correct 194 ms 540 KB Output is correct
43 Correct 266 ms 528 KB Output is correct
44 Correct 315 ms 344 KB Output is correct
45 Runtime error 2 ms 604 KB Execution killed with signal 6
46 Halted 0 ms 0 KB -