fork download
  1. /*
  2. ID: barish21
  3. LANG: C++14
  4. TASK: test
  5. */
  6.  
  7. /****Author: Barish Namazov****/
  8. #include <bits/stdc++.h>
  9. #include <iostream>
  10. #include <fstream>
  11. #include <cstdio>
  12. #include <queue>
  13. #include <vector>
  14. #include <algorithm>
  15. #include <iomanip>
  16. #include <map>
  17. #include <set>
  18. #include <stack>
  19. #include <cstring>
  20. #include <cmath>
  21.  
  22. using namespace std;
  23.  
  24. /***TEMPLATE***/
  25. #define intt long long
  26.  
  27. #define all(v) (v).begin(),(v).end()
  28. #define rall(v) (v).rbegin(),(v).rend()
  29. #define sz(s) (intt)s.size()
  30.  
  31. #define ms0(arr) memset(arr,0,sizeof arr)
  32. #define ms63(arr) memset(arr,63,sizeof arr)
  33.  
  34. #define forn(i,a,b) for(intt i=a;i<=b;i++)
  35. #define rofn(i,a,b) for(intt i=a;i>=b;i--)
  36. #define setf(it,myset) for(set<intt>::iterator it=myset.begin();it!=myset.end();it++)
  37.  
  38. #define fi first
  39. #define se second
  40. #define pb push_back
  41. #define mp make_pair
  42. #define VI vector<intt>
  43. #define PII pair<intt,intt>
  44. #define VPII vector< PII >
  45.  
  46. #define posl(ch) (int)(ch-'a'+1)
  47. #define posL(ch) (int)(ch-'A'+1)
  48.  
  49. #define IO ios_base::sync_with_stdio(false);cin.tie();
  50. /***************/
  51.  
  52. /***Additional Functions***/
  53. intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
  54. intt gcd(intt a,intt b){return __gcd(a, b);}
  55. intt lcm(intt a,intt b){return a*b/gcd(a,b);}
  56. intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
  57. intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}
  58.  
  59. intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
  60. string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
  61.  
  62. /**************************/
  63.  
  64. intt arr[1000001], holes[1000001], bone;
  65. int main()
  66. {
  67. //freopen("in.txt","r",stdin);
  68. //freopen("out.txt","w",stdout);
  69. //ofstream fout ("test.out");
  70. //ifstream fin ("test.in");
  71. IO;
  72. intt n, m, k;
  73. cin >> n >> m >> k;
  74. for (intt i = 1; i <= m; i++) {
  75. intt t;
  76. cin >> t;
  77. holes[t] = 1;
  78. }
  79. bone = 1;
  80. for (intt i = 1; i <= k; i++) {
  81. intt a, b;
  82. cin >> a >> b;
  83. if (holes[bone]) {
  84. cout << bone << endl;
  85. return 0;
  86. }
  87. if (bone == a)
  88. bone = b;
  89. else
  90. if (bone == b)
  91. bone = a;
  92. if (holes[bone]) {
  93. cout << bone << endl;
  94. return 0;
  95. }
  96. //cout << bone << endl;
  97. }
  98. cout << bone << endl;
  99. return 0;
  100. }
Time limit exceeded #stdin #stdout 5s 31696KB
stdin
Standard input is empty
stdout
Standard output is empty