Advertisement
TimxAG

Untitled

Apr 10th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. int INF=2147483647;
  5. int inf=-2147483648;
  6. int mod=1000000007;
  7. #define read(x) cin >> x;
  8. #define fo(i,n) for(i=0;i<n;i++)
  9. #define one(x) cout<<(x)<<endl;
  10. #define two(a,b) cout<<(a)<<" "<<(b)<<endl;
  11. #define three(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;
  12. #define four(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl;
  13. #define write(a,i) cout << a[i] << " ";
  14. int main()
  15. {
  16. int n,m,k,i,uk=1,q,a,b,f=0;
  17. cin >> n >> m >> k;int sos[n];fill(sos,sos+n+1,0);
  18. fo(i,m)
  19. {
  20. cin >> q; sos[q]++;
  21. if (q==1) f=1;
  22. }
  23. fo(i,k)
  24. {
  25. cin >> a >> b;
  26. if (a==uk)
  27. if (f!=1)
  28. if (sos[b]>0) { uk=b;f=1;}
  29. else
  30. uk=b;
  31. // cout << a << " " << b << " " << uk << " " << f << endl;
  32. }
  33. cout << uk;
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement