Submission #1071063

# Submission time Handle Problem Language Result Execution time Memory
1071063 2024-08-23T04:04:27 Z kunzaZa183 Cultivation (JOI17_cultivation) C++17
15 / 100
2000 ms 1336 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int r,c;
  cin>>r>>c;
  int n;
  cin>>n;
  vector<pair<int,int>> vpii(n);
  for(int i = 0; i < n;i++) {
    cin>>vpii[i].first>>vpii[i].second;
    vpii[i].first--, vpii[i].second--;
  }

  int minans = LLONG_MAX;
  for(int no = 0; no < r; no++ )
    for(int so = 0; so < r; so++) {
      set<pair<int,int>> spii;
      for(int j = 0; j < n;j++)
        for(int k = max(0ll,vpii[j].first-no); k <= min(r-1,vpii[j].first + so); k++) {
          spii.emplace(k, vpii[j].second);
        }
      
      vector<vector<int>> perr(r);
      for(auto a:spii)
        perr[a.first].push_back(a.second);

      int minw = 0, mine = 0, minsum = 0;
      for(int i =0 ; i < r;i++) {
        sort(perr[i].begin(),perr[i].end());
        if(perr[i].empty()) {
          goto CANT;
        }
        minw = max(minw, perr[i].front());
        mine = max(mine, c - 1 - perr[i].back());
        for(int j = 0 ; j < perr[i].size() - 1; j++) {
          minsum = max(minsum, perr[i][j + 1] - perr[i][j] - 1);
        }
      }
      
      // cout<<no<<' '<<so<<" "<<minw<<" "<<mine<<" "<<minsum<<"\n";

      minans = min(minans, no + so + max(minsum, mine + minw));

      CANT:;
    }

  cout<<minans<<"\n";
}

Compilation message

cultivation.cpp: In function 'int main()':
cultivation.cpp:36:27: 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]
   36 |         for(int j = 0 ; j < perr[i].size() - 1; j++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~
# 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 1 ms 344 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 1 ms 344 KB Output is correct
15 Correct 0 ms 344 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 1 ms 344 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 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 40 ms 468 KB Output is correct
19 Correct 56 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 163 ms 484 KB Output is correct
22 Correct 393 ms 532 KB Output is correct
23 Correct 94 ms 348 KB Output is correct
24 Correct 631 ms 792 KB Output is correct
25 Correct 503 ms 536 KB Output is correct
26 Correct 897 ms 596 KB Output is correct
27 Correct 921 ms 348 KB Output is correct
28 Correct 610 ms 348 KB Output is correct
29 Correct 758 ms 348 KB Output is correct
30 Correct 915 ms 544 KB Output is correct
31 Correct 890 ms 536 KB Output is correct
32 Correct 862 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 1 ms 344 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 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 40 ms 468 KB Output is correct
19 Correct 56 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 163 ms 484 KB Output is correct
22 Correct 393 ms 532 KB Output is correct
23 Correct 94 ms 348 KB Output is correct
24 Correct 631 ms 792 KB Output is correct
25 Correct 503 ms 536 KB Output is correct
26 Correct 897 ms 596 KB Output is correct
27 Correct 921 ms 348 KB Output is correct
28 Correct 610 ms 348 KB Output is correct
29 Correct 758 ms 348 KB Output is correct
30 Correct 915 ms 544 KB Output is correct
31 Correct 890 ms 536 KB Output is correct
32 Correct 862 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1955 ms 1336 KB Output is correct
35 Correct 1824 ms 848 KB Output is correct
36 Correct 1995 ms 1336 KB Output is correct
37 Correct 1302 ms 1224 KB Output is correct
38 Execution timed out 2024 ms 1336 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 600 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 1 ms 344 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 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 40 ms 468 KB Output is correct
19 Correct 56 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 163 ms 484 KB Output is correct
22 Correct 393 ms 532 KB Output is correct
23 Correct 94 ms 348 KB Output is correct
24 Correct 631 ms 792 KB Output is correct
25 Correct 503 ms 536 KB Output is correct
26 Correct 897 ms 596 KB Output is correct
27 Correct 921 ms 348 KB Output is correct
28 Correct 610 ms 348 KB Output is correct
29 Correct 758 ms 348 KB Output is correct
30 Correct 915 ms 544 KB Output is correct
31 Correct 890 ms 536 KB Output is correct
32 Correct 862 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1955 ms 1336 KB Output is correct
35 Correct 1824 ms 848 KB Output is correct
36 Correct 1995 ms 1336 KB Output is correct
37 Correct 1302 ms 1224 KB Output is correct
38 Execution timed out 2024 ms 1336 KB Time limit exceeded
39 Halted 0 ms 0 KB -