Submission #888215

# Submission time Handle Problem Language Result Execution time Memory
888215 2023-12-16T13:17:18 Z 12345678 Connecting Supertrees (IOI20_supertrees) C++17
19 / 100
177 ms 24404 KB
#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;

const int nx=1e3+5;
bool vs[nx];

int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	vector<vector<int>> answer(n, vector<int> (n, 0));
	for (int i=0; i<n; i++)
    {
        if (vs[i]) continue;
        queue<int> q;
        vector<int> d;
        q.push(i); vs[i]=1;
        while (!q.empty())
        {
            auto u=q.front(); 
            q.pop();
            d.push_back(u);
            for (int v=0; v<n; v++) if (p[u][v]==2&&!vs[v]) vs[v]=1, q.push(v);
        }
        for (auto u:d) for (auto v:d) if (p[u][v]==0) return 0;
        if (d.size()==2) return 0;
        if (d.size()<=1) continue;
        int sz=d.size();
        for (int j=0; j<sz-1; j++) answer[d[j]][d[j+1]]=answer[d[j+1]][d[j]]=1;
        answer[d[0]][d[sz-1]]=answer[d[sz-1]][d[0]]=1;
    }
	build(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 7 ms 1116 KB Output is correct
9 Correct 157 ms 22064 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 7 ms 1116 KB Output is correct
13 Correct 164 ms 22100 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 860 KB Output is correct
17 Correct 78 ms 12196 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 40 ms 5696 KB Output is correct
22 Correct 177 ms 24140 KB Output is correct
23 Correct 157 ms 23920 KB Output is correct
24 Correct 164 ms 24404 KB Output is correct
25 Correct 68 ms 14224 KB Output is correct
26 Correct 68 ms 14204 KB Output is correct
27 Correct 157 ms 24148 KB Output is correct
28 Correct 161 ms 24032 KB Output is correct
29 Correct 72 ms 14084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Too few ways to get from 1 to 2, should be 1 found 0
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Too few ways to get from 0 to 1, should be 1 found 0
3 Halted 0 ms 0 KB -