Submission #436468

#TimeUsernameProblemLanguageResultExecution timeMemory
436468ApiramFountain Parks (IOI21_parks)C++17
5 / 100
71 ms8268 KiB
#include "parks.h" #include<bits/stdc++.h> using namespace std; void build(vector<int> u, vector<int> v, vector<int> a, vector<int> b); struct point { int x,y,index; }; bool dist(point x,point y){ if (pow(x.x - y.x,2)+pow(x.y-y.y,2)!=4)return false; return true; } int construct_roads(std::vector<int> x, std::vector<int> y) { vector<point>arr; int n = x.size(); bool ok=true; for (int i = 0 ;i<n;++i){ if (x[i]!=x[0])ok=false; arr.push_back({x[i],y[i],i}); } vector<int>ansx,ansy,ansxi,ansyi; if (ok){ sort(arr.begin(),arr.end(),[&](point a,point b){ return a.y<b.y; }); for (int i = 1;i<n;++i){ if (dist(arr[i],arr[i-1])){ ansx.push_back(min(arr[i].x,arr[i-1].x) + 1); ansy.push_back(min(arr[i].y,arr[i-1].y)+1); ansxi.push_back(arr[i].index); ansyi.push_back(arr[i-1].index); } else return 0; } build(ansxi,ansyi,ansx,ansy); return 1;} else{ sort(arr.begin(),arr.end(),[&](point a,point b){ if (a.x==b.x)return a.y<b.y; return a.x<b.x; }); int i =1; for (;i<n;++i){ if (arr[i].x!=2)break; if (dist(arr[i],arr[i-1])){ ansx.push_back(min(arr[i].x,arr[i-1].x) - 1); ansy.push_back(min(arr[i].y,arr[i-1].y) + 1); ansxi.push_back(arr[i].index); ansyi.push_back(arr[i-1].index); } else return 0; } for (;i<n;++i){ if (arr[i-1].x==2)continue; if (dist(arr[i],arr[i-1])){ ansx.push_back(min(arr[i].x,arr[i-1].x) + 1); ansy.push_back(min(arr[i].y,arr[i-1].y) + 1); ansxi.push_back(arr[i].index); ansyi.push_back(arr[i-1].index); } else return 0; } if (ansxi.empty()){ if (dist(arr[0],arr[1])){ ansx.push_back(min(arr[1].x,arr[0].x) + 1); ansy.push_back(min(arr[1].y,arr[0].y) - 1); ansxi.push_back(arr[1].index); ansyi.push_back(arr[0].index); build(ansxi,ansyi,ansx,ansy); return 1; } return 0; } build(ansxi,ansyi,ansx,ansy); 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...