Submission #1071058

#TimeUsernameProblemLanguageResultExecution timeMemory
1071058kunzaZa183Cultivation (JOI17_cultivation)C++17
15 / 100
2087 ms1844 KiB
#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 (stderr)

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 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...