Submission #283756

#TimeUsernameProblemLanguageResultExecution timeMemory
2837562qbingxuanSimurgh (IOI17_simurgh)C++14
0 / 100
3076 ms256 KiB
#include "simurgh.h" #include <bits/stdc++.h> #ifdef local #define debug(...) QQBX(#__VA_ARGS__, __VA_ARGS__) void QQBX(const char *s) {} template <typename H, typename ...T> void QQBX(const char *s, const H&h, T &&...args) { for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s; std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n"); if(sizeof...(T)) QQBX(++s, args...); } #define safe std::cerr<<__PRETTY_FUNCTION<<" line "<<__LINE__<<" safe\n"; #else #define debug(...) ((void)0) #define safe ((void)0) #endif // local #define pb emplace_back using namespace std; const int N = 10025; int pa[N], rk[N]; int anc(int x) { return x==pa[x] ? x : pa[x]=anc(pa[x]); } bool join(int x, int y) { if((x=anc(x)) == (y=anc(y))) return false; if(rk[x] < rk[y]) swap(x, y); return pa[y] = x, rk[x]!=rk[y]||++rk[x]; } std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { auto ok = [&](vector<int> &ids) -> bool { assert(ids.size() == n-1); for(int i = 0; i < n; i++) pa[i] = i, rk[i] = 0; for(int x: ids) if(!join(u[x], v[x])) return false; return true; }; int m = u.size(); vector<int> r(m); iota(r.begin(), r.end(), 0); do { vector<int> q; for(int i = 0; i < n-1; i++) q.pb(r[i]); if(ok(q) && count_common_roads(q) == n-1) return q; } while(next_permutation(r.begin(), r.end())); }

Compilation message (stderr)

In file included from /usr/include/c++/9/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
                 from simurgh.cpp:3:
simurgh.cpp: In lambda function:
simurgh.cpp:31:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |         assert(ids.size() == n-1);
      |                ~~~~~~~~~~~^~~~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:37:20: warning: control reaches end of non-void function [-Wreturn-type]
   37 |     vector<int> r(m);
      |                    ^
#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...