Submission #1075913

#TimeUsernameProblemLanguageResultExecution timeMemory
1075913NeroZeinSimurgh (IOI17_simurgh)C++17
13 / 100
558 ms604 KiB
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; vector<int> find_roads(int n, vector<int> eu, vector<int> ev) { int cc; vector<int> p(n), sz(n); function<int(int)> get = [&](int v) { return p[v] = (p[v] == v ? v : get(p[v])); }; auto unite = [&](int u, int v) { u = get(u); v = get(v); if (u == v) { return false; } if (sz[u] > sz[v]) { swap(u, v); } --cc; p[u] = v; sz[v] += sz[u]; return true; }; auto init_dsu = [&]() { cc = n; iota(p.begin(), p.end(), 0); fill(sz.begin(), sz.end(), 1); }; int m = (int) eu.size(); for (int i = 0; i < (1 << m); ++i) { init_dsu(); bool ok = true; vector<int> in_tree; for (int j = 0; j < m; ++j) { if (i >> j & 1) { in_tree.push_back(j); ok &= unite(eu[j], ev[j]); } } if (cc > 1 || !ok) { continue; } assert(in_tree.size() == n - 1); if (count_common_roads(in_tree) == n - 1) { return in_tree; } } assert(false); } //~ int common = count_common_roads(r);

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from simurgh.cpp:2:
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:48:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |   assert(in_tree.size() == n - 1);
      |          ~~~~~~~~~~~~~~~^~~~~~~~
#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...