1 solutions

  • 0
    @ 2025-12-3 16:12:49

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int n,a=1,b=2,c=4,x,y;
    int main()
    { 
    //    freopen("1.in","r",stdin);
     //   freopen("1.out","w",stdout);
        cin>>n;
       for(int i=0;i<n;i++)
        {
           cin>>x>>y;	
           if(a==x) a=y;
           else if(a==y) a=x;
        }
        cout<<a;
        
        return 0;
    }   
    
    • 1

    Information

    ID
    835
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    4
    Accepted
    4
    Uploaded By