Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //rip zadanko
- #include <bits/stdc++.h>
- using namespace std;
- const long long N=1e5+10;
- #define ll long long
- #define pi pair<ll,ll>
- #define ft first
- #define sd second
- #define mp make_pair
- #define pb push_back
- #define VI vector<int>
- #define int ll
- #define PI 3.14159265
- int n;
- int G[N][2];
- int H[N][2];
- int podobne(int idG, int idH)
- {
- if(idG==0 && idH==0)
- return true;
- if(idG == 0 || idH == 0)
- return false;
- return ((podobne(G[idG][0], H[idH][0]) && podobne(G[idG][1], H[idH][1])) ||
- (podobne(G[idG][1], H[idH][0]) && podobne(G[idG][0], H[idH][1])));
- }
- #undef int
- int main()
- {
- #define int ll
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cerr.tie(0);
- cin>>n;
- for(int i=1;i<=n;i++)
- cin>>G[i][0]>>G[i][1];
- for(int i=1;i<=n;i++)
- cin>>H[i][0]>>H[i][1];
- if(podobne(1, 1))
- cout<<"TAK\n";
- else
- cout<<"NIE\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement