Submission #70593

#TimeUsernameProblemLanguageResultExecution timeMemory
70593khohkoAlternating Current (BOI18_alternating)C++17
0 / 100
113 ms8416 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; #define ll long long #define pb push_back #define fr first #define sc second #define MAX ((ll)(1e12+100)) #define MX ((ll)(1e6+100)) #define ARRS ((ll)(2e6+100)) #define HS ((ll)(233)) #define MOD ((ll)(1e9+7)) #define EP ((double)(1e-9)) #define LG 21 #define mul(a,b) a=((a)*(b))%MOD using namespace std; ll n,m; pair<ll,ll> a[ARRS]; ll pas[ARRS]; void eend(){ cout<<"impossible"; exit(0); } int main(){ #ifdef KHOKHO freopen("in.in","r",stdin); freopen("out.out","w",stdout); #endif // KHOKHO cin>>n>>m; for(int i=0; i<m; i++){ cin>>a[i].fr>>a[i].sc; } sort(a,a+m); ll ma=0,mb=0,j=0; multiset<pair<ll,ll> > st; for(int i=1; i<=n; i++){ while(j<m&&a[j].fr==i)st.insert({a[j].sc,j}),j++; if(ma<i){ if(!st.size())eend(); ma=st.begin()->fr; pas[st.begin()->sc]=1; st.erase(st.begin()); } if(mb<i){ if(!st.size())eend(); mb=st.begin()->fr; pas[st.begin()->sc]=0; st.erase(st.begin()); } } for(int i=0; i<m; i++){ cout<<pas[i]; } }
#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...