| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 436764 | David_M | 열쇠 (IOI21_keys) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "keys.h"
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
const int N=300005;
vector<pii> V[N];
pair<int, int> ans[N];
vi find_reachable(vi r, vi u, vi v, vi c){
int n=r.size(), m=u.size();
int Ans[n];
for(int j=0; j<m; j++){
int x=u[j], y=v[j], C=c[j];
V[x].pb({y,C});
V[y].pb({x,C});
}
for (int i=0; i<n; i++){
bool C[n];
vi vv[n];
C[r[i]]=true;
queue<int> q;
q.push(i);
while(!q.empty()){ans[i].F++;
int x=q.top();
q.pop();
for (auto [y,c]:V[x]) if(!C[c])vv[c].pb(y); else q.push(y);
if(!C[r[x]]){for (auto k:vv[r[x]])q.push(k); C[r[i]]=true;}
}
}
sort(ans, ans+n);
int R=ans[0].F, o=0;
while(ans[o].F==R){
Ans[ans[o].S]=1;
o++;
}
return Ans;
}
