답안 #803540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
803540 2023-08-03T04:48:25 Z Warinchai 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
181 ms 27972 KB
#include "supertrees.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
int sz;
vector<vector<int> >v;
vector<vector<int> >ans;
int pr[1005];
int fp(int a){
    if(pr[a]==a){
        return a;
    }
    return pr[a]=fp(pr[a]);
}
void un(int a,int b){
    if(fp(a)!=fp(b)){
        ans[a][b]=1;
        ans[b][a]=1;
        pr[fp(b)]=fp(a);
    }
}
void build_1(){
    for(int i=0;i<sz;i++){
        for(int j=i+1;j<sz;j++){
            if(v[i][j]==1){
                un(i,j);
            }
        }
    }
}
bool check_0(){
    for(int i=0;i<sz;i++){
        for(int j=i+1;j<sz;j++){
            if(v[i][j]==0&&fp(i)==fp(j))return 0;
        }
    }
    return 1;
}
int construct(vector<vector<int> > p) {
    //cout<<"work"<<endl;
	sz = p.size();
    bool check=0;
    v.resize(sz);
    for(int i=0;i<sz;i++){
        v[i].resize(sz);
    }
    for(int i=0;i<sz;i++){
        for(int j=0;j<sz;j++){
            //cout<<"i j "<<i<<" "<<j<<endl;
            v[i][j]=p[i][j];
            if(p[i][j]!=p[j][i]||(i==j&&p[i][j]!=1)){
                check=1;
                //cout<<"break"<<endl;
                break;
            }
        }
    }
    //cout<<"work"<<endl;
    if(check){
        return 0;
    }
    //cout<<"work"<<endl;
    ans.resize(sz);
    for(int i=0;i<sz;i++){
        ans[i].resize(sz);
    }
    for(int i=0;i<sz;i++){
        pr[i]=i;
    }
    //cout<<"work"<<endl;
    build_1();
    if(!check_0()){
        return 0;
    }else{
        build(ans);
    }
	//cout<<"ans:"<<endl;
	return 1;
}
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 8 ms 1356 KB Output is correct
7 Correct 155 ms 25904 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 8 ms 1356 KB Output is correct
7 Correct 155 ms 25904 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 6 ms 1364 KB Output is correct
13 Correct 171 ms 25900 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 76 ms 16008 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 41 ms 7260 KB Output is correct
21 Correct 155 ms 27972 KB Output is correct
22 Correct 155 ms 27956 KB Output is correct
23 Correct 181 ms 27912 KB Output is correct
24 Correct 167 ms 27960 KB Output is correct
25 Correct 67 ms 17996 KB Output is correct
26 Correct 81 ms 18040 KB Output is correct
27 Correct 158 ms 27908 KB Output is correct
28 Correct 153 ms 27852 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 Incorrect 1 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 212 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 8 ms 1356 KB Output is correct
7 Correct 155 ms 25904 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 6 ms 1364 KB Output is correct
13 Correct 171 ms 25900 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 76 ms 16008 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 41 ms 7260 KB Output is correct
21 Correct 155 ms 27972 KB Output is correct
22 Correct 155 ms 27956 KB Output is correct
23 Correct 181 ms 27912 KB Output is correct
24 Correct 167 ms 27960 KB Output is correct
25 Correct 67 ms 17996 KB Output is correct
26 Correct 81 ms 18040 KB Output is correct
27 Correct 158 ms 27908 KB Output is correct
28 Correct 153 ms 27852 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 212 KB Output is correct
32 Incorrect 1 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 8 ms 1356 KB Output is correct
7 Correct 155 ms 25904 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 6 ms 1364 KB Output is correct
13 Correct 171 ms 25900 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 76 ms 16008 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 41 ms 7260 KB Output is correct
21 Correct 155 ms 27972 KB Output is correct
22 Correct 155 ms 27956 KB Output is correct
23 Correct 181 ms 27912 KB Output is correct
24 Correct 167 ms 27960 KB Output is correct
25 Correct 67 ms 17996 KB Output is correct
26 Correct 81 ms 18040 KB Output is correct
27 Correct 158 ms 27908 KB Output is correct
28 Correct 153 ms 27852 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 212 KB Output is correct
32 Incorrect 1 ms 212 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -