Submission #153129

#TimeUsernameProblemLanguageResultExecution timeMemory
153129SwanAlternating Current (BOI18_alternating)C++14
0 / 100
27 ms4944 KiB
#include <bits/stdc++.h> #define stop system("pause") #define INP freopen("input.txt","r",stdin) #define OUTP freopen("solve1.txt","w",stdout) #define int long long using namespace std; typedef long long ll; bool c1[1000],c2[1000]; int n,m; void clean(int n){ for(int i(0); i < n;i++)c1[i] = c2[i] = 0; } void set_color(int x,int y,int c){ if(x <= y ){ for(int i(x);i<=y;i++){ if(c == 0)c1[i] = 1; else c2[i] = 1; } } else{ for(int i(x);i<n;i++){ if(c == 0)c1[i] = 1; else c2[i] = 1; } for(int i(0);i<=y;i++){ if(c == 0)c1[i] = 1; else c2[i] = 1; } } } bool check(){ for(int i(0); i < n;i++){ if(!c1[i] || !c2[i])return 0; } return 1; } main() { ios_base::sync_with_stdio(0); cin >> n >> m; vector<pair<int,int> > v; for(int i(0); i < m;i++){ int a,b; cin >> a >> b; v.push_back({a,b}); } for(int mask(0); mask < (1<<m);mask++){ clean(n); for(int j(0); j < m;j++){ if(mask&(1<<j))set_color(v[j].first,v[j].second,1); else set_color(v[j].first,v[j].second,0); } if(check()){ for(int j(0); j < m;j++){ if(mask&(1<<j))cout << 1; else cout << 0; } return 0; } } cout << "impossible"; return 0; } /* */

Compilation message (stderr)

alternating.cpp:43:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#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...