Submission #302142

# Submission time Handle Problem Language Result Execution time Memory
302142 2020-09-18T13:29:58 Z TMJN Simurgh (IOI17_simurgh) C++17
51 / 100
356 ms 1792 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;

int N,M,T[500],tmpval[30000];
bool B[30000],checked[30000];
vector<int>res,tree;

static int par(int x){
	if(T[x]==x)return x;
	return T[x]=par(T[x]);
}

static bool uni(int x,int y){
	x=par(x);
	y=par(y);
	if(x==y)return false;
	T[x]=y;
	return true;
}

vector<int>find_roads(int n,vector<int>u,vector<int>v){
	N=n;
	M=u.size();
	res.clear();
	tree.clear();
	for(int i=0;i<N;i++){
		T[i]=i;
	}
	for(int i=0;i<M;i++){
		if(uni(u[i],v[i])){
			tree.push_back(i);
		}
		B[i]=checked[i]=false;
		tmpval[i]=0;
	}
	int tmp=count_common_roads(tree);
	for(int i:tree){
		tmpval[i]=tmp;
	}
	for(int i:tree){
		for(int j=0;j<N;j++){
			T[j]=j;
		}
		vector<int>K;
		for(int j:tree){
			if(i==j)continue;
			uni(u[j],v[j]);
			K.push_back(j);
		}
		K.push_back(-1);
		int t=-1;
		for(int j=0;j<M;j++){
			if(i==j)continue;
			if(par(u[j])!=par(v[j])){
				if(checked[j]){
					if(B[j]){
						t=j;
					}
				}
				else{
					K.back()=j;
					tmpval[j]=count_common_roads(K);
				}
			}
		}
		if(t==-1){
			int mx=0;
			for(int j=0;j<M;j++){
				if(par(u[j])!=par(v[j])&&!checked[j]){
					mx=max(mx,tmpval[j]);
				}
			}
			for(int j=0;j<M;j++){
				if(par(u[j])!=par(v[j])&&!checked[j]){
					if(tmpval[j]==mx){
						B[j]=true;
					}
					checked[j]=true;
				}
			}
		}
		else{
			K.back()=t;
			int hoge=count_common_roads(K);
			for(int j=0;j<M;j++){
				if(par(u[j])!=par(v[j])&&!checked[j]){
					if(tmpval[j]==hoge){
						B[j]=true;
					}
					checked[j]=true;
				}
			}
		}
	}
	for(int i=0;i<M;i++){
		if(B[i])res.push_back(i);
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB correct
2 Correct 1 ms 384 KB correct
3 Correct 1 ms 384 KB correct
4 Correct 1 ms 512 KB correct
5 Correct 1 ms 384 KB correct
6 Correct 1 ms 384 KB correct
7 Correct 1 ms 512 KB correct
8 Correct 1 ms 256 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 1 ms 384 KB correct
11 Correct 1 ms 384 KB correct
12 Correct 1 ms 384 KB correct
13 Correct 1 ms 384 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB correct
2 Correct 1 ms 384 KB correct
3 Correct 1 ms 384 KB correct
4 Correct 1 ms 512 KB correct
5 Correct 1 ms 384 KB correct
6 Correct 1 ms 384 KB correct
7 Correct 1 ms 512 KB correct
8 Correct 1 ms 256 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 1 ms 384 KB correct
11 Correct 1 ms 384 KB correct
12 Correct 1 ms 384 KB correct
13 Correct 1 ms 384 KB correct
14 Correct 4 ms 512 KB correct
15 Correct 4 ms 384 KB correct
16 Correct 4 ms 384 KB correct
17 Correct 3 ms 384 KB correct
18 Correct 2 ms 384 KB correct
19 Correct 4 ms 384 KB correct
20 Correct 3 ms 384 KB correct
21 Correct 3 ms 384 KB correct
22 Correct 3 ms 384 KB correct
23 Correct 3 ms 384 KB correct
24 Correct 3 ms 384 KB correct
25 Correct 1 ms 512 KB correct
26 Correct 3 ms 384 KB correct
27 Correct 3 ms 384 KB correct
28 Correct 1 ms 384 KB correct
29 Correct 1 ms 384 KB correct
30 Correct 3 ms 384 KB correct
31 Correct 3 ms 384 KB correct
32 Correct 3 ms 384 KB correct
33 Correct 3 ms 384 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB correct
2 Correct 1 ms 384 KB correct
3 Correct 1 ms 384 KB correct
4 Correct 1 ms 512 KB correct
5 Correct 1 ms 384 KB correct
6 Correct 1 ms 384 KB correct
7 Correct 1 ms 512 KB correct
8 Correct 1 ms 256 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 1 ms 384 KB correct
11 Correct 1 ms 384 KB correct
12 Correct 1 ms 384 KB correct
13 Correct 1 ms 384 KB correct
14 Correct 4 ms 512 KB correct
15 Correct 4 ms 384 KB correct
16 Correct 4 ms 384 KB correct
17 Correct 3 ms 384 KB correct
18 Correct 2 ms 384 KB correct
19 Correct 4 ms 384 KB correct
20 Correct 3 ms 384 KB correct
21 Correct 3 ms 384 KB correct
22 Correct 3 ms 384 KB correct
23 Correct 3 ms 384 KB correct
24 Correct 3 ms 384 KB correct
25 Correct 1 ms 512 KB correct
26 Correct 3 ms 384 KB correct
27 Correct 3 ms 384 KB correct
28 Correct 1 ms 384 KB correct
29 Correct 1 ms 384 KB correct
30 Correct 3 ms 384 KB correct
31 Correct 3 ms 384 KB correct
32 Correct 3 ms 384 KB correct
33 Correct 3 ms 384 KB correct
34 Correct 344 ms 1272 KB correct
35 Correct 342 ms 1272 KB correct
36 Correct 235 ms 1024 KB correct
37 Correct 17 ms 384 KB correct
38 Correct 342 ms 1272 KB correct
39 Correct 306 ms 1144 KB correct
40 Correct 233 ms 1016 KB correct
41 Correct 343 ms 1320 KB correct
42 Correct 356 ms 1152 KB correct
43 Correct 211 ms 888 KB correct
44 Correct 173 ms 760 KB correct
45 Correct 209 ms 768 KB correct
46 Correct 153 ms 680 KB correct
47 Correct 66 ms 512 KB correct
48 Correct 7 ms 384 KB correct
49 Correct 19 ms 384 KB correct
50 Correct 67 ms 512 KB correct
51 Correct 208 ms 768 KB correct
52 Correct 180 ms 640 KB correct
53 Correct 153 ms 640 KB correct
54 Correct 221 ms 768 KB correct
55 Correct 193 ms 768 KB correct
56 Correct 192 ms 768 KB correct
57 Correct 193 ms 892 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB correct
2 Correct 1 ms 384 KB correct
3 Incorrect 19 ms 1792 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB correct
2 Correct 1 ms 384 KB correct
3 Correct 1 ms 384 KB correct
4 Correct 1 ms 512 KB correct
5 Correct 1 ms 384 KB correct
6 Correct 1 ms 384 KB correct
7 Correct 1 ms 512 KB correct
8 Correct 1 ms 256 KB correct
9 Correct 1 ms 384 KB correct
10 Correct 1 ms 384 KB correct
11 Correct 1 ms 384 KB correct
12 Correct 1 ms 384 KB correct
13 Correct 1 ms 384 KB correct
14 Correct 4 ms 512 KB correct
15 Correct 4 ms 384 KB correct
16 Correct 4 ms 384 KB correct
17 Correct 3 ms 384 KB correct
18 Correct 2 ms 384 KB correct
19 Correct 4 ms 384 KB correct
20 Correct 3 ms 384 KB correct
21 Correct 3 ms 384 KB correct
22 Correct 3 ms 384 KB correct
23 Correct 3 ms 384 KB correct
24 Correct 3 ms 384 KB correct
25 Correct 1 ms 512 KB correct
26 Correct 3 ms 384 KB correct
27 Correct 3 ms 384 KB correct
28 Correct 1 ms 384 KB correct
29 Correct 1 ms 384 KB correct
30 Correct 3 ms 384 KB correct
31 Correct 3 ms 384 KB correct
32 Correct 3 ms 384 KB correct
33 Correct 3 ms 384 KB correct
34 Correct 344 ms 1272 KB correct
35 Correct 342 ms 1272 KB correct
36 Correct 235 ms 1024 KB correct
37 Correct 17 ms 384 KB correct
38 Correct 342 ms 1272 KB correct
39 Correct 306 ms 1144 KB correct
40 Correct 233 ms 1016 KB correct
41 Correct 343 ms 1320 KB correct
42 Correct 356 ms 1152 KB correct
43 Correct 211 ms 888 KB correct
44 Correct 173 ms 760 KB correct
45 Correct 209 ms 768 KB correct
46 Correct 153 ms 680 KB correct
47 Correct 66 ms 512 KB correct
48 Correct 7 ms 384 KB correct
49 Correct 19 ms 384 KB correct
50 Correct 67 ms 512 KB correct
51 Correct 208 ms 768 KB correct
52 Correct 180 ms 640 KB correct
53 Correct 153 ms 640 KB correct
54 Correct 221 ms 768 KB correct
55 Correct 193 ms 768 KB correct
56 Correct 192 ms 768 KB correct
57 Correct 193 ms 892 KB correct
58 Correct 1 ms 384 KB correct
59 Correct 1 ms 384 KB correct
60 Incorrect 19 ms 1792 KB WA in grader: NO
61 Halted 0 ms 0 KB -