Submission #1030654

# Submission time Handle Problem Language Result Execution time Memory
1030654 2024-07-22T08:11:52 Z vjudge1 Simurgh (IOI17_simurgh) C++17
51 / 100
108 ms 2616 KB
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rng(i,l,r) for(int i=(l); i<(r); i++)
#define all(x) x.begin(),x.end()
using ll=long long;
const int INF=INT_MAX>>1;
#include "simurgh.h"

struct UnionFind{
	int size;
	vector<int> uf;
	UnionFind(int sz):size(sz){
		uf.resize(sz,-1);
	}
	int leader(int x){
		if(uf[x]<0)return x;
		uf[x]=leader(uf[x]);
		return uf[x];
	}
	bool same(int x,int y){
		return leader(x)==leader(y);
	}
	bool merge(int x,int y){
		x=leader(x);
		y=leader(y);
		if(x==y)return false;
		if(-uf[x]>-uf[y])swap(x,y);
		uf[y]+=uf[x];
		uf[x]=y;
		return true;
	}
};
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
	vector<int> tree;
	int m=u.size();
	UnionFind uni(n);
	rep(i,m){
		if(uni.merge(u[i],v[i]))tree.emplace_back(i);
	}
	vector<int> ans;
	int def=count_common_roads(tree);
	vector<int> mark(m+1,0);
	rep(i,n-1){
		UnionFind uni(n);
		int bef=tree[i];
		rep(j,n-1){
			if(i!=j)uni.merge(u[tree[j]],v[tree[j]]);
		}
		vector<pair<int,int>> num={{def,bef}};
		bool checked=false;
		rep(j,m){
			if(j==bef)continue;
			if(!uni.same(u[j],v[j])){
				if(mark[j]!=0){
					if(checked)continue;
					checked=true;
				}
				tree[i]=j;
				num.emplace_back(count_common_roads(tree),j);
				if(mark[j]==-1)num.emplace_back(num.back().first+1,m);
				tree[i]=bef;
			}
		}
		sort(all(num));
		for(auto &[v,j]:num){
			//cout<<v<<" "<<j<<endl;
			if(v==num.back().first)mark[j]=1;
			else mark[j]=-1;
		}
	}
	rep(i,m){
		if(mark[i]==1)ans.emplace_back(i);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB correct
2 Correct 0 ms 348 KB correct
3 Correct 0 ms 348 KB correct
4 Correct 0 ms 348 KB correct
5 Correct 0 ms 348 KB correct
6 Correct 0 ms 348 KB correct
7 Correct 0 ms 348 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 0 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 0 ms 348 KB correct
13 Correct 1 ms 344 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB correct
2 Correct 0 ms 348 KB correct
3 Correct 0 ms 348 KB correct
4 Correct 0 ms 348 KB correct
5 Correct 0 ms 348 KB correct
6 Correct 0 ms 348 KB correct
7 Correct 0 ms 348 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 0 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 0 ms 348 KB correct
13 Correct 1 ms 344 KB correct
14 Correct 2 ms 344 KB correct
15 Correct 1 ms 348 KB correct
16 Correct 2 ms 348 KB correct
17 Correct 1 ms 352 KB correct
18 Correct 1 ms 348 KB correct
19 Correct 1 ms 344 KB correct
20 Correct 1 ms 468 KB correct
21 Correct 1 ms 344 KB correct
22 Correct 1 ms 348 KB correct
23 Correct 1 ms 348 KB correct
24 Correct 1 ms 348 KB correct
25 Correct 1 ms 348 KB correct
26 Correct 1 ms 348 KB correct
27 Correct 1 ms 348 KB correct
28 Correct 1 ms 348 KB correct
29 Correct 1 ms 348 KB correct
30 Correct 1 ms 348 KB correct
31 Correct 1 ms 348 KB correct
32 Correct 1 ms 348 KB correct
33 Correct 1 ms 348 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB correct
2 Correct 0 ms 348 KB correct
3 Correct 0 ms 348 KB correct
4 Correct 0 ms 348 KB correct
5 Correct 0 ms 348 KB correct
6 Correct 0 ms 348 KB correct
7 Correct 0 ms 348 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 0 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 0 ms 348 KB correct
13 Correct 1 ms 344 KB correct
14 Correct 2 ms 344 KB correct
15 Correct 1 ms 348 KB correct
16 Correct 2 ms 348 KB correct
17 Correct 1 ms 352 KB correct
18 Correct 1 ms 348 KB correct
19 Correct 1 ms 344 KB correct
20 Correct 1 ms 468 KB correct
21 Correct 1 ms 344 KB correct
22 Correct 1 ms 348 KB correct
23 Correct 1 ms 348 KB correct
24 Correct 1 ms 348 KB correct
25 Correct 1 ms 348 KB correct
26 Correct 1 ms 348 KB correct
27 Correct 1 ms 348 KB correct
28 Correct 1 ms 348 KB correct
29 Correct 1 ms 348 KB correct
30 Correct 1 ms 348 KB correct
31 Correct 1 ms 348 KB correct
32 Correct 1 ms 348 KB correct
33 Correct 1 ms 348 KB correct
34 Correct 107 ms 1116 KB correct
35 Correct 101 ms 1180 KB correct
36 Correct 67 ms 856 KB correct
37 Correct 5 ms 344 KB correct
38 Correct 108 ms 1300 KB correct
39 Correct 91 ms 1128 KB correct
40 Correct 65 ms 860 KB correct
41 Correct 100 ms 1204 KB correct
42 Correct 104 ms 1292 KB correct
43 Correct 56 ms 860 KB correct
44 Correct 44 ms 604 KB correct
45 Correct 50 ms 856 KB correct
46 Correct 35 ms 604 KB correct
47 Correct 18 ms 348 KB correct
48 Correct 3 ms 348 KB correct
49 Correct 5 ms 348 KB correct
50 Correct 15 ms 348 KB correct
51 Correct 47 ms 860 KB correct
52 Correct 41 ms 604 KB correct
53 Correct 36 ms 600 KB correct
54 Correct 55 ms 860 KB correct
55 Correct 55 ms 908 KB correct
56 Correct 61 ms 856 KB correct
57 Correct 50 ms 840 KB correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB correct
2 Correct 1 ms 348 KB correct
3 Incorrect 63 ms 2616 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB correct
2 Correct 0 ms 348 KB correct
3 Correct 0 ms 348 KB correct
4 Correct 0 ms 348 KB correct
5 Correct 0 ms 348 KB correct
6 Correct 0 ms 348 KB correct
7 Correct 0 ms 348 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 0 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 0 ms 348 KB correct
13 Correct 1 ms 344 KB correct
14 Correct 2 ms 344 KB correct
15 Correct 1 ms 348 KB correct
16 Correct 2 ms 348 KB correct
17 Correct 1 ms 352 KB correct
18 Correct 1 ms 348 KB correct
19 Correct 1 ms 344 KB correct
20 Correct 1 ms 468 KB correct
21 Correct 1 ms 344 KB correct
22 Correct 1 ms 348 KB correct
23 Correct 1 ms 348 KB correct
24 Correct 1 ms 348 KB correct
25 Correct 1 ms 348 KB correct
26 Correct 1 ms 348 KB correct
27 Correct 1 ms 348 KB correct
28 Correct 1 ms 348 KB correct
29 Correct 1 ms 348 KB correct
30 Correct 1 ms 348 KB correct
31 Correct 1 ms 348 KB correct
32 Correct 1 ms 348 KB correct
33 Correct 1 ms 348 KB correct
34 Correct 107 ms 1116 KB correct
35 Correct 101 ms 1180 KB correct
36 Correct 67 ms 856 KB correct
37 Correct 5 ms 344 KB correct
38 Correct 108 ms 1300 KB correct
39 Correct 91 ms 1128 KB correct
40 Correct 65 ms 860 KB correct
41 Correct 100 ms 1204 KB correct
42 Correct 104 ms 1292 KB correct
43 Correct 56 ms 860 KB correct
44 Correct 44 ms 604 KB correct
45 Correct 50 ms 856 KB correct
46 Correct 35 ms 604 KB correct
47 Correct 18 ms 348 KB correct
48 Correct 3 ms 348 KB correct
49 Correct 5 ms 348 KB correct
50 Correct 15 ms 348 KB correct
51 Correct 47 ms 860 KB correct
52 Correct 41 ms 604 KB correct
53 Correct 36 ms 600 KB correct
54 Correct 55 ms 860 KB correct
55 Correct 55 ms 908 KB correct
56 Correct 61 ms 856 KB correct
57 Correct 50 ms 840 KB correct
58 Correct 0 ms 348 KB correct
59 Correct 1 ms 348 KB correct
60 Incorrect 63 ms 2616 KB WA in grader: NO
61 Halted 0 ms 0 KB -