답안 #1051388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1051388 2024-08-10T05:47:46 Z LittleOrange 슈퍼트리 잇기 (IOI20_supertrees) C++17
40 / 100
117 ms 22188 KB
#include "supertrees.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
using ll = int;
struct dsu{
	ll n;
	vector<ll> p;
	dsu(ll N):n(N),p(N,-1){}
	ll g(ll i){
		return p[i]<0?i:p[i]=g(p[i]);
	}
	bool e(ll a, ll b){
		return g(a)==g(b);
	}
	bool m(ll a, ll b){
		a = g(a);
		b = g(b);
		if(a==b) return false;
		if (p[a]>p[b]) swap(a,b);
		p[a] += p[b];
		p[b] = a;
		return true;
	}
};

int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	vector<vector<ll>> ans(n,vector<ll>(n,0));
	dsu d(n);
	for(ll i = 0;i<n;i++) for(ll j = 0;j<n;j++){
		if (p[i][j]) d.m(i,j);
	}
	for(ll i = 0;i<n;i++) for(ll j = 0;j<n;j++){
		if (!p[i][j]&&d.e(i,j)) return 0;
	}
	vector<ll> g;
	for(ll i = 0;i<n;i++) if(d.g(i)==i) g.push_back(i);
	ll gc = g.size();
	vector<vector<ll>> gs(gc);
	for(ll i = 0;i<n;i++) gs[lower_bound(g.begin(),g.end(),d.g(i))-g.begin()].push_back(i);
	for(auto &o : gs) if(o.size()>1){
		ll ty = p[o[0]][o[1]];
		for(ll i = 1;i<o.size();i++) ans[o[i-1]][o[i]] = ans[o[i]][o[i-1]] = 1;
		if (ty == 2){
			if (o.size()==2) return 0;
			ans[o.front()][o.back()] = ans[o.back()][o.front()] = 1;
		}
	}
	build(ans);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:44:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for(ll i = 1;i<o.size();i++) ans[o[i-1]][o[i]] = ans[o[i]][o[i-1]] = 1;
      |                ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1116 KB Output is correct
7 Correct 117 ms 22024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1116 KB Output is correct
7 Correct 117 ms 22024 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 1280 KB Output is correct
13 Correct 93 ms 22100 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 50 ms 12052 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 24 ms 5724 KB Output is correct
21 Correct 102 ms 22096 KB Output is correct
22 Correct 95 ms 22096 KB Output is correct
23 Correct 100 ms 21984 KB Output is correct
24 Correct 101 ms 22096 KB Output is correct
25 Correct 42 ms 12252 KB Output is correct
26 Correct 40 ms 12044 KB Output is correct
27 Correct 100 ms 22096 KB Output is correct
28 Correct 94 ms 22188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 4 ms 1116 KB Output is correct
9 Correct 97 ms 22112 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 94 ms 22096 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 54 ms 12052 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 24 ms 5724 KB Output is correct
22 Correct 97 ms 22096 KB Output is correct
23 Correct 94 ms 21984 KB Output is correct
24 Correct 101 ms 22100 KB Output is correct
25 Correct 42 ms 12112 KB Output is correct
26 Correct 43 ms 12116 KB Output is correct
27 Correct 94 ms 22100 KB Output is correct
28 Correct 106 ms 22036 KB Output is correct
29 Correct 42 ms 12116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 24 ms 5832 KB Output is correct
5 Correct 99 ms 22100 KB Output is correct
6 Correct 97 ms 22036 KB Output is correct
7 Correct 107 ms 22096 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 24 ms 5728 KB Output is correct
10 Correct 102 ms 21972 KB Output is correct
11 Correct 94 ms 22120 KB Output is correct
12 Correct 101 ms 22100 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Incorrect 0 ms 344 KB Too many ways to get from 0 to 4, should be 1 found no less than 2
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1116 KB Output is correct
7 Correct 117 ms 22024 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 1280 KB Output is correct
13 Correct 93 ms 22100 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 50 ms 12052 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 24 ms 5724 KB Output is correct
21 Correct 102 ms 22096 KB Output is correct
22 Correct 95 ms 22096 KB Output is correct
23 Correct 100 ms 21984 KB Output is correct
24 Correct 101 ms 22096 KB Output is correct
25 Correct 42 ms 12252 KB Output is correct
26 Correct 40 ms 12044 KB Output is correct
27 Correct 100 ms 22096 KB Output is correct
28 Correct 94 ms 22188 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 4 ms 1116 KB Output is correct
37 Correct 97 ms 22112 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 4 ms 1116 KB Output is correct
41 Correct 94 ms 22096 KB Output is correct
42 Correct 0 ms 600 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 54 ms 12052 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 24 ms 5724 KB Output is correct
50 Correct 97 ms 22096 KB Output is correct
51 Correct 94 ms 21984 KB Output is correct
52 Correct 101 ms 22100 KB Output is correct
53 Correct 42 ms 12112 KB Output is correct
54 Correct 43 ms 12116 KB Output is correct
55 Correct 94 ms 22100 KB Output is correct
56 Correct 106 ms 22036 KB Output is correct
57 Correct 42 ms 12116 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 3 ms 860 KB Output is correct
61 Correct 49 ms 12112 KB Output is correct
62 Correct 1 ms 344 KB Output is correct
63 Correct 0 ms 344 KB Output is correct
64 Correct 0 ms 344 KB Output is correct
65 Incorrect 24 ms 5696 KB Too many ways to get from 1 to 269, should be 1 found no less than 2
66 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 4 ms 1116 KB Output is correct
7 Correct 117 ms 22024 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 4 ms 1280 KB Output is correct
13 Correct 93 ms 22100 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 860 KB Output is correct
17 Correct 50 ms 12052 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 24 ms 5724 KB Output is correct
21 Correct 102 ms 22096 KB Output is correct
22 Correct 95 ms 22096 KB Output is correct
23 Correct 100 ms 21984 KB Output is correct
24 Correct 101 ms 22096 KB Output is correct
25 Correct 42 ms 12252 KB Output is correct
26 Correct 40 ms 12044 KB Output is correct
27 Correct 100 ms 22096 KB Output is correct
28 Correct 94 ms 22188 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 4 ms 1116 KB Output is correct
37 Correct 97 ms 22112 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 4 ms 1116 KB Output is correct
41 Correct 94 ms 22096 KB Output is correct
42 Correct 0 ms 600 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 2 ms 860 KB Output is correct
45 Correct 54 ms 12052 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 24 ms 5724 KB Output is correct
50 Correct 97 ms 22096 KB Output is correct
51 Correct 94 ms 21984 KB Output is correct
52 Correct 101 ms 22100 KB Output is correct
53 Correct 42 ms 12112 KB Output is correct
54 Correct 43 ms 12116 KB Output is correct
55 Correct 94 ms 22100 KB Output is correct
56 Correct 106 ms 22036 KB Output is correct
57 Correct 42 ms 12116 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 24 ms 5832 KB Output is correct
62 Correct 99 ms 22100 KB Output is correct
63 Correct 97 ms 22036 KB Output is correct
64 Correct 107 ms 22096 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 24 ms 5728 KB Output is correct
67 Correct 102 ms 21972 KB Output is correct
68 Correct 94 ms 22120 KB Output is correct
69 Correct 101 ms 22100 KB Output is correct
70 Correct 0 ms 344 KB Output is correct
71 Correct 0 ms 344 KB Output is correct
72 Incorrect 0 ms 344 KB Too many ways to get from 0 to 4, should be 1 found no less than 2
73 Halted 0 ms 0 KB -