Submission #952873

#TimeUsernameProblemLanguageResultExecution timeMemory
952873koukirocksAlternating Current (BOI18_alternating)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #define speed ios_base::sync_with_stdio(0); cin.tie(0) #define all(x) (x).begin(),(x).end() #define F first #define S second namespace{using namespace std;} typedef long long ll; typedef double db; typedef long double ldb; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MAX=15+10,P=1e9+7; const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f; int n,m; struct segment{ pii rg; int id; }seg[MAX]; int main() { speed; cin>>n>>m; for (int i=0;i<m;i++) { cin>>seg[i].rg.F>>seg[i].rg.S; seg[i].id=i; } sort(seg,seg+m,[&](segment a,segment b) { if (a.rg.F!=b.rg.F) return a.rg.F<b.rg.F; else return a.rg.S>b.rg.S; }); int cvr[2]={0,0}; int ans=0; for (int i=0;i<m;i++) { int id; if (cvr[0]<cvr[1]) id=0; else id=1; if (seg[i].rg.F<=cvr[id]+1) { cvr[id]=max(cvr[id],seg[i].rg.S); if (id==0) ans|=(1<<seg[i].id); } else { cout<<"impossible\n"; return 0; } // cout<<cvr[0]<<" "<<cvr[1]<<"\n"; } if (cvr[0]!=n or cvr[1]!=n) { cout<<"impossible\n"; return 0; } for (int i=0;i<m;i++) { if (ans&(1<<i)) cout<<"1"; else cout<<"0"; } return 0; } /* 7 6 1 2 1 5 2 3 5 7 6 7 3 4 */
#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...