답안 #783207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783207 2023-07-14T17:46:02 Z teokakabadze 슈퍼트리 잇기 (IOI20_supertrees) C++17
0 / 100
154 ms 26964 KB
#include "supertrees.h"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

int a[1005][1005], i, j, f[1005], k, c[1005], d, l, cnt, pr[1005];
vector<int> s;

int construct(std::vector<std::vector<int>> p)
{
    int b;
	int n = p.size();
	std::vector<std::vector<int>> answer;
	for(i = 0; i < n; i++)
    for(j = 0; j < n; j++)
    {
        if(p[i][j] == 3) return 0;
        if(p[i][j] == 2) d = 1;
    }
	for(i = 0; i < n; i++)
    if(!f[i])
    {
        if(!c[i]) c[i] = ++k;
        for(j = 0; j < n; j++)
        if(!f[j] && p[i][j] == 1) c[j] = c[i], f[j] = 1;
    }
    for(i = 0; i < n; i++)
    for(j = 0; j < n; j++)
    {
        if(c[i] == c[j] && p[i][j] != 1) return 0;
        if(c[i] == c[j] && i != j) a[i][j] = a[j][i] = 1;
    }
    for(i = 0; i < n; i++)
    f[i] = 0;
    if(d)
    {
        for(i = 0; i < n; i++)
        if(!f[i])
        {
            f[i] = 1;
            vector<int> e, r;
            for(j = 0; j < n; j++)
            if(!f[j] && a[i][j]) { f[j] = 1, pr[j] = i; e.pb(j); }
            l = i, cnt = 0;
            r.pb(i);
            for(j = 0; j < n; j++)
            if(!f[j] && p[i][j] == 2)
            {
                r.pb(j);
                f[j] = 1, a[l][j] = a[j][l] = 1, l = j;
                for(b = 0; b < n; b++)
                if(!f[b] && a[j][b]) { f[b] = 1, pr[b] = j; e.pb(b); }
                cnt++;
            }
            if(cnt < 2) return 0;
            a[i][l] = a[l][i] = 1;
            for(auto x : r)
            for(auto y : r)
            if(x != y && p[x][y] != 2) return 0;
            for(auto x : r)
            for(auto y : e)
            {
                if(x != y && x != pr[y] && p[x][y] != 2) return 0;
                if(x != y && x == pr[y] && p[x][y] != 1) return 0;
            }
            for(auto x : e)
            for(auto y : e)
            {
                if(x != y && p[x] != p[y] && p[x][y] != 2) return 0;
                if(x != y && p[x] == p[y] && p[x][y] != 1) return 0;
            }
        }
    }
	for(i = 0; i < n; i++)
    {
        for(j = 0; j < n; j++)
        s.push_back(a[i][j]);
        answer.push_back(s);
        s.clear();
    }
	build(answer);
	return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 7 ms 1236 KB Output is correct
9 Correct 150 ms 23036 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 7 ms 2004 KB Output is correct
13 Correct 154 ms 26964 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 4 ms 1108 KB Output is correct
17 Correct 69 ms 11400 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Incorrect 1 ms 308 KB Answer gives possible 0 while actual possible 1
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 340 KB Too many ways to get from 1 to 4, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Too many ways to get from 0 to 2, should be 1 found no less than 2
4 Halted 0 ms 0 KB -