Submission #541643

#TimeUsernameProblemLanguageResultExecution timeMemory
541643skittles1412Alternating Current (BOI18_alternating)C++17
19 / 100
40 ms2768 KiB
#include "bits/extc++.h" using namespace std; template <typename T> void dbgh(const T& t) { cerr << t << endl; } template <typename T, typename... U> void dbgh(const T& t, const U&... u) { cerr << t << " | "; dbgh(u...); } #ifdef DEBUG #define dbg(...) \ cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]" \ << ": "; \ dbgh(__VA_ARGS__) #else #define cerr \ if (false) \ cerr #define dbg(...) #endif #define endl "\n" #define long int64_t #define sz(x) int((x).size()) void solve() { int n, m; cin >> n >> m; array<int, 3> arr[m]; for (int i = 0; i < m; i++) { cin >> arr[i][0] >> arr[i][1]; arr[i][2] = i; } sort(arr, arr + m); int c1 = 1, c2 = 1; bool ans[m]; for (auto& [l, r, i] : arr) { dbg(c1, c2); if (l <= c1 && l <= c2) { if (c1 > c2) { c2 = max(c2, r + 1); ans[i] = true; } else { c1 = max(c1, r + 1); ans[i] = false; } } else if (l <= c1) { c1 = max(c1, r + 1); ans[i] = false; } else if (l <= c2) { c2 = max(c2, r + 1); ans[i] = true; } } dbg(c1, c2); if (c1 > n && c2 > n) { for (auto& a : ans) { cout << a; } cout << endl; } else { cout << "impossible" << endl; } } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cin.exceptions(ios::failbit); solve(); }
#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...