답안 #790181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790181 2023-07-22T11:50:54 Z Andrey 슈퍼트리 잇기 (IOI20_supertrees) C++14
46 / 100
156 ms 27976 KB
#include "supertrees.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> ans(0);
vector<vector<int>> haha(0);
vector<bool> bruh(3001,true);
int n;
vector<int> col(3000,-1);

void dfs(int a, int c) {
    col[a] = c;
    if(a != c) {
        ans[a][c] = 1;
        ans[c][a] = 1;
    }
    for(int i = 0; i < n; i++) {
        if(col[i] == -1 && haha[a][i] == 1) {
            dfs(i,c);
        }
    }
}

int construct(vector<vector<int>> p) {
    n = p[0].size();
    haha = p;
    vector<int> wut(0);
    for(int i = 0; i < n; i++) {
        ans.push_back(vector<int> (n));
    }
    for(int i = 0; i < n; i++) {
        if(col[i] == -1) {
            dfs(i,i);
            wut.push_back(i);
        }
    }
    for(int i = 0; i < wut.size(); i++) {
        vector<int> wow(0);
        wow.push_back(wut[i]);
        for(int j = 0; j < wut.size(); j++) {
            if(haha[wut[i]][wut[j]] == 2 && bruh[j]) {
                bruh[j] = false;
                wow.push_back(wut[j]);
            }
        }
        if(wow.size() > 1) {
            for(int j = 0; j < wow.size(); j++) {
                ans[wow[j]][wow[(j+1)%(int)wow.size()]] = 1;
                ans[wow[(j+1)%(int)wow.size()]][wow[j]] = 1;
            }
        }
    }
    build(ans);
    return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 0; i < wut.size(); i++) {
      |                    ~~^~~~~~~~~~~~
supertrees.cpp:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int j = 0; j < wut.size(); j++) {
      |                        ~~^~~~~~~~~~~~
supertrees.cpp:48:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for(int j = 0; j < wow.size(); j++) {
      |                            ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
6 Correct 7 ms 1348 KB Output is correct
7 Correct 146 ms 27956 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
6 Correct 7 ms 1348 KB Output is correct
7 Correct 146 ms 27956 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 6 ms 1332 KB Output is correct
13 Correct 146 ms 27976 KB Output is correct
14 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 212 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 37 ms 7264 KB Output is correct
5 Correct 146 ms 27908 KB Output is correct
6 Correct 147 ms 27872 KB Output is correct
7 Correct 156 ms 27904 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 40 ms 7164 KB Output is correct
10 Correct 148 ms 27912 KB Output is correct
11 Correct 147 ms 27920 KB Output is correct
12 Correct 154 ms 27904 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 308 KB Output is correct
16 Correct 37 ms 7188 KB Output is correct
17 Correct 148 ms 27916 KB Output is correct
18 Correct 146 ms 27904 KB Output is correct
19 Correct 145 ms 27916 KB Output is correct
20 Correct 149 ms 27912 KB Output is correct
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
6 Correct 7 ms 1348 KB Output is correct
7 Correct 146 ms 27956 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 6 ms 1332 KB Output is correct
13 Correct 146 ms 27976 KB Output is correct
14 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
6 Correct 7 ms 1348 KB Output is correct
7 Correct 146 ms 27956 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 6 ms 1332 KB Output is correct
13 Correct 146 ms 27976 KB Output is correct
14 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
15 Halted 0 ms 0 KB -