답안 #721932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721932 2023-04-11T08:57:00 Z danikoynov 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
244 ms 31000 KB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;

vector < int > graph[maxn], comp;
int cap[maxn][maxn];
int used[maxn];
vector<std::vector<int>> answer;
void dfs(int v)
{
    comp.push_back(v);
    used[v] = 1;
    for (int u : graph[v])
    {
        if (!used[u])
            dfs(u);
    }
}

bool solve_component()
{
    for (int i = 0; i < comp.size(); i ++)
        for (int j = 0; j < comp.size(); j ++)
        if (cap[comp[i]][comp[j]] == 0)
            return false;

    for (int i = 0; i < (int)(comp.size()) - 1; i ++)
    {
        answer[comp[i]][comp[i + 1]] = 1;
        answer[comp[i + 1]][comp[i]] = 1;
    }

    return true;

}
int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	for (int i = 0; i < n; i++) {
		std::vector<int> row;
		row.resize(n, 0);
		answer.push_back(row);
	}

	for (int i = 0; i < n; i ++)
        for (int j = 0; j < n; j ++)
        cap[i][j] = p[i][j];

	for (int i = 0; i < n; i ++)
        for (int j = 0; j < n; j ++)
    {
        if (i != j && p[i][j] != 0)
            graph[i].push_back(j);
    }

    for (int i = 0; i < n; i ++)
    {
        if (!used[i])
        {
            comp.clear();
            dfs(i);
            bool is_fine = solve_component();
            if (!is_fine)
                return 0;
        }
    }
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'bool solve_component()':
supertrees.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i = 0; i < comp.size(); i ++)
      |                     ~~^~~~~~~~~~~~~
supertrees.cpp:24:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for (int j = 0; j < comp.size(); j ++)
      |                         ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 182 ms 30228 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 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 182 ms 30228 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 284 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 9 ms 2004 KB Output is correct
13 Correct 184 ms 27936 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 5 ms 1748 KB Output is correct
17 Correct 90 ms 20496 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 83 ms 8220 KB Output is correct
21 Correct 201 ms 28464 KB Output is correct
22 Correct 210 ms 27936 KB Output is correct
23 Correct 221 ms 29992 KB Output is correct
24 Correct 206 ms 27924 KB Output is correct
25 Correct 93 ms 18580 KB Output is correct
26 Correct 98 ms 18064 KB Output is correct
27 Correct 244 ms 31000 KB Output is correct
28 Correct 205 ms 27932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Incorrect 1 ms 340 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Too few ways to get from 0 to 1, should be 2 found 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 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 182 ms 30228 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 284 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 9 ms 2004 KB Output is correct
13 Correct 184 ms 27936 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 5 ms 1748 KB Output is correct
17 Correct 90 ms 20496 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 83 ms 8220 KB Output is correct
21 Correct 201 ms 28464 KB Output is correct
22 Correct 210 ms 27936 KB Output is correct
23 Correct 221 ms 29992 KB Output is correct
24 Correct 206 ms 27924 KB Output is correct
25 Correct 93 ms 18580 KB Output is correct
26 Correct 98 ms 18064 KB Output is correct
27 Correct 244 ms 31000 KB Output is correct
28 Correct 205 ms 27932 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Incorrect 1 ms 340 KB Answer gives possible 1 while actual possible 0
33 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 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 9 ms 2260 KB Output is correct
7 Correct 182 ms 30228 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 284 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 9 ms 2004 KB Output is correct
13 Correct 184 ms 27936 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 5 ms 1748 KB Output is correct
17 Correct 90 ms 20496 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 83 ms 8220 KB Output is correct
21 Correct 201 ms 28464 KB Output is correct
22 Correct 210 ms 27936 KB Output is correct
23 Correct 221 ms 29992 KB Output is correct
24 Correct 206 ms 27924 KB Output is correct
25 Correct 93 ms 18580 KB Output is correct
26 Correct 98 ms 18064 KB Output is correct
27 Correct 244 ms 31000 KB Output is correct
28 Correct 205 ms 27932 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Incorrect 1 ms 340 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -