Submission #730126

# Submission time Handle Problem Language Result Execution time Memory
730126 2023-04-25T10:02:59 Z lucri Connecting Supertrees (IOI20_supertrees) C++17
40 / 100
232 ms 24076 KB
#include "supertrees.h"
#include <vector>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <string>
int t[1010];
bool e[1010],dc[1010],ca[1010];
int tata(int nod)
{
    if(t[nod]==nod) return nod;
    return t[nod]=tata(t[nod]);
}
int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	std::vector<std::vector<int>> answer;
	answer.resize(n);
	for (int i = 0; i < n; i++) {
		t[i]=i;
		dc[i]=false;
		e[i]=true;
		answer[i].resize(n);
	}
	for(int i=0;i<n;++i)
    {
        if(p[i][i]!=1)
            return 0;
        for(int j=0;j<n;++j)
            if(p[i][j]==1)
            {
                if(tata(i)!=tata(j))
                {
                    answer[i][j]=answer[j][i]=1;
                    t[t[i]]=t[j];
                }
            }
    }
	for(int i=0;i<n;++i)
    {
        for(int j=0;j<n;++j)
            if(p[i][j]==0)
            {
                if(tata(i)==tata(j))
                    return 0;
            }
    }
    for(int i=0;i<n;++i)
        if(e[i])
            for(int j=i+1;j<n;++j)
            {
                if(e[j])
                    if(tata(i)==tata(j))
                    {
                        e[j]=false;
                        for(int q=0;q<n;++q)
                            if(p[i][q]!=p[j][q])
                                return 0;
                    }
            }
    int ciclu[1010];
    for(int i=0;i<n;++i)
    {
        for(int q=0;q<n;++q)
            ca[q]=false;
        ca[i]=true;
        if(e[i]==true&&dc[i]==false)
        {
            ciclu[0]=1;
            ciclu[1]=i;
            for(int j=0;j<n;++j)
                if(e[j]&&p[i][j]==2)
                {
                    ciclu[++ciclu[0]]=j;
                    ca[j]=true;
                }
            if(ciclu[0]>2)
            {
                for(int ii=1;ii<ciclu[0];++ii)
                {
                    dc[ciclu[ii]]=true;
                    answer[ciclu[ii]][ciclu[ii+1]]=answer[ciclu[ii+1]][ciclu[ii]]=1;
                    for(int q=0;q<n;++q)
                    {
                        if(q!=ciclu[ii])
                            if(ca[q]==false&&p[ciclu[ii]][q]==2||ca[q]==true&&p[ciclu[ii]][q]!=2)
                                return 0;
                    }
                }
                answer[ciclu[ciclu[0]]][ciclu[1]]=answer[ciclu[1]][ciclu[ciclu[0]]]=1;
            }
            else if(ciclu[0]==2)
                return 0;
        }
    }
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:85:44: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   85 |                             if(ca[q]==false&&p[ciclu[ii]][q]==2||ca[q]==true&&p[ciclu[ii]][q]!=2)
      |                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 272 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 9 ms 1108 KB Output is correct
