Submission #819864

#TimeUsernameProblemLanguageResultExecution timeMemory
819864Marco_EscandonFountain Parks (IOI21_parks)C++17
0 / 100
1 ms328 KiB
#include "parks.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; ll cad[7][200004]={ }; int construct_roads(std::vector<int> x, std::vector<int> y) { if (x.size() == 1) { build({}, {}, {}, {}); return 1; } ll n=x.size(); for(int i=0; i<n; i++) { cad[x[i]][y[i]]=i+1; } n=200001; std::vector<int> u, v, a, b; ll pl=0; for(int i=2; i<n; i+=2) { if(cad[2][i]==0&&cad[4][i]==0&&cad[6][i]==0&&cad[2][i-2]!=0&&cad[4][i-2]!=0&&cad[6][i-2]!=0) { if(pl==1) { build(u, v, a, b); return 0; } pl=1; } if(cad[2][i]!=0&&cad[2][i+2]!=0) { u.push_back(cad[2][i]-1); v.push_back(cad[2][i+2]-1); a.push_back(1); b.push_back(i+1); } if(cad[6][i]!=0&&cad[6][i+2]!=0) { u.push_back(cad[6][i]-1); v.push_back(cad[6][i+2]-1); a.push_back(7); b.push_back(i+1); } } for(int i=2; i<n; i+=2) { if(cad[4][i]!=0&&cad[4][i+2]==0) { if(cad[2][i]!=0) { u.push_back(cad[2][i]-1); v.push_back(cad[4][i]-1); a.push_back(3); b.push_back(i+1); } if(cad[6][i]!=0) { u.push_back(cad[4][i]-1); v.push_back(cad[6][i]-1); a.push_back(5); b.push_back(i+1); } } else if(cad[4][i]!=0&&cad[2][i+2]==0&&cad[2][i]!=0&&cad[6][i+2]==0&&cad[6][i]!=0) { u.push_back(cad[4][i]-1); v.push_back(cad[4][i+2]-1); a.push_back(3); b.push_back(i+1); u.push_back(cad[2][i]-1); v.push_back(cad[4][i]-1); a.push_back(3); b.push_back(i-1); u.push_back(cad[6][i]-1); v.push_back(cad[4][i]-1); a.push_back(5); b.push_back(i+1); } else if(cad[4][i]!=0&&cad[2][i+2]==0&&cad[2][i]!=0) { u.push_back(cad[4][i]-1); v.push_back(cad[4][i+2]-1); a.push_back(5); b.push_back(i+1); u.push_back(cad[2][i]); v.push_back(cad[4][i]); a.push_back(3); b.push_back(i+1); } else if(cad[4][i]!=0&&cad[6][i+2]==0&&cad[6][i]!=0) { u.push_back(cad[4][i]-1); v.push_back(cad[4][i+2]-1); a.push_back(3); b.push_back(i+1); u.push_back(cad[6][i]-1); v.push_back(cad[4][i]-1); a.push_back(5); b.push_back(i+1); } else if(cad[4][i]!=0&&cad[4][i+2]!=0) { u.push_back(cad[4][i]-1); v.push_back(cad[4][i+2]-1); a.push_back(5); b.push_back(i+1); } } /*for(int i=0; i<a.size(); i++) { cout<<u[i]<<" "<<v[i]<<" "<<a[i]<<" "<<b[i]<<"\n"; }*/ build(u, v, a, b); return 1; }
#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...