Submission #826772

#TimeUsernameProblemLanguageResultExecution timeMemory
826772jamezzzGarden (JOI23_garden)C++17
45 / 100
3073 ms200420 KiB
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define fi first #define se second #define pb push_back #define INF 1023456789 #define sz(x) ((int)x.size()) #define all(x) x.begin(),x.end() typedef long long ll; typedef pair<int,int> ii; typedef pair<ll,ll> pll; #define maxd 5005 int n,m,d; int mx[maxd][maxd],my[maxd][maxd]; int main(){ sf("%d%d%d",&n,&m,&d); for(int i=0;i<n;++i){ int x,y;sf("%d%d",&x,&y); mx[0][0]=max(mx[0][0],x); my[0][0]=max(my[0][0],y); my[0][y+1]=max(my[0][y+1],y+d); mx[x+1][0]=max(mx[x+1][0],x+d); } deque<ii> tmp; for(int i=0;i<m;++i){ int x,y;sf("%d%d",&x,&y); tmp.pb({x,y}); } sort(all(tmp)); for(int i=0;i<d;++i){ for(int j=0;j<d;++j){ if(i!=0){ mx[i][j]=max(mx[i][j],mx[i-1][j]); my[i][j]=max(my[i][j],my[i-1][j]); } if(j!=0){ mx[i][j]=max(mx[i][j],mx[i][j-1]); my[i][j]=max(my[i][j],my[i][j-1]); } } } int ans=INF; for(int y=0;y<d;++y){ deque<ii> dq; for(auto p:tmp)dq.pb(p); for(int x=0;x<d;++x){ while(dq.front().fi<x){ ii pr=dq.front(); dq.pop_front(); dq.pb({pr.fi+d,pr.se}); } int h=my[x][y]; for(int i=sz(dq)-1;i>=0;--i){ if(dq[i].fi<mx[x][y])break; ans=min(ans,(dq[i].fi-x+1)*(h-y+1)); h=max(h,dq[i].se+(dq[i].se<y)*d); } ans=min(ans,(mx[x][y]-x+1)*(h-y+1)); } } pf("%d\n",ans); }

Compilation message (stderr)

garden.cpp: In function 'int main()':
garden.cpp:22:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  sf("%d%d%d",&n,&m,&d);
      |    ^
garden.cpp:24:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   int x,y;sf("%d%d",&x,&y);
      |             ^
garden.cpp:32:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   int x,y;sf("%d%d",&x,&y);
      |             ^
#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...