Submission #171376

#TimeUsernameProblemLanguageResultExecution timeMemory
171376itiamWand (COCI19_wand)C++11
56 / 70
287 ms2816 KiB
#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 timeMemoryGrader output
Fetching results...