| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 171376 | itiam | Wand (COCI19_wand) | C++11 | 287 ms | 2816 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int L[100004],Lp[100004],Lg[100004];
int main(){
    int N,M,x,y,poc=0,cnt=0;
    cin >> N >> M;
    //unos dvoboja
    for (int i=0;i<M;i++){
        cin >> x >> y;
        if (y==1){
            L[x]=1;
            cnt+=1;
            if (cnt==1) poc=x;
            else if (x<poc) poc=x;
        }
        else{
            Lp[i-cnt]=x;
            Lg[i-cnt]=y;
        }
    }
    //traženje
    for (int i=poc;i<=N;i++){
        if (cnt==0)  break;
        if (L[i]==0){
            continue;}
        for (int j=0;j<M;j++){
            if (Lg[j]==i && L[Lp[j]]!=1){
                L[Lp[j]]=1;
                cnt+=1;
                if (Lp[j]<i)    i=Lp[j]-1;
            }
        }
        cnt-=1;
    }
    //ispis
    for (int i=1;i<=N;i++){
        cout << L[i];
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
