Submission #441381

#TimeUsernameProblemLanguageResultExecution timeMemory
441381sam571128Paths (BOI18_paths)C++17
0 / 100
3067 ms9052 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 << 1; else cout << 0; } 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...