Submission #1071363

# Submission time Handle Problem Language Result Execution time Memory
1071363 2024-08-23T06:54:54 Z 12345678 Cultivation (JOI17_cultivation) C++17
30 / 100
284 ms 780 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=305;

int r, c, n, a[nx], b[nx], res=INT_MAX;
vector<int> d[nx];

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>r>>c>>n;
    for (int i=1; i<=n; i++) cin>>a[i]>>b[i];
    for (int up=0; up<r; up++)
    {
        for (int dn=0; dn<r; dn++)
        {
            for (int i=1; i<=r; i++) d[i].clear();
            int x=0, g=0, y=0, f=0;
            for (int i=1; i<=n; i++) for (int j=max(a[i]-up, 1); j<=min(r, a[i]+dn); j++) d[j].push_back(b[i]);
            for (int i=1; i<=r; i++) 
            {
                if (d[i].empty())
                {
                    f=1;
                    break;
                }
                sort(d[i].begin(), d[i].end());
                x=max(x, d[i][0]-1);
                y=max(y, c-d[i].back());
                for (int j=1; j<d[i].size(); j++) g=max(g, d[i][j]-d[i][j-1]-1);
            }
            if (f) continue;
            if (x+y>=g) res=min(res, up+dn+x+y);
            else res=min(res, up+dn+g);
        }
    }
    cout<<res;
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:32:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |                 for (int j=1; j<d[i].size(); j++) g=max(g, d[i][j]-d[i][j-1]-1);
      |                               ~^~~~~~~~~~~~
# 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 1 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 1 ms 348 KB Output is correct
16 Correct 1 ms 344 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 1 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 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 7 ms 484 KB Output is correct
19 Correct 6 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 15 ms 424 KB Output is correct
22 Correct 60 ms 344 KB Output is correct
23 Correct 16 ms 348 KB Output is correct
24 Correct 111 ms 348 KB Output is correct
25 Correct 97 ms 508 KB Output is correct
26 Correct 226 ms 544 KB Output is correct
27 Correct 230 ms 528 KB Output is correct
28 Correct 106 ms 504 KB Output is correct
29 Correct 188 ms 344 KB Output is correct
30 Correct 226 ms 344 KB Output is correct
31 Correct 226 ms 344 KB Output is correct
32 Correct 231 ms 592 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 1 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 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 7 ms 484 KB Output is correct
19 Correct 6 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 15 ms 424 KB Output is correct
22 Correct 60 ms 344 KB Output is correct
23 Correct 16 ms 348 KB Output is correct
24 Correct 111 ms 348 KB Output is correct
25 Correct 97 ms 508 KB Output is correct
26 Correct 226 ms 544 KB Output is correct
27 Correct 230 ms 528 KB Output is correct
28 Correct 106 ms 504 KB Output is correct
29 Correct 188 ms 344 KB Output is correct
30 Correct 226 ms 344 KB Output is correct
31 Correct 226 ms 344 KB Output is correct
32 Correct 231 ms 592 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 249 ms 544 KB Output is correct
35 Correct 273 ms 600 KB Output is correct
36 Correct 284 ms 520 KB Output is correct
37 Correct 158 ms 780 KB Output is correct
38 Correct 254 ms 532 KB Output is correct
39 Correct 230 ms 524 KB Output is correct
40 Correct 274 ms 348 KB Output is correct
41 Correct 131 ms 780 KB Output is correct
42 Correct 151 ms 524 KB Output is correct
43 Correct 217 ms 520 KB Output is correct
44 Correct 279 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
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 1 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 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 7 ms 484 KB Output is correct
19 Correct 6 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 15 ms 424 KB Output is correct
22 Correct 60 ms 344 KB Output is correct
23 Correct 16 ms 348 KB Output is correct
24 Correct 111 ms 348 KB Output is correct
25 Correct 97 ms 508 KB Output is correct
26 Correct 226 ms 544 KB Output is correct
27 Correct 230 ms 528 KB Output is correct
28 Correct 106 ms 504 KB Output is correct
29 Correct 188 ms 344 KB Output is correct
30 Correct 226 ms 344 KB Output is correct
31 Correct 226 ms 344 KB Output is correct
32 Correct 231 ms 592 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 249 ms 544 KB Output is correct
35 Correct 273 ms 600 KB Output is correct
36 Correct 284 ms 520 KB Output is correct
37 Correct 158 ms 780 KB Output is correct
38 Correct 254 ms 532 KB Output is correct
39 Correct 230 ms 524 KB Output is correct
40 Correct 274 ms 348 KB Output is correct
41 Correct 131 ms 780 KB Output is correct
42 Correct 151 ms 524 KB Output is correct
43 Correct 217 ms 520 KB Output is correct
44 Correct 279 ms 528 KB Output is correct
45 Runtime error 1 ms 600 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -