Submission #824724

#TimeUsernameProblemLanguageResultExecution timeMemory
824724andrei_boacaFountain Parks (IOI21_parks)C++17
5 / 100
98 ms25784 KiB
#include "parks.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; typedef pair<int,int> pii; map<pii,int> ind; struct point { int x,y; } v[200005]; int k; vector<int> myy[200005]; vector<int> muchii[200005]; bool have[11][200005]; bool use[200005]; void dfs(int nod) { use[nod]=1; for(int i:muchii[nod]) if(!use[i]) dfs(i); } int construct_roads(std::vector<int> X, std::vector<int> Y) { k=X.size(); int xmax=0; for(int i=0;i<k;i++) { v[i]={X[i],Y[i]}; ind[{X[i],Y[i]}]=i; xmax=max(xmax,X[i]); myy[X[i]].push_back(Y[i]); have[X[i]][Y[i]]=1; } if(xmax<=2) { sort(myy[2].begin(),myy[2].end()); vector<int> U,V,a,b; for(int i=1;i<myy[2].size();i++) { if(myy[2][i]-myy[2][i-1]!=2) return 0; int x=2; int yu=myy[2][i-1]; int yv=myy[2][i]; U.push_back(ind[{x,yu}]); V.push_back(ind[{x,yv}]); a.push_back(x-1); b.push_back(yv-1); } build(U,V,a,b); return 1; } if(xmax<=4) { sort(myy[2].begin(),myy[2].end()); sort(myy[4].begin(),myy[4].end()); vector<int> U,V,A,B; for(int i=2;i<=200000;i+=2) if(have[2][i]&&have[2][i-2]) { int a=ind[{2,i}]; int b=ind[{2,i-1}]; U.push_back(a); V.push_back(b); muchii[a].push_back(b); muchii[b].push_back(a); A.push_back(1); B.push_back(i-1); } for(int i=2;i<=200000;i+=2) if(have[4][i]&&have[4][i-2]) { int a=ind[{4,i}]; int b=ind[{4,i-2}]; U.push_back(a); V.push_back(b); muchii[a].push_back(b); muchii[b].push_back(a); A.push_back(5); B.push_back(i-1); } for(int i=2;i<=200000;i+=2) if(have[2][i]&&have[4][i]) { int a=ind[{2,i}]; int b=ind[{4,i}]; U.push_back(a); V.push_back(b); muchii[a].push_back(b); muchii[b].push_back(a); A.push_back(3); B.push_back(i+1); } dfs(0); for(int i=0;i<k;i++) if(!use[i]) return 0; build(U,V,A,B); return 1; } }

Compilation message (stderr)

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i=1;i<myy[2].size();i++)
      |                     ~^~~~~~~~~~~~~~
parks.cpp:103:1: warning: control reaches end of non-void function [-Wreturn-type]
  103 | }
      | ^
#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...