답안 #756182

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756182 2023-06-11T09:21:16 Z Trumling 슈퍼트리 잇기 (IOI20_supertrees) C++14
40 / 100
235 ms 26172 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()

vector<bool>vis(1000,0);
vector<bool>vis2(1000,0);

vector<vector<int>>g;
vector<vector<int>>ans;
ll nn;
bool dfs1(int start,int beg)
{
	vis[start]=1;
	for(int i=0;i<nn;i++)
		if(g[start][i]!=g[beg][i] && i!=start && i!=beg)
			return 0;

	for(int i=0;i<nn;i++)
		if(!vis[i] && g[start][i]==1)
		{
			ans[i][start]=1;
			ans[start][i]=1;
			return dfs1(i,beg);
		}
	if(start==beg)
	vis[start]=0;

	return 1;
}

bool dfs2(int start,int beg)
{
	vis[start]=1;

	for(int i=0;i<nn;i++)
		if(g[start][i]!=g[beg][i] && i!=start && i!=beg)
			return 0;
		
		

	ll count=0;
	for(int i=0;i<nn;i++)
		if(g[start][i]==2)
		count++;
	
	if(count==1)
	return 0;

	for(int i=0;i<nn;i++)
		if(!vis[i] && g[start][i]==2)
		{
			ans[i][start]=1;
			ans[start][i]=1;

			return dfs2(i,beg);
		}
	ans[start][beg]=1;
	ans[beg][start]=1;
	return 1;
}

int construct(vector<vector<int>> pr) 
{
	nn=pr.size();
	g=pr;

	ans.assign(nn,vector<int>(nn,0));

	for(int i=0;i<nn;i++)
	{
		bool now=dfs1(i,i);
		if(!now)
		return 0;
	}

	for(int i=0;i<nn;i++)
	{
		bool now=dfs2(i,i);
		if(!now)
		return 0;
	}

	for(int i=0;i<nn;i++)
	ans[i][i]=0;

	build(ans);
	return 1;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 8 ms 1340 KB Output is correct
7 Correct 176 ms 26004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 8 ms 1340 KB Output is correct
7 Correct 176 ms 26004 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1236 KB Output is correct
13 Correct 183 ms 26060 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 77 ms 16004 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 46 ms 6756 KB Output is correct
21 Correct 174 ms 25932 KB Output is correct
22 Correct 180 ms 25904 KB Output is correct
23 Correct 215 ms 26128 KB Output is correct
24 Correct 173 ms 25932 KB Output is correct
25 Correct 71 ms 16004 KB Output is correct
26 Correct 69 ms 16008 KB Output is correct
27 Correct 178 ms 25984 KB Output is correct
28 Correct 198 ms 26172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 7 ms 1308 KB Output is correct
9 Correct 186 ms 25984 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1356 KB Output is correct
13 Correct 169 ms 25884 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 82 ms 16000 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 43 ms 6664 KB Output is correct
22 Correct 177 ms 25900 KB Output is correct
23 Correct 199 ms 25984 KB Output is correct
24 Correct 200 ms 25876 KB Output is correct
25 Correct 79 ms 16056 KB Output is correct
26 Correct 80 ms 16000 KB Output is correct
27 Correct 189 ms 25892 KB Output is correct
28 Correct 178 ms 25984 KB Output is correct
29 Correct 69 ms 16076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 51 ms 6696 KB Output is correct
5 Correct 235 ms 25988 KB Output is correct
6 Correct 173 ms 26060 KB Output is correct
7 Correct 178 ms 26004 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 46 ms 6696 KB Output is correct
10 Correct 196 ms 25988 KB Output is correct
11 Correct 170 ms 25932 KB Output is correct
12 Correct 183 ms 25988 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 8 ms 1340 KB Output is correct
7 Correct 176 ms 26004 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1236 KB Output is correct
13 Correct 183 ms 26060 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 77 ms 16004 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 46 ms 6756 KB Output is correct
21 Correct 174 ms 25932 KB Output is correct
22 Correct 180 ms 25904 KB Output is correct
23 Correct 215 ms 26128 KB Output is correct
24 Correct 173 ms 25932 KB Output is correct
25 Correct 71 ms 16004 KB Output is correct
26 Correct 69 ms 16008 KB Output is correct
27 Correct 178 ms 25984 KB Output is correct
28 Correct 198 ms 26172 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 7 ms 1308 KB Output is correct
37 Correct 186 ms 25984 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 7 ms 1356 KB Output is correct
41 Correct 169 ms 25884 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 4 ms 852 KB Output is correct
45 Correct 82 ms 16000 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 43 ms 6664 KB Output is correct
50 Correct 177 ms 25900 KB Output is correct
51 Correct 199 ms 25984 KB Output is correct
52 Correct 200 ms 25876 KB Output is correct
53 Correct 79 ms 16056 KB Output is correct
54 Correct 80 ms 16000 KB Output is correct
55 Correct 189 ms 25892 KB Output is correct
56 Correct 178 ms 25984 KB Output is correct
57 Correct 69 ms 16076 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 6 ms 852 KB Output is correct
61 Correct 82 ms 16004 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 0 ms 212 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Incorrect 25 ms 4228 KB Answer gives possible 0 while actual possible 1
66 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 8 ms 1340 KB Output is correct
7 Correct 176 ms 26004 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 8 ms 1236 KB Output is correct
13 Correct 183 ms 26060 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 77 ms 16004 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 46 ms 6756 KB Output is correct
21 Correct 174 ms 25932 KB Output is correct
22 Correct 180 ms 25904 KB Output is correct
23 Correct 215 ms 26128 KB Output is correct
24 Correct 173 ms 25932 KB Output is correct
25 Correct 71 ms 16004 KB Output is correct
26 Correct 69 ms 16008 KB Output is correct
27 Correct 178 ms 25984 KB Output is correct
28 Correct 198 ms 26172 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 7 ms 1308 KB Output is correct
37 Correct 186 ms 25984 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 7 ms 1356 KB Output is correct
41 Correct 169 ms 25884 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 4 ms 852 KB Output is correct
45 Correct 82 ms 16000 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 43 ms 6664 KB Output is correct
50 Correct 177 ms 25900 KB Output is correct
51 Correct 199 ms 25984 KB Output is correct
52 Correct 200 ms 25876 KB Output is correct
53 Correct 79 ms 16056 KB Output is correct
54 Correct 80 ms 16000 KB Output is correct
55 Correct 189 ms 25892 KB Output is correct
56 Correct 178 ms 25984 KB Output is correct
57 Correct 69 ms 16076 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 51 ms 6696 KB Output is correct
62 Correct 235 ms 25988 KB Output is correct
63 Correct 173 ms 26060 KB Output is correct
64 Correct 178 ms 26004 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 46 ms 6696 KB Output is correct
67 Correct 196 ms 25988 KB Output is correct
68 Correct 170 ms 25932 KB Output is correct
69 Correct 183 ms 25988 KB Output is correct
70 Correct 0 ms 212 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
73 Halted 0 ms 0 KB -