Submission #791038

# Submission time Handle Problem Language Result Execution time Memory
791038 2023-07-23T11:09:42 Z fatemetmhr Simurgh (IOI17_simurgh) C++17
13 / 100
628 ms 308 KB
//  ~ 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 time Memory Grader output
1 Correct 2 ms 212 KB correct
2 Correct 4 ms 212 KB correct
3 Correct 1 ms 212 KB correct
4 Correct 0 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 0 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 1 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 11 ms 212 KB correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB correct
2 Correct 4 ms 212 KB correct
3 Correct 1 ms 212 KB correct
4 Correct 0 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 0 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 1 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 11 ms 212 KB correct
14 Incorrect 628 ms 308 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB correct
2 Correct 4 ms 212 KB correct
3 Correct 1 ms 212 KB correct
4 Correct 0 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 0 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 1 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 11 ms 212 KB correct
14 Incorrect 628 ms 308 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB correct
2 Incorrect 14 ms 308 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB correct
2 Correct 4 ms 212 KB correct
3 Correct 1 ms 212 KB correct
4 Correct 0 ms 212 KB correct
5 Correct 0 ms 212 KB correct
6 Correct 0 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 0 ms 212 KB correct
9 Correct 0 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 1 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 11 ms 212 KB correct
14 Incorrect 628 ms 308 KB WA in grader: NO
15 Halted 0 ms 0 KB -