제출 #894847

#제출 시각아이디문제언어결과실행 시간메모리
894847Faisal_Saqib분수 공원 (IOI21_parks)C++17
15 / 100
456 ms34984 KiB
#include <vector> #include <map> #include <queue> using namespace std; void build(std::vector<int> u, std::vector<int> v, std::vector<int> a, std::vector<int> b); int construct_roads(std::vector<int> x, std::vector<int> y) { int n=x.size(); vector<int> u,v,a,b; map<pair<int,int>,int> ind; for(int i=0;i<n;i++) ind[{x[i],y[i]}]=i; map<int,bool> vis; queue<pair<int,int>> q; q.push({x[0],y[0]}); vis[0]=1; while(q.size()) { auto f=q.front(); q.pop(); if(ind.find({f.first,f.second+2})!=ind.end() and !vis[ind[{f.first,f.second+2}]]) { vis[ind[{f.first,f.second+2}]]=1; u.push_back(ind[f]); v.push_back(ind[{f.first,f.second+2}]); if(f.first==2) { a.push_back(f.first-1); b.push_back(f.second+1); } else// 4 { a.push_back(f.first+1); b.push_back(f.second+1); } q.push({f.first,f.second+2}); } if(ind.find({f.first+2,f.second})!=ind.end() and !vis[ind[{f.first+2,f.second}]]) { vis[ind[{f.first+2,f.second}]]=1; u.push_back(ind[f]); v.push_back(ind[{f.first+2,f.second}]); a.push_back(f.first+1); b.push_back(f.second+1); q.push({f.first+2,f.second}); } if(ind.find({f.first,f.second-2})!=ind.end() and !vis[ind[{f.first,f.second-2}]]) { vis[ind[{f.first,f.second-2}]]=1; u.push_back(ind[f]); v.push_back(ind[{f.first,f.second-2}]); if(f.first==2) { a.push_back(f.first-1); b.push_back(f.second-1); } else// 4 { a.push_back(f.first+1); b.push_back(f.second-1); } q.push({f.first,f.second-2}); } if(ind.find({f.first-2,f.second})!=ind.end() and !vis[ind[{f.first-2,f.second}]]) { vis[ind[{f.first-2,f.second}]]=1; u.push_back(ind[f]); v.push_back(ind[{f.first-2,f.second}]); a.push_back(f.first-1); b.push_back(f.second-1); q.push({f.first-2,f.second}); } } if(vis.size()!=n) return 0; build(u,v,a,b); return 1; }

컴파일 시 표준 에러 (stderr) 메시지

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:74:15: warning: comparison of integer expressions of different signedness: 'std::map<int, bool>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   74 |  if(vis.size()!=n)
      |     ~~~~~~~~~~^~~
#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...