제출 #1188442

#제출 시각아이디문제언어결과실행 시간메모리
1188442alexddGarden (JOI23_garden)C++20
30 / 100
3115 ms933732 KiB
#include <bits/stdc++.h> using namespace std; int n,m,d; map<pair<int,int>,vector<int>> onpoz; int poz[500005],cntactive; bool active[500005]; pair<int,int> special[500005]; int goup[10005],goleft[10005]; signed main() { ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>m>>d; for(int i=0;i<n;i++) { int p,q; cin>>p>>q; onpoz[{p,q}].push_back(i); onpoz[{p,q+d}].push_back(i); onpoz[{p+d,q}].push_back(i); onpoz[{p+d,q+d}].push_back(i); } for(int i=0;i<m;i++) { int p,q; cin>>p>>q; special[i] = {p,q}; } int rez = d*d; for(int jos=0;jos<2*d;jos++) { for(int i=0;i<d;i++) { for(int x:onpoz[{jos,i}]) { if(!active[x]) { cntactive++; active[x] = 1; } poz[x] = jos; } } if(cntactive == n) { int minlin=jos; for(int x=0;x<n;x++) minlin = min(minlin, poz[x]); goup[jos] = minlin; } else goup[jos] = -1; } cntactive=0; for(int x=0;x<n;x++) active[x]=0; for(int jos=0;jos<2*d;jos++) { for(int i=0;i<d;i++) { for(int x:onpoz[{i,jos}]) { if(!active[x]) { cntactive++; active[x] = 1; } poz[x] = jos; } } if(cntactive == n) { int minlin=jos; for(int x=0;x<n;x++) minlin = min(minlin, poz[x]); goleft[jos] = minlin; } else goleft[jos] = -1; } for(int jos=d;jos<2*d;jos++) { for(int dr=d;dr<2*d;dr++) { assert(goup[jos]!=-1); assert(goleft[dr]!=-1); for(int le=goleft[dr];le>=0;le--) { int sus = goup[jos]; if((dr-le+1) * (jos-sus+1) >= rez) break; for(int x=0;x<m;x++) { if((le <= special[x].second && special[x].second <= dr) || (le <= special[x].second + d && special[x].second + d <= dr)) { } else { if(special[x].first + d <= jos) sus = min(sus, special[x].first + d); else sus = min(sus, special[x].first); } if((dr-le+1) * (jos-sus+1) >= rez) break; } rez = min(rez, (dr-le+1) * (jos-sus+1)); } } } cout<<rez; return 0; } /* 2 1 5 1 4 2 2 0 0 patratele se repeta din d in d obs: o sa existe tot timpu o solutie care are fiecare latura <d */
#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...