답안 #550657

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550657 2022-04-18T19:05:57 Z Lobo Cultivation (JOI17_cultivation) C++17
30 / 100
274 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

const int maxn = -1;

void solve() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<pair<int,int>> p;
    for(int i = 1; i <= q; i++) {
        int x,y; cin >> y >> x;
        p.pb(mp(x,y));
    }

    sort(all(p));

    int ans = inf;
    for(int up = 0; up <= n; up++) {
        for(int dw = 0; dw <= n; dw++) {
            vector<int> pos[n+10];
            for(auto X : p) {
                int x = X.fr;
                int y = X.sc;
                for(int i = max(1LL,y-dw); i <= min(n,y+up); i++) {
                    pos[i].pb(x);
                }
            }

            int sm = 0;
            int lmn = 0;
            int rmn = 0;
            for(int i = 1; i <= n; i++) {
                if(pos[i].size() == 0) {
                    sm = inf;
                    continue;
                }
                sort(all(pos[i]));
                lmn = max(lmn, pos[i][0]-1);
                rmn = max(rmn, m-pos[i].back());
                for(int j = 1; j < pos[i].size(); j++) {
                    sm = max(sm, pos[i][j]-pos[i][j-1]-1);
                }
            }
            ans = min(ans, dw+up+max(sm,lmn+rmn));
        }
    }

    cout << ans << endl;
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    
    int tt = 1;
    // cin >> tt;
    while(tt--) {
        solve();
    }

}

Compilation message

cultivation.cpp: In function 'void solve()':
cultivation.cpp:51:34: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |                 for(int j = 1; j < pos[i].size(); j++) {
      |                                ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 328 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 340 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 328 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 340 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 2 ms 340 KB Output is correct
18 Correct 17 ms 340 KB Output is correct
19 Correct 23 ms 344 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 43 ms 360 KB Output is correct
22 Correct 103 ms 372 KB Output is correct
23 Correct 28 ms 340 KB Output is correct
24 Correct 174 ms 432 KB Output is correct
25 Correct 127 ms 396 KB Output is correct
26 Correct 249 ms 532 KB Output is correct
27 Correct 274 ms 576 KB Output is correct
28 Correct 149 ms 340 KB Output is correct
29 Correct 205 ms 520 KB Output is correct
30 Correct 252 ms 532 KB Output is correct
31 Correct 239 ms 528 KB Output is correct
32 Correct 267 ms 624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 328 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 340 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 2 ms 340 KB Output is correct
18 Correct 17 ms 340 KB Output is correct
19 Correct 23 ms 344 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 43 ms 360 KB Output is correct
22 Correct 103 ms 372 KB Output is correct
23 Correct 28 ms 340 KB Output is correct
24 Correct 174 ms 432 KB Output is correct
25 Correct 127 ms 396 KB Output is correct
26 Correct 249 ms 532 KB Output is correct
27 Correct 274 ms 576 KB Output is correct
28 Correct 149 ms 340 KB Output is correct
29 Correct 205 ms 520 KB Output is correct
30 Correct 252 ms 532 KB Output is correct
31 Correct 239 ms 528 KB Output is correct
32 Correct 267 ms 624 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 212 ms 576 KB Output is correct
35 Correct 233 ms 584 KB Output is correct
36 Correct 233 ms 616 KB Output is correct
37 Correct 151 ms 604 KB Output is correct
38 Correct 245 ms 532 KB Output is correct
39 Correct 216 ms 604 KB Output is correct
40 Correct 232 ms 528 KB Output is correct
41 Correct 190 ms 596 KB Output is correct
42 Correct 192 ms 520 KB Output is correct
43 Correct 232 ms 520 KB Output is correct
44 Correct 223 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 110 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 110 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 328 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 320 KB Output is correct
12 Correct 1 ms 340 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 2 ms 340 KB Output is correct
18 Correct 17 ms 340 KB Output is correct
19 Correct 23 ms 344 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 43 ms 360 KB Output is correct
22 Correct 103 ms 372 KB Output is correct
23 Correct 28 ms 340 KB Output is correct
24 Correct 174 ms 432 KB Output is correct
25 Correct 127 ms 396 KB Output is correct
26 Correct 249 ms 532 KB Output is correct
27 Correct 274 ms 576 KB Output is correct
28 Correct 149 ms 340 KB Output is correct
29 Correct 205 ms 520 KB Output is correct
30 Correct 252 ms 532 KB Output is correct
31 Correct 239 ms 528 KB Output is correct
32 Correct 267 ms 624 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 212 ms 576 KB Output is correct
35 Correct 233 ms 584 KB Output is correct
36 Correct 233 ms 616 KB Output is correct
37 Correct 151 ms 604 KB Output is correct
38 Correct 245 ms 532 KB Output is correct
39 Correct 216 ms 604 KB Output is correct
40 Correct 232 ms 528 KB Output is correct
41 Correct 190 ms 596 KB Output is correct
42 Correct 192 ms 520 KB Output is correct
43 Correct 232 ms 520 KB Output is correct
44 Correct 223 ms 524 KB Output is correct
45 Runtime error 110 ms 262144 KB Execution killed with signal 9
46 Halted 0 ms 0 KB -