답안 #782335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
782335 2023-07-13T20:15:31 Z teokakabadze 슈퍼트리 잇기 (IOI20_supertrees) C++17
65 / 100
183 ms 27944 KB
#include "supertrees.h"
#include<bits/stdc++.h>
using namespace std;

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

int construct(std::vector<std::vector<int>> p)
{
	int n = p.size();
	std::vector<std::vector<int>> answer;
	for(i = 0; i < n; i++)
    {
        //cout << i << "A\n";
		if(!f[i])
        {
            a2 = a3 = 0;
            for(j = 0; j < n; j++)
            {
                if(p[i][j] == 2) a2 = 1;
                if(p[i][j] == 3) a3 = 1;
            }
            if(a2 && a3) return 0;
            if(a2) k = 2;
            else if(a3) k = 3;
            else k = 1;
            f[i] = 1;
            l = i, cnt = 0;
            for(int b = 0; b < n; b++)
            {
                if(i != b && !f[b] && p[i][b] == 1) f[b] = 1, a[i][b] = a[b][i] = 1;
                if(f[b] == 2 && p[i][b]) return 0;
            }
            for(j = 0; j < n; j++)
            if(!f[j] && p[l][j] == k)
            {
                f[j] = 1;
                a[l][j] = a[j][l] = 1;
                for(int b = 0; b < n; b++)
                {
                    if(j != b && !f[b] && p[j][b] == 1) f[b] = 1, a[j][b] = a[b][j] = 1;
                    if(f[b] == 2 && p[j][b]) return 0;
                }
                l = j;
                cnt++;
                if(cnt == 2) c = j;
            }
            if(k == 2 && cnt < 2) return 0;
            if(k == 2) a[l][i] = a[i][l] = 1;
            if(k == 3 && cnt < 3) return 0;
            if(k == 3) a[l][i] = a[i][l] = a[i][c] = a[c][i] = 1;
            for(j = 0; j < n; j++)
            if(f[j] == 1) f[j] = 2;
        }
	}
	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 0 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 7 ms 1992 KB Output is correct
7 Correct 159 ms 27900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 7 ms 1992 KB Output is correct
7 Correct 159 ms 27900 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1216 KB Output is correct
13 Correct 157 ms 23884 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 1108 KB Output is correct
17 Correct 64 ms 12080 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
20 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 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 244 KB Output is correct
8 Correct 7 ms 1236 KB Output is correct
9 Correct 183 ms 23932 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 7 ms 1988 KB Output is correct
13 Correct 155 ms 27944 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 980 KB Output is correct
17 Correct 65 ms 12124 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 40 ms 7996 KB Output is correct
22 Correct 156 ms 27912 KB Output is correct
23 Correct 176 ms 27864 KB Output is correct
24 Correct 158 ms 27916 KB Output is correct
25 Correct 63 ms 10368 KB Output is correct
26 Correct 62 ms 11212 KB Output is correct
27 Correct 157 ms 27784 KB Output is correct
28 Correct 159 ms 27924 KB Output is correct
29 Correct 68 ms 10368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 39 ms 8060 KB Output is correct
5 Correct 158 ms 27900 KB Output is correct
6 Correct 159 ms 27388 KB Output is correct
7 Correct 157 ms 27908 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 39 ms 8048 KB Output is correct
10 Correct 162 ms 27876 KB Output is correct
11 Correct 155 ms 27852 KB Output is correct
12 Correct 158 ms 27924 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 39 ms 8052 KB Output is correct
17 Correct 157 ms 27920 KB Output is correct
18 Correct 172 ms 27528 KB Output is correct
19 Correct 154 ms 27548 KB Output is correct
20 Correct 172 ms 24240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 7 ms 1992 KB Output is correct
7 Correct 159 ms 27900 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1216 KB Output is correct
13 Correct 157 ms 23884 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 1108 KB Output is correct
17 Correct 64 ms 12080 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 7 ms 1992 KB Output is correct
7 Correct 159 ms 27900 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 7 ms 1216 KB Output is correct
13 Correct 157 ms 23884 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 1108 KB Output is correct
17 Correct 64 ms 12080 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
20 Halted 0 ms 0 KB -