답안 #757726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757726 2023-06-13T16:27:09 Z Piokemon 슈퍼트리 잇기 (IOI20_supertrees) C++17
56 / 100
195 ms 22192 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

bool odw[1009];
int nr[1009];
vector<int> lista[1009];

int construct(vector<vector<int>> p) {
	int n = p.size();
	vector<int> czesc(n,0);
	vector<vector<int>> answer(n,czesc);
	for(int i=0;i<=n;i++) odw[i]=0;
	for (int i=0;i<n;i++){
		if (odw[i]) continue;
		nr[i] = i;
		lista[i].push_back(i);
		odw[i] = 1;
		for (int j=0;j<n;j++){
			if (p[i][j]==3) return 0;
			if (odw[j] || i==j) continue;
			if (p[i][j]==1){
				answer[i][j] = 1;
				answer[j][i] = 1;
				nr[j] = i;
				lista[i].push_back(j);
				odw[j] = 1;
			}
		}
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			if (p[i][j] != p[nr[i]][j]) return 0;
		}
	}
	for(int i=0;i<=n;i++) odw[i]=0;
	/*cout << "nr: ";
	for (int i=0;i<n;i++) cout << nr[i] << ' ';
	cout << '\n';*/
	for (int i=0;i<n;i++){
		if (nr[i]!=i || odw[i]) continue;
		vector<int> cykl;
		cykl.push_back(i);
		for (int j=0;j<n;j++){
			if (p[i][j]==2 && !odw[nr[j]]){
				cykl.push_back(nr[j]);
				odw[nr[j]] = 1;
			}
		}
		for (int x=0;x<cykl.size();x++){
			for (int y=0;y<cykl.size();y++){
				if (x==y) continue;
				for (int z:lista[cykl[y]]){
					if (p[cykl[x]][z]!=2) return 0;
				}
			}
		}
		/*cout << "cykl: ";
		for (int j:cykl){
			cout << j << ' ';
		}
		cout << '\n';*/
		if (cykl.size()==1) continue;
		for (int j=0;j<cykl.size()-1;j++){
			answer[cykl[j]][cykl[j+1]] = 1;
			answer[cykl[j+1]][cykl[j]] = 1;
		}
		answer[cykl.back()][cykl[0]] = 1;
		answer[cykl[0]][cykl.back()] =1;
	}
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   for (int x=0;x<cykl.size();x++){
      |                ~^~~~~~~~~~~~
supertrees.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |    for (int y=0;y<cykl.size();y++){
      |                 ~^~~~~~~~~~~~
supertrees.cpp:65:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   for (int j=0;j<cykl.size()-1;j++){
      |                ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 ms 240 KB Output is correct
6 Correct 7 ms 1108 KB Output is correct
7 Correct 188 ms 22044 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 1 ms 240 KB Output is correct
6 Correct 7 ms 1108 KB Output is correct
7 Correct 188 ms 22044 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 1108 KB Output is correct
13 Correct 185 ms 22044 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 4 ms 724 KB Output is correct
17 Correct 83 ms 12060 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 46 ms 5792 KB Output is correct
21 Correct 172 ms 21968 KB Output is correct
22 Correct 194 ms 22192 KB Output is correct
23 Correct 195 ms 22060 KB Output is correct
24 Correct 176 ms 22152 KB Output is correct
25 Correct 70 ms 12076 KB Output is correct
26 Correct 74 ms 12064 KB Output is correct
27 Correct 187 ms 22048 KB Output is correct
28 Correct 168 ms 22060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
5 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 1 ms 212 KB Output is correct
4 Correct 46 ms 5788 KB Output is correct
5 Correct 175 ms 22008 KB Output is correct
6 Correct 175 ms 21972 KB Output is correct
7 Correct 194 ms 22032 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 59 ms 5788 KB Output is correct
10 Correct 184 ms 22064 KB Output is correct
11 Correct 194 ms 22056 KB Output is correct
12 Correct 186 ms 22048 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 45 ms 5744 KB Output is correct
17 Correct 191 ms 22048 KB Output is correct
18 Correct 179 ms 22092 KB Output is correct
19 Correct 181 ms 22088 KB Output is correct
20 Correct 170 ms 22060 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 1 ms 240 KB Output is correct
6 Correct 7 ms 1108 KB Output is correct
7 Correct 188 ms 22044 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 1108 KB Output is correct
13 Correct 185 ms 22044 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 4 ms 724 KB Output is correct
17 Correct 83 ms 12060 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 46 ms 5792 KB Output is correct
21 Correct 172 ms 21968 KB Output is correct
22 Correct 194 ms 22192 KB Output is correct
23 Correct 195 ms 22060 KB Output is correct
24 Correct 176 ms 22152 KB Output is correct
25 Correct 70 ms 12076 KB Output is correct
26 Correct 74 ms 12064 KB Output is correct
27 Correct 187 ms 22048 KB Output is correct
28 Correct 168 ms 22060 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
33 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 1 ms 240 KB Output is correct
6 Correct 7 ms 1108 KB Output is correct
7 Correct 188 ms 22044 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 1108 KB Output is correct
13 Correct 185 ms 22044 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 4 ms 724 KB Output is correct
17 Correct 83 ms 12060 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 46 ms 5792 KB Output is correct
21 Correct 172 ms 21968 KB Output is correct
22 Correct 194 ms 22192 KB Output is correct
23 Correct 195 ms 22060 KB Output is correct
24 Correct 176 ms 22152 KB Output is correct
25 Correct 70 ms 12076 KB Output is correct
26 Correct 74 ms 12064 KB Output is correct
27 Correct 187 ms 22048 KB Output is correct
28 Correct 168 ms 22060 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -