Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define vi vector<int>
- #define LEN 12
- #define cont continue
- #define bk break
- template <class T>
- void print(T a){
- for (auto var : a)
- cout << var << ' ';
- cout << endl;
- }
- int main(){
- vi ar(LEN);
- for (int i = 0; i < LEN; ++i)
- ar[i]=i;
- int a,b;
- int i,j;
- while(cin>>a>>b)
- {
- for (i = ar[a]; i != ar[i]; i = ar[i]) ;
- for (j = ar[b]; j != ar[j]; j = ar[j]) ;
- if (i == j) cont;
- ar[i]=j;
- }
- print(ar);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement