Submission #810969

# Submission time Handle Problem Language Result Execution time Memory
810969 2023-08-06T18:44:06 Z oscar1f Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
211 ms 28184 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];

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;
        }
    }
	build(rep);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 7 ms 1508 KB Output is correct
7 Correct 211 ms 28184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 7 ms 1508 KB Output is correct
7 Correct 211 ms 28184 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1460 KB Output is correct
13 Correct 155 ms 27988 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 1108 KB Output is correct
17 Correct 71 ms 18072 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 45 ms 7288 KB Output is correct
21 Correct 202 ms 27980 KB Output is correct
22 Correct 182 ms 28056 KB Output is correct
23 Correct 207 ms 28056 KB Output is correct
24 Correct 157 ms 28060 KB Output is correct
25 Correct 97 ms 18064 KB Output is correct
26 Correct 79 ms 18076 KB Output is correct
27 Correct 206 ms 28048 KB Output is correct
28 Correct 156 ms 28060 KB Output is correct
# Verdict Execution time Memory 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 328 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 340 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 7 ms 1508 KB Output is correct
7 Correct 211 ms 28184 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1460 KB Output is correct
13 Correct 155 ms 27988 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 1108 KB Output is correct
17 Correct 71 ms 18072 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 45 ms 7288 KB Output is correct
21 Correct 202 ms 27980 KB Output is correct
22 Correct 182 ms 28056 KB Output is correct
23 Correct 207 ms 28056 KB Output is correct
24 Correct 157 ms 28060 KB Output is correct
25 Correct 97 ms 18064 KB Output is correct
26 Correct 79 ms 18076 KB Output is correct
27 Correct 206 ms 28048 KB Output is correct
28 Correct 156 ms 28060 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 328 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 7 ms 1508 KB Output is correct
7 Correct 211 ms 28184 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 328 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1460 KB Output is correct
13 Correct 155 ms 27988 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 1108 KB Output is correct
17 Correct 71 ms 18072 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 328 KB Output is correct
20 Correct 45 ms 7288 KB Output is correct
21 Correct 202 ms 27980 KB Output is correct
22 Correct 182 ms 28056 KB Output is correct
23 Correct 207 ms 28056 KB Output is correct
24 Correct 157 ms 28060 KB Output is correct
25 Correct 97 ms 18064 KB Output is correct
26 Correct 79 ms 18076 KB Output is correct
27 Correct 206 ms 28048 KB Output is correct
28 Correct 156 ms 28060 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 328 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -