Submission #171376

# Submission time Handle Problem Language Result Execution time Memory
171376 2019-12-28T12:10:49 Z itiam Wand (COCI19_wand) C++11
56 / 70
287 ms 2816 KB
#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
1 Correct 2 ms 376 KB Output is correct
2 Correct 10 ms 376 KB Output is correct
3 Correct 287 ms 2816 KB Output is correct
4 Correct 175 ms 2532 KB Output is correct
5 Correct 259 ms 2552 KB Output is correct
6 Incorrect 175 ms 2684 KB Output isn't correct
7 Correct 192 ms 2552 KB Output is correct
8 Correct 227 ms 2756 KB Output is correct
9 Incorrect 106 ms 2452 KB Output isn't correct
10 Correct 140 ms 2780 KB Output is correct