이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
struct edge{
int u,v;
int weight;
edge(int _u,int _v,int _w){
u=_u;
v=_v;
weight=_w;
}
};
std::vector<edge> adj[2000];
std::vector<bool> visited(2000,false);
int k=1;
std::set<int> s;
void dfs(int n, std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c){
if(visited[n]){
return;
}else{
visited[n]=true;
s.insert(r[n]);
}
for(int i=0;i<adj[n].size();i++){
int y=adj[n][i].v;
int f=adj[n][i].weight;
if(s.count(f)==1 && visited[y]==false){
k+=1;
dfs(y,r,u,v,c);
}
}
}
std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) {
std::vector<int> ans(r.size(), 1);
for(int i=0;i<u.size();i++){
adj[u[i]].push_back(edge(u[i],v[i],c[i]));
adj[v[i]].push_back(edge(v[i],u[i],c[i]));
}
for(int i=0;i<r.size();i++){
s.erase(s.begin(),s.end());
s.insert(r[i]);
dfs(i,r,u,v,c);
ans[i]=k;
k=1;
fill(visited.begin(),visited.end(),false);
}
int m=1000000;
for(int i=0;i<r.size();i++){
m=std::min(m,ans[i]);
}
for(int i=0;i<r.size();i++){
if(ans[i]==m){
ans[i]=1;
}else{
ans[i]=0;
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
keys.cpp: In function 'void dfs(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:27:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<edge>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i=0;i<adj[n].size();i++){
| ~^~~~~~~~~~~~~~
keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:39:15: 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<u.size();i++){
| ~^~~~~~~~~
keys.cpp:43:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for(int i=0;i<r.size();i++){
| ~^~~~~~~~~
keys.cpp:52:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i=0;i<r.size();i++){
| ~^~~~~~~~~
keys.cpp:55:15: 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<r.size();i++){
| ~^~~~~~~~~
# | 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... |