Submission #1064953

# Submission time Handle Problem Language Result Execution time Memory
1064953 2024-08-18T20:02:15 Z kkkkkkkk Connecting Supertrees (IOI20_supertrees) C++14
0 / 100
1 ms 444 KB
#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;

int parent[1005], sz[1005];

int Find(int x) {
    if (x==parent[x])
        return x;
    return parent[x]=Find(parent[x]);
}

void Union(int a, int b) {
    a=Find(a), b=Find(b);
    if (a==b) return;
    if (sz[a]<sz[b])
        swap(a, b);
    sz[a]+=sz[b];
    parent[b]=a;
}

int construct(vector<vector<int> > paths) {
    int n=paths.size();
    vector<vector<int> > a=paths;
    for (int i=0;i<n;i++)
        sz[i]=1, parent[i]=i;
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            a[i][j]=0;
    for (int i=0;i<n;i++) {
        for (int j=i+1;j<n;j++) {
            if (paths[i][j]) Union(i, j);
        }
    }
    vector<int> gr[n];
    for (int i=0;i<n;i++) {
        int lider=Find(i);
        gr[lider].push_back(i);
    }
    for (int i=0;i<n;i++) {
        if (gr[i].size()) {
            for (auto x:gr[i])
                for (auto y:gr[i])
                    if (x!=y) a[x][y]=1;
        }
    }
    build(a);
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 444 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 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 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too many ways to get from 1 to 4, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -