# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1006419 | andecaandeci | 게임 (IOI14_game) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define repp(i,x,n) for(int i=x;i<=n;i++)
#define repo(i,x,n) for(int i=x;i>=n;i--)
#define cy cout<<"Yes"<<endl
#define cn cout<<"No"<<endl
#define r0 return 0
#define fi first
#define se second
#define liow ios_base::sync_with_stdio(false);cin.tie(NULL)
#define jelek cout<<"jelek"<<endl
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define pi pair<pair<int,int>,pair<int,int>>
#define p4 pair<pii,pii>
#define fl fflush(stdout)
using namespace std;
const int mod=1e9+7,maxn=1e6+5,N=(1<<17),INF=1e18;
int p[1505];
int root(int x){
if(p[x]==x) return x;
return root(p[x]);
}
void merge(int x,int y){
int rx=root(x),ry=root(y);
if(rx==ry)return;
p[rx]=ry;
}
void solve(){
int n;cin>>n;
int r=n*(n-1)/2;
repp(i,1,n){
int x,y;cin>>x>>y;
int rx=root(x),ry=root(y);
if(rx==ry) cout<<"No"<<endl;
else cout<<"Yes"<<endl;
fl;
merge(rx,ry);
}
}
signed main() {
liow;
int t=1;
// cin>>t;
while(t--){
solve();
}
}