답안 #794222

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
794222 2023-07-26T11:05:26 Z 12345678 슈퍼트리 잇기 (IOI20_supertrees) C++17
11 / 100
160 ms 22188 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=0; j<n; j++) if (p[i][j]!=p[j][i]) can=0;
    for (int i=0; i<n; i++) if (!p[i][i]) can=0;
    if (!can)return 0;
	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]||!p[y][x])
                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:46:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         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 1 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 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 149 ms 22044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 149 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 1 ms 212 KB Output is correct
12 Correct 7 ms 1128 KB Output is correct
13 Correct 151 ms 22060 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 74 ms 12068 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 43 ms 5788 KB Output is correct
21 Correct 150 ms 22060 KB Output is correct
22 Correct 149 ms 22048 KB Output is correct
23 Correct 159 ms 22188 KB Output is correct
24 Correct 160 ms 21964 KB Output is correct
25 Incorrect 149 ms 21968 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 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 149 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 1 ms 212 KB Output is correct
12 Correct 7 ms 1128 KB Output is correct
13 Correct 151 ms 22060 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 74 ms 12068 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 43 ms 5788 KB Output is correct
21 Correct 150 ms 22060 KB Output is correct
22 Correct 149 ms 22048 KB Output is correct
23 Correct 159 ms 22188 KB Output is correct
24 Correct 160 ms 21964 KB Output is correct
25 Incorrect 149 ms 21968 KB Answer gives possible 1 while actual possible 0
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 212 KB Output is correct
6 Correct 6 ms 1108 KB Output is correct
7 Correct 149 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 1 ms 212 KB Output is correct
12 Correct 7 ms 1128 KB Output is correct
13 Correct 151 ms 22060 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 74 ms 12068 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 43 ms 5788 KB Output is correct
21 Correct 150 ms 22060 KB Output is correct
22 Correct 149 ms 22048 KB Output is correct
23 Correct 159 ms 22188 KB Output is correct
24 Correct 160 ms 21964 KB Output is correct
25 Incorrect 149 ms 21968 KB Answer gives possible 1 while actual possible 0
26 Halted 0 ms 0 KB -