Submission #1036557

#TimeUsernameProblemLanguageResultExecution timeMemory
1036557Alihan_8Simurgh (IOI17_simurgh)C++17
13 / 100
129 ms2900 KiB
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define ar array #define pb push_back #define ln '\n' //#define int long long using i64 = long long; template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } struct Dsu{ vector <int> fa; int n; Dsu(int n) : n(n){ fa.resize(n); iota(all(fa), 0); } int get(int u){ return u ^ fa[u] ? fa[u] = get(fa[u]) : u; } bool merge(int u, int v){ u = get(u), v = get(v); if ( u == v ){ return false; } fa[u] = v; return true; } }; vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { int m = u.size(); vector <int> t(m, -1); for ( int i = 0; i < m; i++ ){ Dsu ds(n), tmp(n); ds.merge(u[i], v[i]); vector <int> is(m); is[i] = 1; vector <int> cur; for ( int j = 0; j < m; j++ ){ if ( t[j] == 0 || j == i ) continue; is[j] = ds.merge(u[j], v[j]); if ( is[j] > 0 ){ cur.pb(j); tmp.merge(u[j], v[j]); } } cur.pb(i); if ( cur.size() != n - 1 ){ t[i] = 0; continue; } int x = count_common_roads(cur); if ( x == n - 1 ){ return cur; } for ( int j = 0; j < m; j++ ){ if ( is[j] ) continue; auto q = tmp; if ( q.merge(u[j], v[j]) ){ cur.back() = j; int y = count_common_roads(cur); if ( x != y ){ t[i] = (x > y); break; } } } } vector <int> ret; for ( int i = 0; i < m; i++ ){ if ( t[i] > 0 ){ ret.pb(i); } } return ret; }

Compilation message (stderr)

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:91:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   91 |   if ( cur.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...