Submission #35365

#TimeUsernameProblemLanguageResultExecution timeMemory
35365pedro_sponchiadoCultivation (JOI17_cultivation)C++14
0 / 100
0 ms2084 KiB
#include<bits/stdc++.h> using namespace std; const int maxn=310; const int INF=2000000010; int n, x[maxn], y[maxn], r, c, a, b; int y_x[maxn]; int x_x[maxn]; vector<pair<int, int> > comp_x; int marc[maxn][50]; int main(){ scanf("%d %d %d", &r, &c, &n); for(int i=1; i<=n; i++){ scanf("%d %d", &a, &b); comp_x.push_back(make_pair(b, a)); } sort(comp_x.begin(), comp_x.end()); for(int i=0; i<comp_x.size(); i++){ x[i+1]=comp_x[i].first; y[i+1]=comp_x[i].second; // printf("%d %d\n", x[i+1], y[i+1]); } int resp=INF+10; for(int cima=0; cima<=r; cima++){ for(int baixo=0; baixo<=r; baixo++){ for(int i=1; i<=n; i++){ for(int j=1; j<=r; j++){ marc[i][j]=0; } } for(int i=1; i<=n; i++){ for(int j=0; j<=cima; j++){ if(y[i]+j<=r) marc[i][y[i]+j]=1; } for(int j=1; j<=baixo; j++){ if(y[i]-j>=0) marc[i][y[i]-j]=1; } } /*for(int i=1; i<=r; i++){ for(int j=1; j<=c; j++){ printf("%d ", marc[j][i]); } printf("\n"); } printf("\n");*/ int maxi=0; int maxi_c=0; int maxi_f=0; int t=0; for(int j=1; j<=r; j++){ int acumulado=0; for(int i=1; i<=n; i++){ if(marc[i][j]==0) acumulado+=x[i]-x[i-1]; else if(marc[i][j]==1){ acumulado+=x[i]-x[i-1]-1; if(i==1) maxi_c=max(maxi_c, x[i]-1); else if(i==n) maxi_f=max(maxi_f, c-x[i]); else maxi=max(maxi, acumulado); } } if(acumulado==c){ t=1; break; } } if(t) break; resp=min(resp, cima+baixo+max(maxi, maxi_c+maxi_f)); } } printf("%d\n", resp); return 0; }

Compilation message (stderr)

cultivation.cpp: In function 'int main()':
cultivation.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<comp_x.size(); i++){
                ^
cultivation.cpp:17:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &r, &c, &n);
                               ^
cultivation.cpp:20:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a, &b);
                         ^
#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...