이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "keys.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
vector<int>find_reachable(vector<int>r,vector<int>u,vector<int>v,vector<int>c){
int n=r.size();
int mn=n;
vector<int>p(n,0);
vector<pair<int,int>>adj[n];
vector<int>now[n];//if found key_i
for(int i=0;i<u.size();i++){
adj[u[i]].pb({v[i],c[i]});
adj[v[i]].pb({u[i],c[i]});
}
vector<bool>used(n,0),found(n,0);
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
now[j].clear();
}
fill(all(used),0);
fill(all(found),0);
queue<int>q;//nodes
q.push(i);
used[i]=true;
while(!q.empty()){
int x=q.front();
q.pop();
if(!found[r[x]]){
found[r[x]]=true;
for(auto y:now[r[x]]){
if(!used[y]){
used[y]=true;
q.push(y);
}
}
now[r[x]].clear();
}
for(auto [y,k]:adj[x]){
if(found[k]==true){
if(!used[y]){
used[y]=true;
q.push(y);
}
}
else{
now[k].pb(y);
}
}
}
for(int j=0;j<n;j++){
if(used[j]){
p[i]++;
}
}
mn=min(mn,p[i]);
}
for(int i=0;i<n;i++){
if(p[i]==mn){
p[i]=1;
}
else{
p[i]=0;
}
}
return p;
}
컴파일 시 표준 에러 (stderr) 메시지
keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for(int i=0;i<u.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... |