Submission #420817

#TimeUsernameProblemLanguageResultExecution timeMemory
420817QCFiumSplit the Attractions (IOI19_split)C++14
11 / 100
130 ms12616 KiB
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } static std::vector<std::vector<int> > hen; std::vector<int> find_split(int n, int a, int b, int c, std::vector<int> p, std::vector<int> q) { hen.resize(n); for (int i = 0; i < (int) p.size(); i++) { hen[p[i]].push_back(q[i]); hen[q[i]].push_back(p[i]); } std::vector<int> res(n, -1); if (a == 1) { std::vector<bool> visited(n); std::queue<int> que; que.push(0); visited[0] = true; std::vector<int> group2; while (que.size()) { auto i = que.front(); que.pop(); group2.push_back(i); if ((int) group2.size() == b) break; for (auto j : hen[i]) if (!visited[j]) visited[j] = true, que.push(j); } for (auto i : group2) res[i] = 2; *std::find(res.begin(), res.end(), -1) = 1; for (auto &i : res) if (i == -1) i = 3; } else assert(0); return res; } #ifdef LOCAL int main() { int n = ri(); int m = ri(); int a = ri(); int b = ri(); int c = ri(); std::vector<int> p(m); std::vector<int> q(m); for (int i = 0; i < m; i++) { p[i] = ri(); q[i] = ri(); } auto res = find_split(n, a, b, c, p, q); for (auto i : res) std::cerr << i << " "; std::cerr << std::endl; return 0; } #endif

Compilation message (stderr)

split.cpp: In function 'int ri()':
split.cpp:5:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |  scanf("%d", &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...