Submission #1053122

#TimeUsernameProblemLanguageResultExecution timeMemory
1053122vnm06Fountain Parks (IOI21_parks)C++17
15 / 100
95 ms39832 KiB
#include "parks.h" #include<bits/stdc++.h> using namespace std; bool pos[200004]; int used[3][200004]; vector<int> gr[200004]; void dfs(int v) { pos[v]=1; int brs=gr[v].size(); for(int i=0; i<brs; i++) { int nv=gr[v][i]; if(!pos[nv]) dfs(nv); } } int construct_roads(std::vector<int> x, std::vector<int> y) { if (x.size() == 1) { build({}, {}, {}, {}); return 1; } std::vector<int> u, v, a, b; for(int i=0; i<x.size(); i++) { used[x[i]/2-1][y[i]]=i+1; } for(int i=2; i<=200000; i+=2) { if(used[0][i] && used[0][i+2]) { u.push_back(used[0][i]-1); v.push_back(used[0][i+2]-1); a.push_back(1); b.push_back(i+1); } if(used[1][i] && used[1][i+2]) { u.push_back(used[1][i]-1); v.push_back(used[1][i+2]-1); a.push_back(5); b.push_back(i+1); } if(used[1][i] && used[0][i]) { u.push_back(used[1][i]-1); v.push_back(used[0][i]-1); a.push_back(3); b.push_back(i+1); } } for(int i=0; i<u.size(); i++) { gr[u[i]].push_back(v[i]); gr[v[i]].push_back(u[i]); } dfs(0); for(int i=0; i<x.size(); i++) if(!pos[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:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0; i<x.size(); i++)
      |                  ~^~~~~~~~~
parks.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i=0; i<u.size(); i++)
      |                  ~^~~~~~~~~
parks.cpp:61:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i=0; i<x.size(); i++) if(!pos[i]) return 0;
      |                  ~^~~~~~~~~
#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...