Submission #924083

#TimeUsernameProblemLanguageResultExecution timeMemory
924083heavylightdecompAlternating Current (BOI18_alternating)C++14
13 / 100
3043 ms3520 KiB
#include<bits/stdc++.h> using namespace std; #define X first #define Y second using pii = pair<int,int>; #define vt vector #define pb push_back #define f0r(i,a,b) for(auto i =(a);i!=(b);i++) #define r0f(i,a,b) for(auto i=(a);i>=(b);i--) #define all(x) (x).begin(), (x).end() #define sz(x) ((int)(x).size()) //sim dor ris enix rge range dud debug 2enix 2dor imie #define sim template<class c #define dor > debug& operator<< #define ris return *this #define eni(x) sim> typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) sim> struct rge { c b,e; }; sim> rge<c> range(c i, c j) { return rge<c>{i,j}; } sim> auto dud(c* x) -> decltype(cout << *x, 0); sim> char dud(...); struct debug { ~debug() { cerr << endl; } eni(!=) { cerr << boolalpha << i; ris; } eni(==) { ris << range(all(i)); } sim, class b dor(pair<b,c> d) { ris << "(" << d.X << ", " << d.Y << ")"; } sim dor(rge<c> d) { *this << "{"; f0r(i,d.b,d.e) *this << ", " + 2*(i==d.b) << *i; ris << "}"; } }; #define imie(r...) " [" << #r << ": " << (r) << "] " signed main() { cin.tie(0)->sync_with_stdio(0); //try every subset //M is number of ranges //N is L int L,N; cin >> L >> N; vt<pii> ro (N); f0r(i,0,N) cin >> ro[i].X >> ro[i].Y, ro[i].X--, ro[i].Y--; f0r(msk,0,(1<<N)) { vt<int> as (L), bs(L); auto mark = [L](vt<int> &a, int l, int r) { if(r < l) { f0r(i,l,L) a[i] = 1; f0r(i,0,r+1) a[i] = 1; } else { f0r(i,l,r+1) a[i] = 1; } }; string res; f0r(g,0,N) { res += (msk & (1 << g)) ? '1' : '0'; mark((msk & (1<<g)) ? as : bs, ro[g].X, ro[g].Y); } bool ok = 1; f0r(i,0,L) if(not as[i] or not bs[i]) ok = 0; if(ok) { cout << res << '\n'; exit(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...