Where's the Marble?

  • [deleted]
    + 0 comments
    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main(){
        int m;
        int n;
        cin >> m >> n;
        for(int i = 0; i < n; i++)
        {
            int a;
            int b;
            cin >> a >> b;
            if((a==m))
                m=b;
            else if (b==m)
                m=a;
           
        }
        cout<<m;
        return 0;
    }