답안 #1071061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071061 2024-08-23T04:02:31 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 = -no; k <= so; k++) {
          int x = vpii[j].first + k;
          if(x>=0 && x< r)
            spii.emplace(vpii[j].first + 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:39: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]
   39 |         for(int j = 0 ; j < perr[i].size() - 1; j++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 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 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 40 ms 476 KB Output is correct
19 Correct 57 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 144 ms 480 KB Output is correct
22 Correct 419 ms 512 KB Output is correct
23 Correct 89 ms 600 KB Output is correct
24 Correct 632 ms 528 KB Output is correct
25 Correct 534 ms 352 KB Output is correct
26 Correct 882 ms 540 KB Output is correct
27 Correct 879 ms 552 KB Output is correct
28 Correct 570 ms 348 KB Output is correct
29 Correct 711 ms 528 KB Output is correct
30 Correct 844 ms 544 KB Output is correct
31 Correct 938 ms 348 KB Output is correct
32 Correct 885 ms 528 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 40 ms 476 KB Output is correct
19 Correct 57 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 144 ms 480 KB Output is correct
22 Correct 419 ms 512 KB Output is correct
23 Correct 89 ms 600 KB Output is correct
24 Correct 632 ms 528 KB Output is correct
25 Correct 534 ms 352 KB Output is correct
26 Correct 882 ms 540 KB Output is correct
27 Correct 879 ms 552 KB Output is correct
28 Correct 570 ms 348 KB Output is correct
29 Correct 711 ms 528 KB Output is correct
30 Correct 844 ms 544 KB Output is correct
31 Correct 938 ms 348 KB Output is correct
32 Correct 885 ms 528 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1946 ms 1332 KB Output is correct
35 Correct 1693 ms 1056 KB Output is correct
36 Execution timed out 2027 ms 1336 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 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 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 40 ms 476 KB Output is correct
19 Correct 57 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 144 ms 480 KB Output is correct
22 Correct 419 ms 512 KB Output is correct
23 Correct 89 ms 600 KB Output is correct
24 Correct 632 ms 528 KB Output is correct
25 Correct 534 ms 352 KB Output is correct
26 Correct 882 ms 540 KB Output is correct
27 Correct 879 ms 552 KB Output is correct
28 Correct 570 ms 348 KB Output is correct
29 Correct 711 ms 528 KB Output is correct
30 Correct 844 ms 544 KB Output is correct
31 Correct 938 ms 348 KB Output is correct
32 Correct 885 ms 528 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1946 ms 1332 KB Output is correct
35 Correct 1693 ms 1056 KB Output is correct
36 Execution timed out 2027 ms 1336 KB Time limit exceeded
37 Halted 0 ms 0 KB -