Submission #791038

#TimeUsernameProblemLanguageResultExecution timeMemory
791038fatemetmhrSimurgh (IOI17_simurgh)C++17
13 / 100
628 ms308 KiB
// ~ Be Name Khoda ~ // #include "simurgh.h" #include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC target("avx2") //#pragma GCC optimize("unroll-loops,Ofast") using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef long long ll; #define pb push_back #define mp make_pair #define all(x) x.begin(), x.end() #define fi first #define se second const int maxn = 1e6 + 10; const int maxn5 = 60; const int maxnt = 1.2e6 + 10; const int maxn3 = 1e3 + 10; const int mod = 1e9 + 7; const ll inf = 1e18; vector <int> adj[maxn5], av; int cnt = 0, par[maxn5], per[maxn]; bool mark[maxn5]; int get_par(int a){return par[a] == -1 ? a : par[a] = get_par(par[a]);} std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) { int m = u.size(); //cout << "ha? " << m << endl; for(int i = 0; i < m; i++){ //cout << i << ' ' << u[i] << ' ' << v[i] << endl; per[i] = i; } //cout << "*** " << endl; while(true){ shuffle(per, per + m, rng); memset(par, -1, sizeof par); av.clear(); for(int j = 0; j < m; j++){ int i = per[j]; int x = get_par(u[i]), y = get_par(v[i]); //cout << "here " << j << ' ' << i << ' ' << x << ' ' << y << endl; if(x == y) continue; av.pb(i); par[x] = y; } //cout << "another turn " << endl; if(count_common_roads(av) == n - 1) return av; } return av; }
#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...