Submission #441462

#TimeUsernameProblemLanguageResultExecution timeMemory
441462abc864197532Alternating Current (BOI18_alternating)C++17
13 / 100
3068 ms9060 KiB
#include <bits/stdc++.h> using namespace std; #define lli long long int #define X first #define Y second #define pb push_back #define eb emplace_back #define mp make_pair #define pii pair<int, int> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define test(args...) abc("[" + string(#args) + "]", args) void abc() {cerr << endl;} template <typename T, typename ...U> void abc(T a, U ...b) { cerr << a << ' ', abc(b...); } template <typename T> void printv(T l, T r) { while (l != r) cout << *l << " \n"[++l == r]; } const int mod = 1e9 + 7, N = 100000; int main () { srand(time(NULL)); ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector <pii> a(m); for (int i = 0; i < m; ++i) cin >> a[i].X >> a[i].Y, --a[i].X; double t = clock(); vector <int> p(m); iota(all(p), 0); while (clock() - t <= 2900) { random_shuffle(all(p)); vector <vector <bool>> is(n, vector <bool> (2, false)); vector <int> ans(m, 0); int now = 0; for (int i : p) { ans[i] = now; int l, r; tie(l, r) = a[i]; if (l < r) { for (int j = l; j < r; ++j) is[j][now] = true; } else { for (int j = l; j < n; ++j) is[j][now] = true; for (int j = 0; j < r; ++j) is[j][now] = true; } bool ok = true; for (int j = 0; j < n; ++j) ok &= is[j][now]; if (ok) { if (now == 1) { for (int i : ans) cout << i; cout << endl; return 0; } now++; } } } 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...