Submission #961634

# Submission time Handle Problem Language Result Execution time Memory
961634 2024-04-12T09:18:48 Z Gr1sen Connecting Supertrees (IOI20_supertrees) C++17
0 / 100
0 ms 348 KB
#include"supertrees.h"
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define vi vector<int>
#define vvi vector<vi>

vi L;

vi F;

int find(int a) {return (a == -1 ? a : F[a] = find(F[a]));}

void uunion(int a, int b) {
    a = find(a); b = find(b);
    if (a == b) return;
    F[a] = b;
}


int construct(std::vector<std::vector<int>> p) {
    int n = p.size();
    vvi Adj(n, vi(n, 0));
    L.clear(); F.clear(); F.resize(n, -1);
    for (int i = 0; i < n; i++) {
        bool q = 0;
        for (int j = 0; j < n; j++) {
            if (p[i][j]) {
                Adj[i][j] = 1; 
                Adj[j][i] = 1; 
                uunion(i, j);
                continue;
            }
            if (find(i) == find(j)) return 0;
        }
        if (find(i) == find(i)) L.push_back(i);
    }
    build(Adj);
    return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:30:14: warning: unused variable 'q' [-Wunused-variable]
   30 |         bool q = 0;
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB b[0][0] is not 0
2 Halted 0 ms 0 KB -