이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "parks.h"
using namespace std;
vector<bool> vis(200000,false);int cnt=0;set<int> node[200000];vector<int> u,v,a,b;
void dsf(int i, vector<int> x, vector<int> y){
vis[i]=true;
cnt++;
for(auto j: node[i]){
if(!vis[j]){
u.push_back(i);v.push_back(j);
if(x[i]==x[j]){
b.push_back((y[i]+y[j])/2);
if(x[i]==2)a.push_back(x[i]-1);
else a.push_back(x[i]+1);
}
else{
a.push_back((x[i]+x[j])/2);
b.push_back(y[i]-1);
}
dsf(j,x,y);
}
}
}
int construct_roads(vector<int> x, vector<int> y){
map<pair<int,int>,bool> m;
map<pair<int,int>,int> n;
for(int i=0;i<x.size();i++){
m[{x[i],y[i]}]=1;
n[{x[i],y[i]}]=i;
}
for(int i=0;i<x.size();i++){
if(m[{x[i]-2,y[i]}]){node[i].insert(n[{x[i]-2,y[i]}]);node[n[{x[i]-2,y[i]}]].insert(i);}
if(m[{x[i]+2,y[i]}]){node[i].insert(n[{x[i]+2,y[i]}]);node[n[{x[i]+2,y[i]}]].insert(i);}
if(m[{x[i],y[i]-2}]){node[i].insert(n[{x[i],y[i]-2}]);node[n[{x[i],y[i]-2}]].insert(i);}
if(m[{x[i],y[i]+2}]){node[i].insert(n[{x[i],y[i]+2}]);node[n[{x[i],y[i]+2}]].insert(i);}
}
dsf(0,x,y);
if(cnt==x.size()){
build(u,v,a,b);
return 1;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i=0;i<x.size();i++){
| ~^~~~~~~~~
parks.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i=0;i<x.size();i++){
| ~^~~~~~~~~
parks.cpp:47:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | if(cnt==x.size()){
| ~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |