Submission #797475

# Submission time Handle Problem Language Result Execution time Memory
797475 2023-07-29T12:40:42 Z firewater Simurgh (IOI17_simurgh) C++14
51 / 100
132 ms 2552 KB
#include "simurgh.h"

#include <cstdio>
#include <cassert>
#include <vector>
#include <cstdlib>
#include <string>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;






#define N 1001000
#define mp make_pair
#define fs first
#define sn second
int n,m,x,y,mx,w,xx,yy,sav,fa[N],p[N];
pair<int,int>a[N],l[N];
vector<int>ans;
int find(int x)
{
	return (fa[x]==x?x:fa[x]=find(fa[x]));
}
std::vector<int> find_roads(int nn, std::vector<int> u, std::vector<int> v) {
	n=nn;
	m=u.size();
	for(int i=1;i<=m;++i)
		l[i]=mp(u[i-1]+1,v[i-1]+1);
	for(int k=1;k<=m;++k){
		if(p[k])continue;
		for(int i=1;i<=n;++i)
			fa[i]=i;
		ans.clear();
		ans.push_back(0);
		xx=l[k].fs;
		yy=l[k].sn;
		// printf("%d:--------------\n",k);
		for(int i=1;i<=m;++i){
			x=find(l[i].fs);
			y=find(l[i].sn);
			// printf("%d %d\n",x,y);
			xx=find(xx);
			yy=find(yy);
			if(x!=y){
				if((x==xx&&y==yy)||(x==yy&&y==xx))continue;
				fa[x]=y;
				ans.push_back(i-1);
			}
		}
		mx=0;
		w=0;
		xx=find(xx);
		yy=find(yy);
		sav=0;
		for(int i=1;i<=m;++i){
			x=find(l[i].fs);
			y=find(l[i].sn);
			if((x==xx&&y==yy)||(x==yy&&y==xx)){
				if(p[i]&&sav)continue;
				ans[0]=i-1;
				a[++w]=mp(i,count_common_roads(ans));
				mx=max(mx,a[w].sn);
				if(p[i])sav=w;
			}
		}
		if(sav)mx=a[sav].sn+2-p[a[sav].fs];
		for(int i=1;i<=w;++i)
			p[a[i].fs]=a[i].sn+2-mx;
	}
	ans.clear();
	for(int i=1;i<=m;++i)
		if(p[i]==2)ans.push_back(i-1);
	return ans;
}






# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB correct
2 Correct 0 ms 212 KB correct
3 Correct 0 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 0 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 1 ms 212 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB correct
2 Correct 0 ms 212 KB correct
3 Correct 0 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 0 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 1 ms 212 KB correct
14 Correct 2 ms 340 KB correct
15 Correct 2 ms 312 KB correct
16 Correct 2 ms 340 KB correct
17 Correct 2 ms 340 KB correct
18 Correct 1 ms 340 KB correct
19 Correct 2 ms 340 KB correct
20 Correct 2 ms 356 KB correct
21 Correct 2 ms 340 KB correct
22 Correct 1 ms 312 KB correct
23 Correct 1 ms 340 KB correct
24 Correct 1 ms 340 KB correct
25 Correct 1 ms 212 KB correct
26 Correct 1 ms 340 KB correct
27 Correct 1 ms 340 KB correct
28 Correct 1 ms 212 KB correct
29 Correct 1 ms 340 KB correct
30 Correct 1 ms 340 KB correct
31 Correct 1 ms 340 KB correct
32 Correct 1 ms 304 KB correct
33 Correct 1 ms 340 KB correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB correct
2 Correct 0 ms 212 KB correct
3 Correct 0 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 0 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 1 ms 212 KB correct
14 Correct 2 ms 340 KB correct
15 Correct 2 ms 312 KB correct
16 Correct 2 ms 340 KB correct
17 Correct 2 ms 340 KB correct
18 Correct 1 ms 340 KB correct
19 Correct 2 ms 340 KB correct
20 Correct 2 ms 356 KB correct
21 Correct 2 ms 340 KB correct
22 Correct 1 ms 312 KB correct
23 Correct 1 ms 340 KB correct
24 Correct 1 ms 340 KB correct
25 Correct 1 ms 212 KB correct
26 Correct 1 ms 340 KB correct
27 Correct 1 ms 340 KB correct
28 Correct 1 ms 212 KB correct
29 Correct 1 ms 340 KB correct
30 Correct 1 ms 340 KB correct
31 Correct 1 ms 340 KB correct
32 Correct 1 ms 304 KB correct
33 Correct 1 ms 340 KB correct
34 Correct 130 ms 1348 KB correct
35 Correct 129 ms 1360 KB correct
36 Correct 86 ms 1012 KB correct
37 Correct 8 ms 376 KB correct
38 Correct 131 ms 1360 KB correct
39 Correct 113 ms 1204 KB correct
40 Correct 87 ms 1012 KB correct
41 Correct 132 ms 1376 KB correct
42 Correct 127 ms 1340 KB correct
43 Correct 66 ms 852 KB correct
44 Correct 53 ms 776 KB correct
45 Correct 70 ms 832 KB correct
46 Correct 47 ms 684 KB correct
47 Correct 21 ms 468 KB correct
48 Correct 3 ms 308 KB correct
49 Correct 7 ms 340 KB correct
50 Correct 21 ms 468 KB correct
51 Correct 62 ms 832 KB correct
52 Correct 56 ms 748 KB correct
53 Correct 49 ms 692 KB correct
54 Correct 66 ms 868 KB correct
55 Correct 62 ms 848 KB correct
56 Correct 61 ms 724 KB correct
57 Correct 60 ms 836 KB correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB correct
2 Correct 0 ms 212 KB correct
3 Incorrect 61 ms 2552 KB WA in grader: NO
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB correct
2 Correct 0 ms 212 KB correct
3 Correct 0 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 0 ms 212 KB correct
11 Correct 0 ms 212 KB correct
12 Correct 0 ms 212 KB correct
13 Correct 1 ms 212 KB correct
14 Correct 2 ms 340 KB correct
15 Correct 2 ms 312 KB correct
16 Correct 2 ms 340 KB correct
17 Correct 2 ms 340 KB correct
18 Correct 1 ms 340 KB correct
19 Correct 2 ms 340 KB correct
20 Correct 2 ms 356 KB correct
21 Correct 2 ms 340 KB correct
22 Correct 1 ms 312 KB correct
23 Correct 1 ms 340 KB correct
24 Correct 1 ms 340 KB correct
25 Correct 1 ms 212 KB correct
26 Correct 1 ms 340 KB correct
27 Correct 1 ms 340 KB correct
28 Correct 1 ms 212 KB correct
29 Correct 1 ms 340 KB correct
30 Correct 1 ms 340 KB correct
31 Correct 1 ms 340 KB correct
32 Correct 1 ms 304 KB correct
33 Correct 1 ms 340 KB correct
34 Correct 130 ms 1348 KB correct
35 Correct 129 ms 1360 KB correct
36 Correct 86 ms 1012 KB correct
37 Correct 8 ms 376 KB correct
38 Correct 131 ms 1360 KB correct
39 Correct 113 ms 1204 KB correct
40 Correct 87 ms 1012 KB correct
41 Correct 132 ms 1376 KB correct
42 Correct 127 ms 1340 KB correct
43 Correct 66 ms 852 KB correct
44 Correct 53 ms 776 KB correct
45 Correct 70 ms 832 KB correct
46 Correct 47 ms 684 KB correct
47 Correct 21 ms 468 KB correct
48 Correct 3 ms 308 KB correct
49 Correct 7 ms 340 KB correct
50 Correct 21 ms 468 KB correct
51 Correct 62 ms 832 KB correct
52 Correct 56 ms 748 KB correct
53 Correct 49 ms 692 KB correct
54 Correct 66 ms 868 KB correct
55 Correct 62 ms 848 KB correct
56 Correct 61 ms 724 KB correct
57 Correct 60 ms 836 KB correct
58 Correct 0 ms 212 KB correct
59 Correct 0 ms 212 KB correct
60 Incorrect 61 ms 2552 KB WA in grader: NO
61 Halted 0 ms 0 KB -