답안 #338096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338096 2020-12-22T13:18:59 Z sealnot123 슈퍼트리 잇기 (IOI20_supertrees) C++14
21 / 100
265 ms 24172 KB
/*
	Author: AquaBlaze
    Keqing best girl :)
    Nephren will always be in my heart
*/
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define ROF(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())
#define pc(x) putchar(x)
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long i64;
typedef tuple<int,int,int> iii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#include "supertrees.h"

//#include "grader.cpp"

queue<int> bfs;

int construct(vvi p) {
	int n = p.size();
    
    // fundamental check
    int visit[n] = {};
    vi group;
    FOR(i, 0, n-1){
        if(!visit[i]){
            bfs.push(i);
            group.pb(i);
            visit[i] = 1;
            while(!bfs.empty()){
                int u = bfs.front();
                group.pb(u);
                bfs.pop();
                FOR(j, 0, n-1){
                    if(p[u][j] && !visit[j]){
                        visit[j] = 1;
                        bfs.push(j);
                    }
                }
            }
            int x = SZ(group);
            FOR(j, 0, x-1){
                FOR(k, j+1, x-1){
                    if(!p[group[j]][group[k]]) return 0;
                }
            }
            group.clear();
        }
    }
    vvi answer(n, vi(n));
    int mx = 1;
    FOR(i, 0, n-1) FOR(j, 0, n-1) mx = max(mx, p[i][j]);
    if(mx == 1){
        int mark[n] = {};
        FOR(i, 0, n-1){
            if(mark[i]) continue;
            mark[i] = 1;
            FOR(j, 0, n-1){
                if(i == j) continue;
                if(p[i][j] && mark[j]) return 0;
                if(p[i][j]) answer[i][j] = answer[j][i] = 1, mark[j] = 1;
            }
        }
        build(answer);
        return 1;
    }
	build(answer);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 11 ms 1260 KB Output is correct
7 Correct 255 ms 22124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 11 ms 1260 KB Output is correct
7 Correct 255 ms 22124 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 11 ms 1152 KB Output is correct
13 Correct 252 ms 22124 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 5 ms 620 KB Output is correct
17 Correct 122 ms 8172 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 64 ms 6252 KB Output is correct
21 Correct 265 ms 24044 KB Output is correct
22 Correct 257 ms 24172 KB Output is correct
23 Correct 264 ms 24044 KB Output is correct
24 Correct 251 ms 24044 KB Output is correct
25 Correct 110 ms 10220 KB Output is correct
26 Correct 108 ms 10220 KB Output is correct
27 Correct 258 ms 24044 KB Output is correct
28 Correct 254 ms 24172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 0 ms 364 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 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 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 11 ms 1260 KB Output is correct
7 Correct 255 ms 22124 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 11 ms 1152 KB Output is correct
13 Correct 252 ms 22124 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 5 ms 620 KB Output is correct
17 Correct 122 ms 8172 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 64 ms 6252 KB Output is correct
21 Correct 265 ms 24044 KB Output is correct
22 Correct 257 ms 24172 KB Output is correct
23 Correct 264 ms 24044 KB Output is correct
24 Correct 251 ms 24044 KB Output is correct
25 Correct 110 ms 10220 KB Output is correct
26 Correct 108 ms 10220 KB Output is correct
27 Correct 258 ms 24044 KB Output is correct
28 Correct 254 ms 24172 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Incorrect 0 ms 364 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 11 ms 1260 KB Output is correct
7 Correct 255 ms 22124 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 11 ms 1152 KB Output is correct
13 Correct 252 ms 22124 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 0 ms 364 KB Output is correct
16 Correct 5 ms 620 KB Output is correct
17 Correct 122 ms 8172 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 64 ms 6252 KB Output is correct
21 Correct 265 ms 24044 KB Output is correct
22 Correct 257 ms 24172 KB Output is correct
23 Correct 264 ms 24044 KB Output is correct
24 Correct 251 ms 24044 KB Output is correct
25 Correct 110 ms 10220 KB Output is correct
26 Correct 108 ms 10220 KB Output is correct
27 Correct 258 ms 24044 KB Output is correct
28 Correct 254 ms 24172 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Incorrect 0 ms 364 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -