답안 #794215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
794215 2023-07-26T10:53:42 Z 12345678 슈퍼트리 잇기 (IOI20_supertrees) C++17
11 / 100
172 ms 22076 KB
#include "supertrees.h"
#include <vector>
#include <bits/stdc++.h>

using namespace std;

int id[1005], t;
vector<vector<int>> d(1005);
bool can=1;

int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	std::vector<std::vector<int>> answer;
	for (int i = 0; i < n; i++) {
		std::vector<int> row;
		row.resize(n);
		answer.push_back(row);
	}
	for (int i=0; i<n; i++)
    {
        for (int j=i+1; j<n; j++)
        {
            if (p[i][j])
            {
                if (!id[i]&&!id[j]) id[i]=id[j]=++t, d[t].push_back(i), d[t].push_back(j);
                else if (!id[i]) id[i]=id[j], d[id[j]].push_back(i);
                else if (!id[j]) id[j]=id[i], d[id[i]].push_back(j);
            }
        }
    }
    for (int i=1; i<=t; i++)
    {
        sort(d[i].begin(), d[i].end());
        for (auto x:d[i])
        {
            for (auto y:d[i])
            {
                if (!p[x][y])
                can=0;
            }
        }
        if (!can) break;
        for (int j=0; j<d[i].size()-1; j++) answer[d[i][j]][d[i][j+1]]=answer[d[i][j+1]][d[i][j]]=1;
    }
    if (can)
    {
        build(answer);
	    return 1;
    }
    else return 0;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:43:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int j=0; j<d[i].size()-1; j++) answer[d[i][j]][d[i][j+1]]=answer[d[i][j+1]][d[i][j]]=1;
      |                       ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 1128 KB Output is correct
7 Correct 155 ms 22044 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 1 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 1128 KB Output is correct
7 Correct 155 ms 22044 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1200 KB Output is correct
13 Correct 162 ms 21960 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 724 KB Output is correct
17 Correct 77 ms 12176 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 38 ms 5764 KB Output is correct
21 Correct 154 ms 22064 KB Output is correct
22 Correct 150 ms 22044 KB Output is correct
23 Correct 155 ms 21964 KB Output is correct
24 Correct 158 ms 21960 KB Output is correct
25 Incorrect 172 ms 22076 KB Answer gives possible 1 while actual possible 0
26 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 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 Incorrect 0 ms 212 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 1 ms 212 KB Output is correct
3 Correct 1 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 1128 KB Output is correct
7 Correct 155 ms 22044 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1200 KB Output is correct
13 Correct 162 ms 21960 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 724 KB Output is correct
17 Correct 77 ms 12176 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 38 ms 5764 KB Output is correct
21 Correct 154 ms 22064 KB Output is correct
22 Correct 150 ms 22044 KB Output is correct
23 Correct 155 ms 21964 KB Output is correct
24 Correct 158 ms 21960 KB Output is correct
25 Incorrect 172 ms 22076 KB Answer gives possible 1 while actual possible 0
26 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 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 1128 KB Output is correct
7 Correct 155 ms 22044 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1200 KB Output is correct
13 Correct 162 ms 21960 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 724 KB Output is correct
17 Correct 77 ms 12176 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 38 ms 5764 KB Output is correct
21 Correct 154 ms 22064 KB Output is correct
22 Correct 150 ms 22044 KB Output is correct
23 Correct 155 ms 21964 KB Output is correct
24 Correct 158 ms 21960 KB Output is correct
25 Incorrect 172 ms 22076 KB Answer gives possible 1 while actual possible 0
26 Halted 0 ms 0 KB -