Submission #441383

#TimeUsernameProblemLanguageResultExecution timeMemory
441383sam571128Alternating Current (BOI18_alternating)C++17
13 / 100
3069 ms3576 KiB
#include <bits/stdc++.h> #define int long long #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; signed main(){ //fastio int n,m; cin >> n >> m; vector<pair<int,int>> v; for(int i = 0;i < m;i++){ int l,r; cin >> l >> r; l--, r--; v.push_back({l,r}); } for(int i = 0;i < (1<<m);i++){ int cnt[n] = {}; for(int j = 0;j < m;j++){ if(i&(1<<j)){ int l = v[j].first, r = v[j].second; while(true){ cnt[l] |= 2; if(l==r) break; l = (l+1)%n; } }else{ int l = v[j].first, r = v[j].second; while(true){ cnt[l] |= 1; if(l==r) break; l = (l+1)%n; } } } bool check = true; for(int j = 0;j < n;j++){ if(cnt[j]!=3){ check = false; } } if(check){ for(int j = 0;j < m;j++){ if(i&(1<<j)) cout << 0; else cout << 1; } cout << "\n"; return 0; } } cout << "impossible\n"; }
#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...