답안 #300356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300356 2020-09-17T05:49:04 Z faustaadp 슈퍼트리 잇기 (IOI20_supertrees) C++17
40 / 100
266 ms 26232 KB
#include "supertrees.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll NN = 1e3 + 5;
ll n, bisa = 1, p[NN], x[NN];
std::vector<std::vector<int>> answer;
vector<ll> v[NN];
std::vector<std::vector<int>> px;
ll car(ll pos)
{
	if(p[pos] == pos)
		return pos;
	else
		return p[pos] = car(p[pos]);
}
int construct(std::vector<std::vector<int>> pt) {
	px = pt;
	n = px.size();
	for (int i = 0; i < n; i++) {
		std::vector<int> row;
		row.resize(n, 0);
		answer.push_back(row);
	}
	for (int i = 0; i < n; i++) 
		p[i] = i;
	for (int i = 0; i < n; i++) 
		for (int j = i + 1; j < n; j++) 
			if(px[i][j])
				p[car(i)] = car(j); 
	for (int i = 0; i < n; i++) 
		v[car(i)].pb(i);
	for (int i = 0; i < n; i++) 
	{
		if(!bisa)
			break;
		ll sz = v[i].size();
		x[0] = 0;
		x[1] = 0;
		x[2] = 0;
		x[3] = 0;
		for(ll j = 0; j < sz; j++)
			for(ll k = j + 1; k < sz; k++)
				x[px[v[i][j]][v[i][k]]] = 1;
		if(x[0] + x[1] + x[2] + x[3] == 0) 
			continue;
		else
		if(x[0])
			bisa = 0;
		else
		if(x[2] == 1 && x[3] == 1)
			bisa = 0;
		else
		if(x[1] == 1 && x[2] == 0 && x[3] == 0)
		{
			for(ll j = 1; j < sz; j++)
			{
				answer[v[i][j - 1]][v[i][j]] = 1;
				answer[v[i][j]][v[i][j - 1]] = 1;
			}
		}
		else
		if(x[2] == 1 && x[1] == 0)
		{
			if(sz <= 2)
				bisa = 0;
			else
			{
				for(ll j = 0; j < sz; j++)
				{
					answer[v[i][j]][v[i][(j + 1) % sz]] = 1;
					answer[v[i][(j + 1) % sz]][v[i][j]] = 1;
				}
			}
		}
		else
		if(x[3] == 1 && x[1] == 0)
		{
			if(sz <= 3)
				bisa = 0;
			else
			{
				for(ll j = 0; j < sz; j++)
				{
					answer[v[i][j]][v[i][(j + 1) % sz]] = 1;
					answer[v[i][(j + 1) % sz]][v[i][j]] = 1;
				}
				answer[v[i][1]][v[i][sz - 1]] = 1;
				answer[v[i][sz - 1]][v[i][1]] = 1;
			}
		}
		else
		if(x[2] == 1 && x[1] == 1)
		{
			vector<ll> sat, dua;
			for(ll j = 0; j < sz; j++)
			{
				ll mi = 4;
				for(ll k = 0; k < sz; k++)
				{
					if(j == k)
						continue;
					mi = min(mi, (ll)px[v[i][j]][v[i][k]]);
				}
				if(mi == 2)
					dua.pb(j);
				else
					sat.pb(j);
			}
			ll ss = sat.size();
			ll sd = dua.size();
			// cout << ss << " " << sd << "_\n";
			for(ll j = 1; j < ss; j++)
			{
				answer[sat[j - 1]][sat[j]] = 1;
				answer[sat[j]][sat[j - 1]] = 1;
			}
			for(ll j = 1; j < sd; j++)
			{
				answer[dua[j - 1]][dua[j]] = 1;
				answer[dua[j]][dua[j - 1]] = 1;
			}
			answer[sat[0]][dua[0]] = 1;
			answer[dua[0]][sat[0]] = 1;
			answer[sat[0]][dua[sd - 1]] = 1;
			answer[dua[sd - 1]][sat[0]] = 1;
		}
	}
	if(!bisa)return 0;
	build(answer);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 11 ms 1536 KB Output is correct
7 Correct 253 ms 26104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 11 ms 1536 KB Output is correct
7 Correct 253 ms 26104 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 10 ms 1408 KB Output is correct
13 Correct 241 ms 26104 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 6 ms 1024 KB Output is correct
17 Correct 132 ms 16120 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 62 ms 6904 KB Output is correct
21 Correct 244 ms 26104 KB Output is correct
22 Correct 242 ms 26104 KB Output is correct
23 Correct 265 ms 26104 KB Output is correct
24 Correct 247 ms 26104 KB Output is correct
25 Correct 114 ms 16120 KB Output is correct
26 Correct 107 ms 16248 KB Output is correct
27 Correct 265 ms 26104 KB Output is correct
28 Correct 243 ms 26104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 10 ms 1408 KB Output is correct
9 Correct 247 ms 26104 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 11 ms 1408 KB Output is correct
13 Correct 257 ms 26092 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 6 ms 1024 KB Output is correct
17 Correct 125 ms 16120 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 66 ms 6904 KB Output is correct
22 Correct 248 ms 26104 KB Output is correct
23 Correct 242 ms 26068 KB Output is correct
24 Correct 256 ms 26104 KB Output is correct
25 Correct 111 ms 16120 KB Output is correct
26 Correct 117 ms 16124 KB Output is correct
27 Correct 245 ms 26232 KB Output is correct
28 Correct 257 ms 26104 KB Output is correct
29 Correct 113 ms 16120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 61 ms 6904 KB Output is correct
5 Correct 249 ms 26096 KB Output is correct
6 Correct 253 ms 26128 KB Output is correct
7 Correct 266 ms 26104 KB Output is correct
8 Correct 1 ms 360 KB Output is correct
9 Correct 61 ms 6904 KB Output is correct
10 Correct 248 ms 26172 KB Output is correct
11 Correct 244 ms 26104 KB Output is correct
12 Correct 260 ms 26104 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Incorrect 1 ms 384 KB Too many ways to get from 0 to 3, should be 0 found no less than 1
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 11 ms 1536 KB Output is correct
7 Correct 253 ms 26104 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 10 ms 1408 KB Output is correct
13 Correct 241 ms 26104 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 6 ms 1024 KB Output is correct
17 Correct 132 ms 16120 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 62 ms 6904 KB Output is correct
21 Correct 244 ms 26104 KB Output is correct
22 Correct 242 ms 26104 KB Output is correct
23 Correct 265 ms 26104 KB Output is correct
24 Correct 247 ms 26104 KB Output is correct
25 Correct 114 ms 16120 KB Output is correct
26 Correct 107 ms 16248 KB Output is correct
27 Correct 265 ms 26104 KB Output is correct
28 Correct 243 ms 26104 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 10 ms 1408 KB Output is correct
37 Correct 247 ms 26104 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 384 KB Output is correct
40 Correct 11 ms 1408 KB Output is correct
41 Correct 257 ms 26092 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 6 ms 1024 KB Output is correct
45 Correct 125 ms 16120 KB Output is correct
46 Correct 1 ms 384 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 1 ms 384 KB Output is correct
49 Correct 66 ms 6904 KB Output is correct
50 Correct 248 ms 26104 KB Output is correct
51 Correct 242 ms 26068 KB Output is correct
52 Correct 256 ms 26104 KB Output is correct
53 Correct 111 ms 16120 KB Output is correct
54 Correct 117 ms 16124 KB Output is correct
55 Correct 245 ms 26232 KB Output is correct
56 Correct 257 ms 26104 KB Output is correct
57 Correct 113 ms 16120 KB Output is correct
58 Correct 1 ms 384 KB Output is correct
59 Correct 1 ms 384 KB Output is correct
60 Correct 6 ms 1024 KB Output is correct
61 Correct 123 ms 16120 KB Output is correct
62 Correct 1 ms 384 KB Output is correct
63 Correct 1 ms 384 KB Output is correct
64 Correct 0 ms 384 KB Output is correct
65 Runtime error 33 ms 8568 KB Execution killed with signal 11
66 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 11 ms 1536 KB Output is correct
7 Correct 253 ms 26104 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 10 ms 1408 KB Output is correct
13 Correct 241 ms 26104 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 6 ms 1024 KB Output is correct
17 Correct 132 ms 16120 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 62 ms 6904 KB Output is correct
21 Correct 244 ms 26104 KB Output is correct
22 Correct 242 ms 26104 KB Output is correct
23 Correct 265 ms 26104 KB Output is correct
24 Correct 247 ms 26104 KB Output is correct
25 Correct 114 ms 16120 KB Output is correct
26 Correct 107 ms 16248 KB Output is correct
27 Correct 265 ms 26104 KB Output is correct
28 Correct 243 ms 26104 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 512 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 10 ms 1408 KB Output is correct
37 Correct 247 ms 26104 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 384 KB Output is correct
40 Correct 11 ms 1408 KB Output is correct
41 Correct 257 ms 26092 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 6 ms 1024 KB Output is correct
45 Correct 125 ms 16120 KB Output is correct
46 Correct 1 ms 384 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 1 ms 384 KB Output is correct
49 Correct 66 ms 6904 KB Output is correct
50 Correct 248 ms 26104 KB Output is correct
51 Correct 242 ms 26068 KB Output is correct
52 Correct 256 ms 26104 KB Output is correct
53 Correct 111 ms 16120 KB Output is correct
54 Correct 117 ms 16124 KB Output is correct
55 Correct 245 ms 26232 KB Output is correct
56 Correct 257 ms 26104 KB Output is correct
57 Correct 113 ms 16120 KB Output is correct
58 Correct 1 ms 384 KB Output is correct
59 Correct 1 ms 384 KB Output is correct
60 Correct 1 ms 384 KB Output is correct
61 Correct 61 ms 6904 KB Output is correct
62 Correct 249 ms 26096 KB Output is correct
63 Correct 253 ms 26128 KB Output is correct
64 Correct 266 ms 26104 KB Output is correct
65 Correct 1 ms 360 KB Output is correct
66 Correct 61 ms 6904 KB Output is correct
67 Correct 248 ms 26172 KB Output is correct
68 Correct 244 ms 26104 KB Output is correct
69 Correct 260 ms 26104 KB Output is correct
70 Correct 1 ms 384 KB Output is correct
71 Correct 1 ms 384 KB Output is correct
72 Incorrect 1 ms 384 KB Too many ways to get from 0 to 3, should be 0 found no less than 1
73 Halted 0 ms 0 KB -