Submission #769083

# Submission time Handle Problem Language Result Execution time Memory
769083 2023-06-29T07:16:53 Z t6twotwo Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
178 ms 24056 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int construct(std::vector<std::vector<int>> a) {
    int N = a.size();
    vector<vector<int>> s(N);
    vector<bool> vis(N);
    for (int i = 0; i < N; i++) {
        if (vis[i]) {
            continue;
        }
        vis[i] = 1;
        queue<int> q;
        q.push(i);
        while (!q.empty()) {
            int x = q.front();
            q.pop();
            s[i].push_back(x);
            for (int y = 0; y < N; y++) {
                if (!vis[y] && a[x][y]) {
                    vis[y] = 1;
                    q.push(y);
                }
            }
        }
    }
    vector ans(N, vector<int>(N));
    for (auto &v : s) {
        for (int i = 0; i < v.size(); i++) {
            for (int j = i + 1; j < v.size(); j++) {
                if (!a[v[i]][v[j]]) {
                    return 0;
                }
            }
        }
        for (int i = 1; i < v.size(); i++) {
            ans[v[0]][v[i]] = ans[v[i]][v[0]] = 1;
        }
    }
    build(ans);
    return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         for (int i = 0; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
supertrees.cpp:30:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             for (int j = i + 1; j < v.size(); j++) {
      |                                 ~~^~~~~~~~~~
supertrees.cpp:36:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for (int i = 1; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 151 ms 22028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 151 ms 22028 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 7 ms 1212 KB Output is correct
13 Correct 151 ms 24056 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 68 ms 14076 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 39 ms 6216 KB Output is correct
21 Correct 155 ms 24012 KB Output is correct
22 Correct 152 ms 24012 KB Output is correct
23 Correct 156 ms 23924 KB Output is correct
24 Correct 156 ms 24052 KB Output is correct
25 Correct 67 ms 14028 KB Output is correct
26 Correct 66 ms 14068 KB Output is correct
27 Correct 178 ms 23924 KB Output is correct
28 Correct 152 ms 23932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 300 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 212 KB Output is correct
2 Incorrect 1 ms 212 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 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 151 ms 22028 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 7 ms 1212 KB Output is correct
13 Correct 151 ms 24056 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 68 ms 14076 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 39 ms 6216 KB Output is correct
21 Correct 155 ms 24012 KB Output is correct
22 Correct 152 ms 24012 KB Output is correct
23 Correct 156 ms 23924 KB Output is correct
24 Correct 156 ms 24052 KB Output is correct
25 Correct 67 ms 14028 KB Output is correct
26 Correct 66 ms 14068 KB Output is correct
27 Correct 178 ms 23924 KB Output is correct
28 Correct 152 ms 23932 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 1 ms 300 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 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 151 ms 22028 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 7 ms 1212 KB Output is correct
13 Correct 151 ms 24056 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 68 ms 14076 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 39 ms 6216 KB Output is correct
21 Correct 155 ms 24012 KB Output is correct
22 Correct 152 ms 24012 KB Output is correct
23 Correct 156 ms 23924 KB Output is correct
24 Correct 156 ms 24052 KB Output is correct
25 Correct 67 ms 14028 KB Output is correct
26 Correct 66 ms 14068 KB Output is correct
27 Correct 178 ms 23924 KB Output is correct
28 Correct 152 ms 23932 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 1 ms 300 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -