답안 #810985

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810985 2023-08-06T18:55:14 Z oscar1f 슈퍼트리 잇기 (IOI20_supertrees) C++17
56 / 100
209 ms 28328 KB
#include "supertrees.h"
#include<bits/stdc++.h>

using namespace std;
using vv=vector<vector<int>>;

const int MAX_SOM=1005;
int nbSom;
vv adja,rep;
int pere[MAX_SOM][2];
vector<int> listeFils[MAX_SOM],listeBoucle[MAX_SOM];

int find(int pos,int tab) {
	if (pere[pos][tab]!=pos) {
		pere[pos][tab]=find(pere[pos][tab],tab);
	}
	return pere[pos][tab];
}

int construct(vv p) {
	adja=p;
	nbSom=adja.size();
	for (int i=0;i<nbSom;i++) {
		rep.push_back({});
		for (int j=0;j<nbSom;j++) {
			rep.back().push_back(0);
		}
		pere[i][0]=i;
		pere[i][1]=i;
	}
	for (int i=0;i<nbSom;i++) {
		for (int j=i+1;j<nbSom;j++) {
			if (adja[i][j]==3) {
				return 0;
			}
			if (adja[i][j]==1) { 
				if (find(i,0)!=find(j,0)) {
					pere[find(i,0)][0]=find(j,0);
				}
			}
		}
	}	
	for (int i=0;i<nbSom;i++) {
		//cout<<i<<" : "<<find(i,0)<<endl;
		listeFils[find(i,0)].push_back(i);
	}
    for (int i=0;i<nbSom;i++) {
        for (int j=1;j<(int)listeFils[i].size();j++) {
            for (int k=0;k<nbSom;k++) {
                if (adja[listeFils[i][j]]!=adja[listeFils[i][j-1]]) {
                    return 0;
                }
            }
            rep[listeFils[i][j]][listeFils[i][j-1]]=1;
            rep[listeFils[i][j-1]][listeFils[i][j]]=1;
        }
    }
    for (int i=0;i<nbSom;i++) {
        for (int j=i+1;j<nbSom;j++) {
            if (!listeFils[i].empty() and !listeFils[j].empty() and adja[i][j]==2 and find(i,1)!=find(j,1)) {
                pere[find(i,1)][1]=find(j,1);
            }
        }
    }
    for (int i=0;i<nbSom;i++) {
        if (!listeFils[i].empty()) {
            listeBoucle[find(i,1)].push_back(i);
        }
    }
    for (int i=0;i<nbSom;i++) {
        if (listeBoucle[i].size()>1) {
            for (int j=0;j<(int)listeBoucle[i].size();j++) {
                rep[listeBoucle[i][j]][listeBoucle[i][(j+1)%listeBoucle[i].size()]]=1;
                rep[listeBoucle[i][(j+1)%listeBoucle[i].size()]][listeBoucle[i][j]]=1;
            }
        }
    }
	build(rep);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 7 ms 1364 KB Output is correct
7 Correct 209 ms 26124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 7 ms 1364 KB Output is correct
7 Correct 209 ms 26124 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 6 ms 1364 KB Output is correct
13 Correct 148 ms 26180 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 67 ms 16192 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 42 ms 6844 KB Output is correct
21 Correct 193 ms 26060 KB Output is correct
22 Correct 179 ms 26140 KB Output is correct
23 Correct 199 ms 26060 KB Output is correct
24 Correct 150 ms 26156 KB Output is correct
25 Correct 95 ms 16180 KB Output is correct
26 Correct 78 ms 16188 KB Output is correct
27 Correct 199 ms 26060 KB Output is correct
28 Correct 146 ms 26136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 0 ms 340 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 42 ms 7280 KB Output is correct
5 Correct 199 ms 28072 KB Output is correct
6 Correct 183 ms 28108 KB Output is correct
7 Correct 205 ms 28328 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 37 ms 7340 KB Output is correct
10 Correct 149 ms 28124 KB Output is correct
11 Correct 155 ms 28144 KB Output is correct
12 Correct 151 ms 28080 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 38 ms 7288 KB Output is correct
17 Correct 145 ms 28108 KB Output is correct
18 Correct 168 ms 28056 KB Output is correct
19 Correct 169 ms 28080 KB Output is correct
20 Correct 145 ms 28084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 7 ms 1364 KB Output is correct
7 Correct 209 ms 26124 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 6 ms 1364 KB Output is correct
13 Correct 148 ms 26180 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 67 ms 16192 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 42 ms 6844 KB Output is correct
21 Correct 193 ms 26060 KB Output is correct
22 Correct 179 ms 26140 KB Output is correct
23 Correct 199 ms 26060 KB Output is correct
24 Correct 150 ms 26156 KB Output is correct
25 Correct 95 ms 16180 KB Output is correct
26 Correct 78 ms 16188 KB Output is correct
27 Correct 199 ms 26060 KB Output is correct
28 Correct 146 ms 26136 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Incorrect 0 ms 340 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 7 ms 1364 KB Output is correct
7 Correct 209 ms 26124 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 6 ms 1364 KB Output is correct
13 Correct 148 ms 26180 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 67 ms 16192 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 42 ms 6844 KB Output is correct
21 Correct 193 ms 26060 KB Output is correct
22 Correct 179 ms 26140 KB Output is correct
23 Correct 199 ms 26060 KB Output is correct
24 Correct 150 ms 26156 KB Output is correct
25 Correct 95 ms 16180 KB Output is correct
26 Correct 78 ms 16188 KB Output is correct
27 Correct 199 ms 26060 KB Output is correct
28 Correct 146 ms 26136 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Incorrect 0 ms 340 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -