# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
83101 | 2018-11-05T10:45:32 Z | vex | 친구 (IOI14_friend) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define maxn 100005 #define pii pair<int,int> #define h first #define p second using namespace std; int n,br; int c[maxn]; int idx[maxn]; vector<int>adj[maxn]; int h[maxn],p[maxn]; /** 0 - IAmYourFriend 1 - MyFriendsAreYourFriends 2 - WeAreYourFriends **/ int sz[maxn]; int p[maxn]; int build() { for(int i=0;i<n;i++) { sz[i]=1; p[i]=i; } } int par(int x) { if(x!=p[x])return p[x]=par(p[x]); return x; } void unite(int x,int y) { x=par(x); y=par(y); if(x==y)return; if(sz[x]<sz[y])swap(x,y); sz[x]+=sz[y]; p[y]=x; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); cin>>n; for(int i=0;i<n;i++)cin>>c[i]; for(int i=0;i<n;i++)cin>>h[i]>>p[i]; build(); for(int i=n-1;i>=0;i--) { if(p[i]==0) { adj[i].push_back(h[i]); adj[h[i]].push_back(i); } else if(p[i]==1) { } else { } } return 0; }