Where's the Marble?

Sort by

recency

|

12 Discussions

|

  • + 0 comments

    include

    include

    include

    include

    include

    include

    include

    void swap(int a[],int i,int j){ int temp; temp=a[i]; a[i]=a[j]; a[j]=temp;

    }

    int main(){ int m; int n; scanf("%d %d",&m,&n); int A[10]={0}; A[m-1]=1; for(int a0 = 0; a0 < n; a0++){ int a; int b; scanf("%d %d",&a,&b); // your code goes here swap(A,a-1,b-1);

        //for(int a0 = 0; a0 < n; a0++){ printf(" %d ",A[a0]);}
    
    }
    
     for(int a0 = 0; a0 < 10; a0++){
         if(A[a0]==1)
             {
             printf("%d",a0+1);
             break;
         }
     }
    return 0;
    

    }

  • [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;
    }
    
  • + 1 comment

    Dont we already know the last cup from the inputs offered

  • + 0 comments
    #include <iostream>
    int main() {
        int n, m, a, b;
        std::cin >> m >> n;
        while(n--){
            std::cin >> a >> b;
            if(a == m || b == m)
                m = a + b - m;
        }
        std::cout << m;
        return 0;
    }
    
  • + 0 comments

    javascript renamed m to current

    current = (current == a) ? b : current == b ? a : current;

    finally log "current"