Submission #1071068

#TimeUsernameProblemLanguageResultExecution timeMemory
1071068kunzaZa183Cultivation (JOI17_cultivation)C++17
30 / 100
1843 ms1044 KiB
#include <bits/stdc++.h> using namespace std; 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--; } long long 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(0,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, ((long long)no) + so + max(minsum, mine + minw)); CANT:; } cout<<minans<<"\n"; }

Compilation message (stderr)

cultivation.cpp: In function 'int main()':
cultivation.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int j = 0 ; j < perr[i].size() - 1; j++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...