Submission #794792

# Submission time Handle Problem Language Result Execution time Memory
794792 2023-07-26T22:49:57 Z vjudge1 Connecting Supertrees (IOI20_supertrees) C++17
56 / 100
182 ms 26920 KB
#include "supertrees.h" 
#include <bits/stdc++.h>
using namespace std;

int comp[1010], tree[1010], comps, sz[1010], roots[1010][1010];
int construct(std::vector<std::vector<int>> p) {
    for(auto i:p)
        for(auto j: i)
            if(j>2)
                return 0;
    int n = p.size();
	std::vector<std::vector<int>> answer(n,vector<int>(n,0));
    for(int i = 0; i < n; i++) {
        bool determined=0;
        bitset<1024>notree;
        bitset<1024>notcomp;
        for(int j = 0; j < i; j++) {
            if(determined) {
                if(!p[i][j]){
                    if(comp[i]==comp[j]) 
                        return 0;
               } else if(comp[i]!=comp[j])
                    return 0;
                else if(p[i][j]==1&&tree[i]!=tree[j])
                    return 0;
            } else {
                if(!p[i][j])
                    notcomp[comp[j]]=1;
                else if(p[i][j]-1) {
                    if(notcomp[comp[j]]) return 0;
                    notcomp.reset();
                    notcomp.flip();
                    notcomp[comp[j]] = 0;
                    notree[tree[j]] = 1;
                    comp[i] = comp[j];
                } else {
                    if(notcomp[comp[j]]) return 0;
                    if(notree[tree[j]]) return 0;
                    answer[i][j] = answer[j][i] = 1;
                    tree[i] = tree[j];
                    comp[i] = comp[j];
                    notcomp.reset();
                    notcomp.flip();
                    notcomp[comp[j]] = 0;
                    notree.reset();
                    notree.flip();
                    notree[tree[j]] = 0;
                    determined = 1;
                }
            }
        }
        if(!comp[i]) {
            comp[i] = ++comps;
            roots[comp[i]][1] = i;
            sz[comps] = tree[i] = 1;
        } else if(!tree[i]) {
            tree[i] = ++sz[comp[i]];
            roots[comp[i]][sz[comp[i]]] = i;
        }
        if(notcomp[comp[i]]||notree[tree[i]]) return 0;
    } 
    for(int i = 1; i <= comps; i++) {
        if(sz[i]==1) continue;
        for(int j = 1; j < sz[i]; j++) {
            answer[roots[i][j]][roots[i][j+1]] = answer[roots[i][j+1]][roots[i][j]] = 1;
        }
        answer[roots[i][1]][roots[i][sz[i]]] = answer[roots[i][sz[i]]][roots[i][1]] = 1;
    }
	build(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 152 ms 23016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 152 ms 23016 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 7 ms 1988 KB Output is correct
13 Correct 156 ms 26904 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 828 KB Output is correct
17 Correct 66 ms 13672 KB Output is correct
18 Correct 0 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 41 ms 6464 KB Output is correct
21 Correct 153 ms 23060 KB Output is correct
22 Correct 155 ms 24592 KB Output is correct
23 Correct 161 ms 23056 KB Output is correct
24 Correct 158 ms 26800 KB Output is correct
25 Correct 67 ms 13728 KB Output is correct
26 Correct 69 ms 14760 KB Output is correct
27 Correct 156 ms 23052 KB Output is correct
28 Correct 155 ms 26828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 304 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 39 ms 6452 KB Output is correct
5 Correct 155 ms 23004 KB Output is correct
6 Correct 162 ms 24656 KB Output is correct
7 Correct 156 ms 23004 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 38 ms 6548 KB Output is correct
10 Correct 160 ms 23008 KB Output is correct
11 Correct 153 ms 23764 KB Output is correct
12 Correct 182 ms 23116 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 43 ms 6524 KB Output is correct
17 Correct 163 ms 23044 KB Output is correct
18 Correct 155 ms 23104 KB Output is correct
19 Correct 158 ms 23244 KB Output is correct
20 Correct 160 ms 26920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 152 ms 23016 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 7 ms 1988 KB Output is correct
13 Correct 156 ms 26904 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 828 KB Output is correct
17 Correct 66 ms 13672 KB Output is correct
18 Correct 0 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 41 ms 6464 KB Output is correct
21 Correct 153 ms 23060 KB Output is correct
22 Correct 155 ms 24592 KB Output is correct
23 Correct 161 ms 23056 KB Output is correct
24 Correct 158 ms 26800 KB Output is correct
25 Correct 67 ms 13728 KB Output is correct
26 Correct 69 ms 14760 KB Output is correct
27 Correct 156 ms 23052 KB Output is correct
28 Correct 155 ms 26828 KB Output is correct
29 Correct 1 ms 304 KB Output is correct
30 Correct 1 ms 304 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 152 ms 23016 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 7 ms 1988 KB Output is correct
13 Correct 156 ms 26904 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 828 KB Output is correct
17 Correct 66 ms 13672 KB Output is correct
18 Correct 0 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 41 ms 6464 KB Output is correct
21 Correct 153 ms 23060 KB Output is correct
22 Correct 155 ms 24592 KB Output is correct
23 Correct 161 ms 23056 KB Output is correct
24 Correct 158 ms 26800 KB Output is correct
25 Correct 67 ms 13728 KB Output is correct
26 Correct 69 ms 14760 KB Output is correct
27 Correct 156 ms 23052 KB Output is correct
28 Correct 155 ms 26828 KB Output is correct
29 Correct 1 ms 304 KB Output is correct
30 Correct 1 ms 304 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 -