답안 #769089

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
769089 2023-06-29T07:19:55 Z t6twotwo 슈퍼트리 잇기 (IOI20_supertrees) C++17
19 / 100
160 ms 24088 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) {
        if (v.size() <= 1) {
            continue;
        }
        if (v.size() == 2) {
            return 0;
        }
        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 = 0; i < v.size(); i++) {
            int x = v[i];
            int y = v[i + 1 == v.size() ? 0 : i + 1];
            ans[x][y] = ans[y][x] = 1;
        }
    }
    build(ans);
    return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for (int i = 0; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
supertrees.cpp:36:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |             for (int j = i + 1; j < v.size(); j++) {
      |                                 ~~^~~~~~~~~~
supertrees.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for (int i = 0; i < v.size(); i++) {
      |                         ~~^~~~~~~~~~
supertrees.cpp:44:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             int y = v[i + 1 == v.size() ? 0 : i + 1];
      |                       ~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 9 ms 1224 KB Output is correct
9 Correct 154 ms 23972 KB Output is correct
10 Correct 0 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 7 ms 1236 KB Output is correct
13 Correct 157 ms 24088 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 852 KB Output is correct
17 Correct 66 ms 14028 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 38 ms 6244 KB Output is correct
22 Correct 158 ms 23992 KB Output is correct
23 Correct 160 ms 24004 KB Output is correct
24 Correct 158 ms 24048 KB Output is correct
25 Correct 60 ms 14068 KB Output is correct
26 Correct 64 ms 14080 KB Output is correct
27 Correct 154 ms 23984 KB Output is correct
28 Correct 155 ms 24012 KB Output is correct
29 Correct 77 ms 14064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Too many ways to get from 1 to 4, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Answer gives possible 0 while actual possible 1
3 Halted 0 ms 0 KB -