Submission #522400

#TimeUsernameProblemLanguageResultExecution timeMemory
522400LucaDantasAlternating Current (BOI18_alternating)C++17
19 / 100
43 ms3088 KiB
// subtask não circular #include <bits/stdc++.h> using namespace std; using pii = pair<int,int>; vector<pair<pii, int>> wires; int main() { int n, m; scanf("%d %d", &n, &m); for(int i = 0, a, b; i < m; i++) scanf("%d %d", &a, &b), wires.push_back({{a, b}, i}); sort(wires.begin(), wires.end()); vector<int> ans(m); int a = 1, b = 1, cor = 0; for(int i = 0; i < m; i++) { if(a > b) swap(a, b), cor ^= 1; if(wires[i].first.first > a) return puts("impossible"), 0; a = max(a, wires[i].first.second + 1); ans[wires[i].second] = cor; } if(min(a, b) < n+1) return puts("impossible"), 0; for(int i = 0; i < m; i++) printf("%d", ans[i]); puts(""); }

Compilation message (stderr)

alternating.cpp: In function 'int main()':
alternating.cpp:10:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  int n, m; scanf("%d %d", &n, &m);
      |            ~~~~~^~~~~~~~~~~~~~~~~
alternating.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d %d", &a, &b), wires.push_back({{a, b}, i});
      |   ~~~~~^~~~~~~~~~~~~~~~~
#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...