Submission #146307

#TimeUsernameProblemLanguageResultExecution timeMemory
146307MvCAlternating Current (BOI18_alternating)C++11
13 / 100
3034 ms3360 KiB
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> //#include "boxes.h" #define rc(x) return cout<<x<<endl,0 #define pb push_back #define mkp make_pair #define in insert #define er erase #define fd find #define fr first #define sc second typedef long long ll; typedef long double ld; const ll INF=0x3f3f3f3f3f3f3f3f; const ll llinf=(1LL<<61); const int inf=(1<<30); const int nmax=1e5+50; const int mod=1e9+7; using namespace std; int n,m,i,j,t,vz[nmax],rs[nmax],nr,l; pair<int,int>a[nmax]; vector<int>rad; int main() { //freopen("sol.in","r",stdin); //freopen("sol.out","w",stdout); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); cin>>n>>m; for(i=1;i<=m;i++)cin>>a[i].fr>>a[i].sc; for(i=1;i<=m;i++)rad.pb(i); while((double)clock()/CLOCKS_PER_SEC<2.950) { shuffle(rad.begin(),rad.end(),rng); nr=n; for(i=1;i<=n;i++)vz[i]=0; for(i=0;i<m;i++) { j=rad[i]; if(a[j].fr<=a[j].sc) { for(t=a[j].fr;t<=a[j].sc;t++) { if(!vz[t])nr--; vz[t]=1; } } else { for(t=a[j].fr;t<=n;t++) { if(!vz[t])nr--; vz[t]=1; } for(t=1;t<=a[j].sc;t++) { if(!vz[t])nr--; vz[t]=1; } } if(!nr)break; } for(j=1;j<=n;j++)vz[j]=0; nr=n; l=i; for(i++;i<m;i++) { j=rad[i]; if(a[j].fr<=a[j].sc) { for(t=a[j].fr;t<=a[j].sc;t++) { if(!vz[t])nr--; vz[t]=1; } } else { for(t=a[j].fr;t<=n;t++) { if(!vz[t])nr--; vz[t]=1; } for(t=1;t<=a[j].sc;t++) { if(!vz[t])nr--; vz[t]=1; } } if(!nr)break; } if(i<m) { for(i=l+1;i<m;i++)rs[rad[i]]=1; for(i=1;i<=m;i++)cout<<rs[i]; cout<<endl; exit(0); } } cout<<"impossible"<<endl; return 0; }

Compilation message (stderr)

alternating.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
alternating.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
#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...