Submission #498693

#TimeUsernameProblemLanguageResultExecution timeMemory
498693LittleCubeAlternating Current (BOI18_alternating)C++14
0 / 100
16 ms2144 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define F first #define S second using namespace std; ll N, M; vector<pii> v; signed main() { ios::sync_with_stdio(0), cin.tie(0); cin >> N >> M; for (int i = 1; i <= M; i++) { int a, b; cin >> a >> b; v.emplace_back(pii{a, b}); } if (N <= 15) { for (int mask = 0; mask < (1 << M); mask++) { bool valid[2] = {1, 1}; for (int i = 1; i <= N; i++) { bool exist[2] = {0, 0}; for (int j = 0; j < M; j++) { if ((v[j].F <= i && i <= v[j].S) || (v[j].F > v[j].S && !(v[j].S < i && i < v[j].F))) exist[(mask >> j) & 1] = 1; } valid[0] &= exist[0]; valid[1] &= exist[1]; } if (valid[0] && valid[1]) { for (int j = M - 1; j >= 0; j--) cout << ((mask >> j) & 1); cout << '\n'; return 0; } } cout << "impossible\n"; } else { } }
#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...