답안 #757725

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

bool odw[1009];
int nr[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;
		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;
				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;
			}
		}
		
		/*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:55:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1108 KB Output is correct
7 Correct 170 ms 21968 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 8 ms 1108 KB Output is correct
7 Correct 170 ms 21968 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 9 ms 1108 KB Output is correct
13 Correct 179 ms 22040 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 84 ms 14028 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 44 ms 6224 KB Output is correct
21 Correct 167 ms 23924 KB Output is correct
22 Correct 174 ms 23936 KB Output is correct
23 Correct 223 ms 23976 KB Output is correct
24 Correct 181 ms 24060 KB Output is correct
25 Correct 76 ms 14068 KB Output is correct
26 Correct 77 ms 14028 KB Output is correct
27 Correct 180 ms 23928 KB Output is correct
28 Correct 178 ms 23984 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 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 1 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 Correct 63 ms 5688 KB Output is correct
5 Correct 183 ms 22052 KB Output is correct
6 Correct 190 ms 22024 KB Output is correct
7 Correct 186 ms 22012 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 46 ms 5708 KB Output is correct
10 Correct 176 ms 22100 KB Output is correct
11 Correct 195 ms 22040 KB Output is correct
12 Correct 185 ms 21972 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 228 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 46 ms 5780 KB Output is correct
17 Correct 168 ms 21992 KB Output is correct
18 Correct 168 ms 22024 KB Output is correct
19 Correct 172 ms 22024 KB Output is correct
20 Correct 182 ms 21960 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 8 ms 1108 KB Output is correct
7 Correct 170 ms 21968 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 9 ms 1108 KB Output is correct
13 Correct 179 ms 22040 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 84 ms 14028 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 44 ms 6224 KB Output is correct
21 Correct 167 ms 23924 KB Output is correct
22 Correct 174 ms 23936 KB Output is correct
23 Correct 223 ms 23976 KB Output is correct
24 Correct 181 ms 24060 KB Output is correct
25 Correct 76 ms 14068 KB Output is correct
26 Correct 77 ms 14028 KB Output is correct
27 Correct 180 ms 23928 KB Output is correct
28 Correct 178 ms 23984 KB Output is correct
29 Correct 1 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 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1108 KB Output is correct
7 Correct 170 ms 21968 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 9 ms 1108 KB Output is correct
13 Correct 179 ms 22040 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 84 ms 14028 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 44 ms 6224 KB Output is correct
21 Correct 167 ms 23924 KB Output is correct
22 Correct 174 ms 23936 KB Output is correct
23 Correct 223 ms 23976 KB Output is correct
24 Correct 181 ms 24060 KB Output is correct
25 Correct 76 ms 14068 KB Output is correct
26 Correct 77 ms 14028 KB Output is correct
27 Correct 180 ms 23928 KB Output is correct
28 Correct 178 ms 23984 KB Output is correct
29 Correct 1 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 -