Submission #1011861

# Submission time Handle Problem Language Result Execution time Memory
1011861 2024-07-01T09:55:29 Z LucaIlie Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
129 ms 24148 KB
#include "supertrees.h"
#include <vector>
#include <iostream>
using namespace std;
vector<vector<int>> answer;
#define nmax 1000
int daddy[nmax];

int find_daddy( int a ) {
    int x;
    if( daddy[a] == a )
        return a;
    x = find_daddy( daddy[a] );
    daddy[a] = x;
    return x;
}

void marry_daddy( int a, int b ) {
    int x, y;
    x = find_daddy( a );
    y = find_daddy( b );
    daddy[x] = y;
}

int construct( vector<vector<int>> p) {
    int n = p.size();
    for (int i = 0; i < n; i++) {
        vector<int> row;
        row.resize(n);
        answer.push_back(row);
    }

    int i, j;
    bool ok = true;
    for( i = 0; i < n; i++ )
        daddy[i] = i;
    for( i = 0; i < n; i++ ) {
        for( j = 0; j < n; j++ )
            if( p[i][j] > 0 )
                marry_daddy( i, j );
    }
    for( i = 0; i < n; i++ ) {
        for( j = 0; j < n; j++ )
            if( p[i][j] == 0 && find_daddy(i) == find_daddy(j) )
                ok = false;
    }
    if( !ok )
        return 0;
    for( i = 0; i < n; i++ )
        if( find_daddy(i) != i ) {
            answer[i][find_daddy(i)] = 1;
            answer[find_daddy(i)][i] = 1;
        }

    build(answer);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 111 ms 23920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 111 ms 23920 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 5 ms 1224 KB Output is correct
13 Correct 112 ms 23948 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 65 ms 14244 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 30 ms 6276 KB Output is correct
21 Correct 115 ms 24076 KB Output is correct
22 Correct 112 ms 23956 KB Output is correct
23 Correct 129 ms 23908 KB Output is correct
24 Correct 116 ms 24148 KB Output is correct
25 Correct 58 ms 14160 KB Output is correct
26 Correct 55 ms 14204 KB Output is correct
27 Correct 127 ms 23952 KB Output is correct
28 Correct 124 ms 23936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 344 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 111 ms 23920 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 5 ms 1224 KB Output is correct
13 Correct 112 ms 23948 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 65 ms 14244 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 30 ms 6276 KB Output is correct
21 Correct 115 ms 24076 KB Output is correct
22 Correct 112 ms 23956 KB Output is correct
23 Correct 129 ms 23908 KB Output is correct
24 Correct 116 ms 24148 KB Output is correct
25 Correct 58 ms 14160 KB Output is correct
26 Correct 55 ms 14204 KB Output is correct
27 Correct 127 ms 23952 KB Output is correct
28 Correct 124 ms 23936 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 344 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 344 KB Output is correct
2 Correct 0 ms 508 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 111 ms 23920 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 5 ms 1224 KB Output is correct
13 Correct 112 ms 23948 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 65 ms 14244 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 30 ms 6276 KB Output is correct
21 Correct 115 ms 24076 KB Output is correct
22 Correct 112 ms 23956 KB Output is correct
23 Correct 129 ms 23908 KB Output is correct
24 Correct 116 ms 24148 KB Output is correct
25 Correct 58 ms 14160 KB Output is correct
26 Correct 55 ms 14204 KB Output is correct
27 Correct 127 ms 23952 KB Output is correct
28 Correct 124 ms 23936 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Incorrect 0 ms 344 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -