답안 #1071058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071058 2024-08-23T04:00:32 Z kunzaZa183 Cultivation (JOI17_cultivation) C++17
15 / 100
2000 ms 1844 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++) 
          spii.emplace(vpii[j].first + k, vpii[j].second);
      
      vector<vector<int>> perr(r);
      for(auto a:spii)
        if(0 <= a.first && a.first < r && a.second >= 0 && a.second < c)
          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++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 344 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 78 ms 348 KB Output is correct
19 Correct 95 ms 492 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 243 ms 348 KB Output is correct
22 Correct 710 ms 568 KB Output is correct
23 Correct 148 ms 508 KB Output is correct
24 Correct 1131 ms 600 KB Output is correct
25 Correct 817 ms 600 KB Output is correct
26 Correct 1501 ms 580 KB Output is correct
27 Correct 1614 ms 640 KB Output is correct
28 Correct 1014 ms 612 KB Output is correct
29 Correct 1319 ms 848 KB Output is correct
30 Correct 1553 ms 864 KB Output is correct
31 Correct 1591 ms 604 KB Output is correct
32 Correct 1545 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 344 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 78 ms 348 KB Output is correct
19 Correct 95 ms 492 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 243 ms 348 KB Output is correct
22 Correct 710 ms 568 KB Output is correct
23 Correct 148 ms 508 KB Output is correct
24 Correct 1131 ms 600 KB Output is correct
25 Correct 817 ms 600 KB Output is correct
26 Correct 1501 ms 580 KB Output is correct
27 Correct 1614 ms 640 KB Output is correct
28 Correct 1014 ms 612 KB Output is correct
29 Correct 1319 ms 848 KB Output is correct
30 Correct 1553 ms 864 KB Output is correct
31 Correct 1591 ms 604 KB Output is correct
32 Correct 1545 ms 640 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Execution timed out 2087 ms 1844 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 856 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 856 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 1 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 344 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 78 ms 348 KB Output is correct
19 Correct 95 ms 492 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 243 ms 348 KB Output is correct
22 Correct 710 ms 568 KB Output is correct
23 Correct 148 ms 508 KB Output is correct
24 Correct 1131 ms 600 KB Output is correct
25 Correct 817 ms 600 KB Output is correct
26 Correct 1501 ms 580 KB Output is correct
27 Correct 1614 ms 640 KB Output is correct
28 Correct 1014 ms 612 KB Output is correct
29 Correct 1319 ms 848 KB Output is correct
30 Correct 1553 ms 864 KB Output is correct
31 Correct 1591 ms 604 KB Output is correct
32 Correct 1545 ms 640 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Execution timed out 2087 ms 1844 KB Time limit exceeded
35 Halted 0 ms 0 KB -