Submission #1064298

#TimeUsernameProblemLanguageResultExecution timeMemory
1064298UnforgettableplCultivation (JOI17_cultivation)C++17
30 / 100
318 ms852 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int INF = 1e15; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int r,c,n; cin >> r >> c >> n; vector<pair<int,int>> points(n); for(auto&[a,b]:points)cin>>a>>b; auto check = [&](int U,int L){ vector<vector<int>> lines(r+1); for(auto&[x,y]:points) { for(int i=max(x-L,1ll);i<=min(x+U,r);i++) lines[i].emplace_back(y); } int left_maxi = 0; int right_maxi = 0; int tot_maxi = 0; for(int i=1;i<=r;i++) { sort(lines[i].begin(),lines[i].end()); if(lines[i].empty())return INF; left_maxi=max(left_maxi,lines[i].front()-1); right_maxi=max(right_maxi,c-lines[i].back()); for(int x=1;x<lines[i].size();x++) { tot_maxi=max(tot_maxi,lines[i][x]-lines[i][x-1]-1); } } return max(left_maxi+right_maxi,tot_maxi); }; int ans = r+c; for(int R=0;R<r;R++){ for(int C=0;C<r;C++){ ans=min(ans,R+C+check(R,C)); } } cout << ans << '\n'; }

Compilation message (stderr)

cultivation.cpp: In lambda function:
cultivation.cpp:29:26: 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]
   29 |             for(int x=1;x<lines[i].size();x++) {
      |                         ~^~~~~~~~~~~~~~~~
#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...