답안 #794217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
794217 2023-07-26T10:56:06 Z 12345678 슈퍼트리 잇기 (IOI20_supertrees) C++17
11 / 100
158 ms 22080 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;
    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:45:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         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 0 ms 212 KB Output is correct
3 Correct 1 ms 228 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 147 ms 22056 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 228 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 147 ms 22056 KB Output is correct
8 Correct 1 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 6 ms 1108 KB Output is correct
13 Correct 143 ms 22044 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 71 ms 12076 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 37 ms 5796 KB Output is correct
21 Correct 145 ms 22020 KB Output is correct
22 Correct 146 ms 22044 KB Output is correct
23 Correct 151 ms 22016 KB Output is correct
24 Correct 144 ms 22080 KB Output is correct
25 Incorrect 158 ms 22056 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 0 ms 212 KB Output is correct
3 Correct 1 ms 228 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 147 ms 22056 KB Output is correct
8 Correct 1 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 6 ms 1108 KB Output is correct
13 Correct 143 ms 22044 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 71 ms 12076 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 37 ms 5796 KB Output is correct
21 Correct 145 ms 22020 KB Output is correct
22 Correct 146 ms 22044 KB Output is correct
23 Correct 151 ms 22016 KB Output is correct
24 Correct 144 ms 22080 KB Output is correct
25 Incorrect 158 ms 22056 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 1 ms 228 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 147 ms 22056 KB Output is correct
8 Correct 1 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 6 ms 1108 KB Output is correct
13 Correct 143 ms 22044 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 71 ms 12076 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 37 ms 5796 KB Output is correct
21 Correct 145 ms 22020 KB Output is correct
22 Correct 146 ms 22044 KB Output is correct
23 Correct 151 ms 22016 KB Output is correct
24 Correct 144 ms 22080 KB Output is correct
25 Incorrect 158 ms 22056 KB Answer gives possible 1 while actual possible 0
26 Halted 0 ms 0 KB -