답안 #745859

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
745859 2023-05-21T08:51:53 Z JakobZorz 슈퍼트리 잇기 (IOI20_supertrees) C++14
19 / 100
223 ms 24140 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]==2){
                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]==2&&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++){
        if(groups[i].size()==1)
            continue;
        if(groups[i].size()==2)
            return 0;
        for(int j=0;j<groups[i].size()-1;j++){
            connect(groups[i][j],groups[i][j+1]);
        }
        connect(groups[i][0],groups[i].back());
    }
    
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:49:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for(int j=0;j<groups[i].size()-1;j++){
      |                     ~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 found 0
3 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 1 found 0
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 316 KB Output is correct
4 Correct 0 ms 316 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 8 ms 1236 KB Output is correct
9 Correct 223 ms 24028 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 9 ms 1196 KB Output is correct
13 Correct 189 ms 23920 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 836 KB Output is correct
17 Correct 97 ms 14084 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 49 ms 6276 KB Output is correct
22 Correct 196 ms 23968 KB Output is correct
23 Correct 187 ms 23948 KB Output is correct
24 Correct 197 ms 24016 KB Output is correct
25 Correct 85 ms 14028 KB Output is correct
26 Correct 90 ms 14084 KB Output is correct
27 Correct 193 ms 23952 KB Output is correct
28 Correct 203 ms 24140 KB Output is correct
29 Correct 91 ms 14092 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 Incorrect 0 ms 212 KB Too few ways to get from 1 to 2, should be 1 found 0
4 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 1 found 0
3 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 1 found 0
3 Halted 0 ms 0 KB -