Submission #226109

#TimeUsernameProblemLanguageResultExecution timeMemory
226109MKopchevAlternating Current (BOI18_alternating)C++14
13 / 100
2805 ms3388 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=1e5+42; const double TL=2.8; int sz,n; pair<int,int> inp[nmax]; double start; int type[nmax]; int pref[2][nmax]; mt19937 rng(42); void test() { for(int i=1;i<=sz;i++) { pref[0][i]=0; pref[1][i]=0; } for(int i=1;i<=n;i++) if(inp[i].first<=inp[i].second) { pref[type[i]][inp[i].first]++; pref[type[i]][inp[i].second+1]--; } else { pref[type[i]][inp[i].first]++; pref[type[i]][sz+1]--; pref[type[i]][1]++; pref[type[i]][inp[i].second+1]--; } for(int i=1;i<=sz;i++) { pref[0][i]+=pref[0][i-1]; if(pref[0][i]==0)return; pref[1][i]+=pref[1][i-1]; if(pref[1][i]==0)return; } for(int i=1;i<=n;i++) printf("%i",type[i]); printf("\n"); exit(0); } int main() { start=clock(); scanf("%i%i",&sz,&n); for(int i=1;i<=n;i++) scanf("%i%i",&inp[i].first,&inp[i].second); while(1.0*(clock()-start)/CLOCKS_PER_SEC<TL) { for(int i=1;i<=n;i++) type[i]=rng()%2; test(); } printf("impossible\n"); return 0; }

Compilation message (stderr)

alternating.cpp: In function 'int main()':
alternating.cpp:61:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i",&sz,&n);
     ~~~~~^~~~~~~~~~~~~~~
alternating.cpp:63:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i",&inp[i].first,&inp[i].second);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...