Submission #300218

# Submission time Handle Problem Language Result Execution time Memory
300218 2020-09-17T01:39:40 Z fpc_coder Connecting Supertrees (IOI20_supertrees) C++17
0 / 100
1000 ms 1970732 KB
#include <bits/stdc++.h>
#include "supertrees.h"

using namespace std;

int construct(vector<vector<int>> p) {
    vector<vector<int>> b(p.size(), vector<int>(p.size(), 0));
    int n = (int) p.size();
    vector<int> par(n, -1);
    vector<bool> vis(n, false);
    for (int i = 0; i < n; i++) {
        if (vis[i]) continue;
        par[i] = i;
        int cur = i;
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (p[i][j]) {
                if (vis[j]) return 0;
                vis[j] = true;
                b[cur][j] = b[j][cur] = 1;
                par[j] = i;
                cur = j;
            }
        }
        if (b[i][cur]) return 0;
        b[i][cur] = b[cur][i] = 1;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (par[i] == par[j] && p[i][j] != 2) return 0;
            if (par[i] != par[j] && p[i][j] != 0) return 0;
        }
    }
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:7:61: warning: control reaches end of non-void function [-Wreturn-type]
    7 |     vector<vector<int>> b(p.size(), vector<int>(p.size(), 0));
      |                                                             ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1174 ms 1668152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1174 ms 1668152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1224 ms 1811312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1205 ms 1970732 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1174 ms 1668152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1174 ms 1668152 KB Time limit exceeded
2 Halted 0 ms 0 KB -