답안 #411069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
411069 2021-05-24T08:58:09 Z eagle30 슈퍼트리 잇기 (IOI20_supertrees) C++17
40 / 100
256 ms 32060 KB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;
int visited[2000];
vector<vector<int> > adjlist;
int coun=1;
void dfs(int s){
	visited[s]=coun;
	for(int i=0; i<adjlist[s].size(); i++){
		int v=adjlist[s][i];
		if(visited[v]==0)
			dfs(v);
	}
}
int construct(vector<vector<int> > p) {
	int n = p.size();
	adjlist.assign(n+1, vector<int>());
	bool is=false;
	for(int i=0; i<n; i++){		
		for(int j=0; j<n; j++){
			if(p[i][j] && i!=j){
				adjlist[i].push_back(j);
				adjlist[j].push_back(i);
			}
			if(p[i][j]==2)
				is=true;
		}
	}
	for(int i=0; i<n; i++){
		if(visited[i]==0){
			dfs(i);
			coun++;
		}
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(visited[i]==visited[j] && p[i][j]==0)
				return 0;
		}
	}
	vector<vector<int> > answer;
	answer.assign(n, vector<int>());
	for(int i=0; i<n; i++)
		answer[i].assign(n, 0);
	map<int, vector<int> > mp;
	for(int i=0; i<n; i++)
		mp[visited[i]].push_back(i);
	for(auto x:mp){
		for(int i=1; i<x.second.size(); i++){
			answer[x.second[i-1]][x.second[i]]=1;
			answer[x.second[i]][x.second[i-1]]=1;
		}
		if(is){
			if(x.second.size()==1)
				continue;
			if(x.second.size()==2)
				return 0;
			answer[x.second[0]][x.second[x.second.size()-1]]=1;
			answer[x.second[x.second.size()-1]][x.second[0]]=1;
		}
	}
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'void dfs(int)':
supertrees.cpp:9:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=0; i<adjlist[s].size(); i++){
      |               ~^~~~~~~~~~~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:49:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for(int i=1; i<x.second.size(); i++){
      |                ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 11 ms 1588 KB Output is correct
7 Correct 252 ms 30204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 11 ms 1588 KB Output is correct
7 Correct 252 ms 30204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 11 ms 1100 KB Output is correct
13 Correct 236 ms 22068 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 6 ms 864 KB Output is correct
17 Correct 126 ms 13952 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 74 ms 5828 KB Output is correct
21 Correct 256 ms 23052 KB Output is correct
22 Correct 232 ms 22080 KB Output is correct
23 Correct 256 ms 26180 KB Output is correct
24 Correct 232 ms 22132 KB Output is correct
25 Correct 101 ms 9284 KB Output is correct
26 Correct 94 ms 8204 KB Output is correct
27 Correct 249 ms 28288 KB Output is correct
28 Correct 244 ms 22176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 11 ms 1356 KB Output is correct
9 Correct 243 ms 24120 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 11 ms 1612 KB Output is correct
13 Correct 254 ms 32060 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 204 KB Output is correct
16 Correct 7 ms 952 KB Output is correct
17 Correct 124 ms 15860 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 59 ms 6276 KB Output is correct
22 Correct 248 ms 25064 KB Output is correct
23 Correct 239 ms 24132 KB Output is correct
24 Correct 248 ms 30196 KB Output is correct
25 Correct 103 ms 14148 KB Output is correct
26 Correct 104 ms 11244 KB Output is correct
27 Correct 235 ms 24188 KB Output is correct
28 Correct 256 ms 28100 KB Output is correct
29 Correct 99 ms 14148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 74 ms 5832 KB Output is correct
5 Correct 242 ms 23108 KB Output is correct
6 Correct 253 ms 22044 KB Output is correct
7 Correct 247 ms 26100 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 60 ms 5796 KB Output is correct
10 Correct 237 ms 23088 KB Output is correct
11 Correct 227 ms 22148 KB Output is correct
12 Correct 251 ms 28288 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Incorrect 1 ms 204 KB Too many ways to get from 4 to 8, should be 1 found no less than 2
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 11 ms 1588 KB Output is correct
7 Correct 252 ms 30204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 11 ms 1100 KB Output is correct
13 Correct 236 ms 22068 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 6 ms 864 KB Output is correct
17 Correct 126 ms 13952 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 74 ms 5828 KB Output is correct
21 Correct 256 ms 23052 KB Output is correct
22 Correct 232 ms 22080 KB Output is correct
23 Correct 256 ms 26180 KB Output is correct
24 Correct 232 ms 22132 KB Output is correct
25 Correct 101 ms 9284 KB Output is correct
26 Correct 94 ms 8204 KB Output is correct
27 Correct 249 ms 28288 KB Output is correct
28 Correct 244 ms 22176 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 11 ms 1356 KB Output is correct
37 Correct 243 ms 24120 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 11 ms 1612 KB Output is correct
41 Correct 254 ms 32060 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 2 ms 204 KB Output is correct
44 Correct 7 ms 952 KB Output is correct
45 Correct 124 ms 15860 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 59 ms 6276 KB Output is correct
50 Correct 248 ms 25064 KB Output is correct
51 Correct 239 ms 24132 KB Output is correct
52 Correct 248 ms 30196 KB Output is correct
53 Correct 103 ms 14148 KB Output is correct
54 Correct 104 ms 11244 KB Output is correct
55 Correct 235 ms 24188 KB Output is correct
56 Correct 256 ms 28100 KB Output is correct
57 Correct 99 ms 14148 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 6 ms 1100 KB Output is correct
61 Correct 122 ms 18856 KB Output is correct
62 Correct 1 ms 204 KB Output is correct
63 Incorrect 1 ms 204 KB Too many ways to get from 0 to 9, should be 1 found no less than 2
64 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 11 ms 1588 KB Output is correct
7 Correct 252 ms 30204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 11 ms 1100 KB Output is correct
13 Correct 236 ms 22068 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 6 ms 864 KB Output is correct
17 Correct 126 ms 13952 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 74 ms 5828 KB Output is correct
21 Correct 256 ms 23052 KB Output is correct
22 Correct 232 ms 22080 KB Output is correct
23 Correct 256 ms 26180 KB Output is correct
24 Correct 232 ms 22132 KB Output is correct
25 Correct 101 ms 9284 KB Output is correct
26 Correct 94 ms 8204 KB Output is correct
27 Correct 249 ms 28288 KB Output is correct
28 Correct 244 ms 22176 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 11 ms 1356 KB Output is correct
37 Correct 243 ms 24120 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 11 ms 1612 KB Output is correct
41 Correct 254 ms 32060 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 2 ms 204 KB Output is correct
44 Correct 7 ms 952 KB Output is correct
45 Correct 124 ms 15860 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 59 ms 6276 KB Output is correct
50 Correct 248 ms 25064 KB Output is correct
51 Correct 239 ms 24132 KB Output is correct
52 Correct 248 ms 30196 KB Output is correct
53 Correct 103 ms 14148 KB Output is correct
54 Correct 104 ms 11244 KB Output is correct
55 Correct 235 ms 24188 KB Output is correct
56 Correct 256 ms 28100 KB Output is correct
57 Correct 99 ms 14148 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 74 ms 5832 KB Output is correct
62 Correct 242 ms 23108 KB Output is correct
63 Correct 253 ms 22044 KB Output is correct
64 Correct 247 ms 26100 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 60 ms 5796 KB Output is correct
67 Correct 237 ms 23088 KB Output is correct
68 Correct 227 ms 22148 KB Output is correct
69 Correct 251 ms 28288 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Incorrect 1 ms 204 KB Too many ways to get from 4 to 8, should be 1 found no less than 2
72 Halted 0 ms 0 KB -