fork download
  1. #include <stdio.h>
  2.  
  3. int isHole[1000005];
  4.  
  5. int main(){
  6. int n, m, k;
  7. scanf("%d%d%d", &n, &m, &k);
  8. for(int i=0; i<m; i++){
  9. int h;
  10. scanf("%d", &h);
  11. isHole[h] = 1;
  12. }
  13. int pos = 1;
  14. for(int i=0; i<k; i++){
  15. int u, v;
  16. scanf("%d%d", &u, &v);
  17. if(u == pos && (!isHole[u])) pos = v;
  18. else if(v == pos && (!isHole[v])) pos = u;
  19. }
  20. printf("%d", pos);
  21. return 0;
  22. }
Success #stdin #stdout 0s 19144KB
stdin
Standard input is empty
stdout
1