7 Correct 198 ms 22052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 272 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 9 ms 1108 KB Output is correct
7 Correct 198 ms 22052 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 13 ms 1092 KB Output is correct
13 Correct 207 ms 21980 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 5 ms 724 KB Output is correct
17 Correct 87 ms 12024 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 57 ms 5744 KB Output is correct
21 Correct 232 ms 22100 KB Output is correct
22 Correct 212 ms 21936 KB Output is correct
23 Correct 204 ms 22028 KB Output is correct
24 Correct 191 ms 21964 KB Output is correct
25 Correct 72 ms 12032 KB Output is correct
26 Correct 65 ms 12108 KB Output is correct
27 Correct 194 ms 21968 KB Output is correct
28 Correct 171 ms 21964 KB Output is correct
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 8 ms 1236 KB Output is correct
9 Correct 178 ms 22372 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 8 ms 1236 KB Output is correct
13 Correct 177 ms 22352 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 4 ms 816 KB Output is correct
17 Correct 85 ms 12300 KB Output is correct
18 Correct 1 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 51 ms 5956 KB Output is correct
22 Correct 179 ms 22448 KB Output is correct
23 Correct 184 ms 22348 KB Output is correct
24 Correct 186 ms 22368 KB Output is correct
25 Correct 71 ms 13340 KB Output is correct
26 Correct 76 ms 13372 KB Output is correct
27 Correct 169 ms 23924 KB Output is correct
28 Correct 182 ms 24076 KB Output is correct
29 Correct 70 ms 14068 KB Output is correct
# Verdict Execution time Memory 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 47 ms 6004 KB Output is correct
5 Correct 181 ms 22184 KB Output is correct
6 Correct 172 ms 22276 KB Output is correct
7 Correct 178 ms 22264 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 45 ms 5900 KB Output is correct
10 Correct 180 ms 22392 KB Output is correct
11 Correct 176 ms 22364 KB Output is correct
12 Correct 189 ms 22544 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 272 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 9 ms 1108 KB Output is correct
7 Correct 198 ms 22052 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 13 ms 1092 KB Output is correct
13 Correct 207 ms 21980 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 5 ms 724 KB Output is correct
17 Correct 87 ms 12024 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 57 ms 5744 KB Output is correct
21 Correct 232 ms 22100 KB Output is correct
22 Correct 212 ms 21936 KB Output is correct
23 Correct 204 ms 22028 KB Output is correct
24 Correct 191 ms 21964 KB Output is correct
25 Correct 72 ms 12032 KB Output is correct
26 Correct 65 ms 12108 KB Output is correct
27 Correct 194 ms 21968 KB Output is correct
28 Correct 171 ms 21964 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 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 8 ms 1236 KB Output is correct
37 Correct 178 ms 22372 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 296 KB Output is correct
40 Correct 8 ms 1236 KB Output is correct
41 Correct 177 ms 22352 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 296 KB Output is correct
44 Correct 4 ms 816 KB Output is correct
45 Correct 85 ms 12300 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 51 ms 5956 KB Output is correct
50 Correct 179 ms 22448 KB Output is correct
51 Correct 184 ms 22348 KB Output is correct
52 Correct 186 ms 22368 KB Output is correct
53 Correct 71 ms 13340 KB Output is correct
54 Correct 76 ms 13372 KB Output is correct
55 Correct 169 ms 23924 KB Output is correct
56 Correct 182 ms 24076 KB Output is correct
57 Correct 70 ms 14068 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 3 ms 788 KB Output is correct
61 Correct 80 ms 14080 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 276 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Incorrect 19 ms 3764 KB Answer gives possible 0 while actual possible 1
66 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 272 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 9 ms 1108 KB Output is correct
7 Correct 198 ms 22052 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 13 ms 1092 KB Output is correct
13 Correct 207 ms 21980 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 5 ms 724 KB Output is correct
17 Correct 87 ms 12024 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 57 ms 5744 KB Output is correct
21 Correct 232 ms 22100 KB Output is correct
22 Correct 212 ms 21936 KB Output is correct
23 Correct 204 ms 22028 KB Output is correct
24 Correct 191 ms 21964 KB Output is correct
25 Correct 72 ms 12032 KB Output is correct
26 Correct 65 ms 12108 KB Output is correct
27 Correct 194 ms 21968 KB Output is correct
28 Correct 171 ms 21964 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 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 8 ms 1236 KB Output is correct
37 Correct 178 ms 22372 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 296 KB Output is correct
40 Correct 8 ms 1236 KB Output is correct
41 Correct 177 ms 22352 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 296 KB Output is correct
44 Correct 4 ms 816 KB Output is correct
45 Correct 85 ms 12300 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 51 ms 5956 KB Output is correct
50 Correct 179 ms 22448 KB Output is correct
51 Correct 184 ms 22348 KB Output is correct
52 Correct 186 ms 22368 KB Output is correct
53 Correct 71 ms 13340 KB Output is correct
54 Correct 76 ms 13372 KB Output is correct
55 Correct 169 ms 23924 KB Output is correct
56 Correct 182 ms 24076 KB Output is correct
57 Correct 70 ms 14068 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 0 ms 212 KB Output is correct
60 Correct 1 ms 212 KB Output is correct
61 Correct 47 ms 6004 KB Output is correct
62 Correct 181 ms 22184 KB Output is correct
63 Correct 172 ms 22276 KB Output is correct
64 Correct 178 ms 22264 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 45 ms 5900 KB Output is correct
67 Correct 180 ms 22392 KB Output is correct
68 Correct 176 ms 22364 KB Output is correct
69 Correct 189 ms 22544 KB Output is correct
70 Correct 1 ms 212 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Incorrect 0 ms 212 KB Answer gives possible 0 while actual possible 1
73 Halted 0 ms 0 KB -