답안 #745826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745826 2023-05-21T08:24:31 Z JakobZorz 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
246 ms 24052 KB
#include "supertrees.h"
#include <vector>
using namespace std;

vector<vector<int>> answer;
int group_ids[1000];
vector<int> groups[1000];

void connect(int a, int b){
    answer[a][b]=1;
    answer[b][a]=1;
}

int construct(vector<vector<int>> p) {
	int n = p.size();
	answer=vector<vector<int>>(n,vector<int>(n,0));
    for(int i=0;i<n;i++)
        group_ids[i]=-1;
    
    int curr_group=0;
    for(int i=0;i<n;i++){
        if(group_ids[i]!=-1)
            continue;
        group_ids[i]=curr_group;
        groups[curr_group].push_back(i);
        for(int j=i+1;j<n;j++){
            if(p[i][j]==1){
                group_ids[j]=curr_group;
                groups[curr_group].push_back(j);
            }
        }
        curr_group++;
    }
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(p[i][j]==1&&group_ids[i]!=group_ids[j])
                return 0;
            if(p[i][j]==0&&group_ids[i]==group_ids[j])
                return 0;
        }
    }
    
    for(int i=0;i<curr_group;i++){
        for(int j=0;j<groups[i].size()-1;j++){
            connect(groups[i][j],groups[i][j+1]);
        }
    }
    
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:45:22: 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<groups[i].size()-1;j++){
      |                     ~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 8 ms 1108 KB Output is correct
7 Correct 209 ms 22084 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 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 8 ms 1108 KB Output is correct
7 Correct 209 ms 22084 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 9 ms 1192 KB Output is correct
13 Correct 189 ms 24040 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 96 ms 14048 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 51 ms 6352 KB Output is correct
21 Correct 191 ms 24052 KB Output is correct
22 Correct 246 ms 23952 KB Output is correct
23 Correct 213 ms 23948 KB Output is correct
24 Correct 228 ms 24016 KB Output is correct
25 Correct 91 ms 14080 KB Output is correct
26 Correct 92 ms 14084 KB Output is correct
27 Correct 205 ms 23908 KB Output is correct
28 Correct 199 ms 24036 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 0 ms 312 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 1 ms 292 KB Too few ways to get from 0 to 1, should be 2 found 0
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 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 8 ms 1108 KB Output is correct
7 Correct 209 ms 22084 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 9 ms 1192 KB Output is correct
13 Correct 189 ms 24040 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 96 ms 14048 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 51 ms 6352 KB Output is correct
21 Correct 191 ms 24052 KB Output is correct
22 Correct 246 ms 23952 KB Output is correct
23 Correct 213 ms 23948 KB Output is correct
24 Correct 228 ms 24016 KB Output is correct
25 Correct 91 ms 14080 KB Output is correct
26 Correct 92 ms 14084 KB Output is correct
27 Correct 205 ms 23908 KB Output is correct
28 Correct 199 ms 24036 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 312 KB Output is correct
32 Incorrect 0 ms 212 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 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 8 ms 1108 KB Output is correct
7 Correct 209 ms 22084 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 9 ms 1192 KB Output is correct
13 Correct 189 ms 24040 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 852 KB Output is correct
17 Correct 96 ms 14048 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 51 ms 6352 KB Output is correct
21 Correct 191 ms 24052 KB Output is correct
22 Correct 246 ms 23952 KB Output is correct
23 Correct 213 ms 23948 KB Output is correct
24 Correct 228 ms 24016 KB Output is correct
25 Correct 91 ms 14080 KB Output is correct
26 Correct 92 ms 14084 KB Output is correct
27 Correct 205 ms 23908 KB Output is correct
28 Correct 199 ms 24036 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 312 KB Output is correct
32 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -