Submission #951714

#TimeUsernameProblemLanguageResultExecution timeMemory
951714mochaAlternating Current (BOI18_alternating)C++14
0 / 100
20 ms2652 KiB
#include <bits/stdc++.h> using namespace std; const int mx = 1e5+5; int n, m; struct Edge { int fr, to; int id; } e[mx]; bool ans[mx]; bool cmp( Edge a, Edge b ) { return a.fr == b.fr ? a.to < b.to : a.fr < b.fr; } int main() { cin.tie(0);ios::sync_with_stdio(0); cin >> n >> m; for (int i=0;i<m;i++) { cin >> e[i].fr >> e[i].to; e[i].id = i; } set<pair<int, int>> st; st.insert({1,0}); st.insert({1,1}); sort(e, e+m, cmp); bool fl = 1; int now = 0; for (int i=0;i<n;i++) { auto [num, ty] = *st.begin(); if (e[i].fr > num) { fl = 0; } else { ans[e[i].id] = ty; st.erase(st.begin()); st.insert({e[i].to+1, ty}); } } for (auto [i,j]:st) fl = (fl and (i>n)); if (fl) { for (int i=0;i<m;i++) { cout << ans[i]; } cout << "\n"; } else { cout << "impossible\n"; } }

Compilation message (stderr)

alternating.cpp: In function 'int main()':
alternating.cpp:32:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   32 |   auto [num, ty] = *st.begin();
      |        ^
alternating.cpp:41:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   41 |  for (auto [i,j]:st) fl = (fl and (i>n));
      |            ^
alternating.cpp:30:6: warning: unused variable 'now' [-Wunused-variable]
   30 |  int now = 0;
      |      ^~~
#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...