Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int INF=2147483647;
- int inf=-2147483648;
- int mod=1000000007;
- #define read(x) cin >> x;
- #define fo(i,n) for(i=0;i<n;i++)
- #define one(x) cout<<(x)<<endl;
- #define two(a,b) cout<<(a)<<" "<<(b)<<endl;
- #define three(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;
- #define four(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl;
- #define write(a,i) cout << a[i] << " ";
- int main()
- {
- int n,m,k,i,uk=1,q,a,b,f=0;
- cin >> n >> m >> k;int sos[n];fill(sos,sos+n+1,0);
- fo(i,m)
- {
- cin >> q; sos[q]++;
- if (q==1) f=1;
- }
- fo(i,k)
- {
- cin >> a >> b;
- if (a==uk)
- if (f!=1)
- if (sos[b]>0) { uk=b;f=1;}
- else
- uk=b;
- // cout << a << " " << b << " " << uk << " " << f << endl;
- }
- cout << uk;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement