Submission #519805

# Submission time Handle Problem Language Result Execution time Memory
519805 2022-01-27T11:08:48 Z A_D Connecting Supertrees (IOI20_supertrees) C++14
21 / 100
204 ms 28184 KB
#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;
const int N=1e3+110;
vector<int> g1[N];
vector<int> g2[N];
bool vis[N];
vector<vector<int>> answer;
vector<int> vec;
void dfs1(int u)
{
    vis[u]=1;
    for(auto x:g1[u]){
        if(vis[x])continue;
        answer[u][x]=1;
        answer[x][u]=1;
        dfs1(x);
    }
}

int construct(vector<vector<int>> p){
	int n = p.size();
	vector<int> tmp(n);
	for(int i=0;i<n;i++){
        answer.push_back(tmp);
	}

	for(int i=0;i<n;i++){
        g1[i].push_back(i);
        g2[i].push_back(i);
        for(int j=i;j<n;j++){
            int v=p[i][j];
            if(v==3||(i==j&&v!=1)||p[i][j]!=p[j][i]){
                return 0;
            }
            if(v==2){
                g2[i].push_back(j);
                g2[j].push_back(i);

            }
            if(v==1&&i!=j){
                g1[i].push_back(j);
                g1[j].push_back(i);
            }
        }
	}
	for(int i=0;i<n;i++){
        sort(g1[i].begin(),g1[i].end());
        sort(g2[i].begin(),g2[i].end());
	}
	for(int i=0;i<n;i++){
        if(vis[i]==0){
            dfs1(i);
            int sz=g1[i].size();
            for(int j=0;j<sz-1;j++){
                if(g1[g1[i][j]]!=g1[g1[i][j+1]])return 0;
            }
        }
	}
	memset(vis,0,sizeof(vis));
	for(int i=0;i<n;i++){
        if(vis[i]==0){
            int sz=g2[i].size();
            for(int j=0;j<sz-1;j++){
                vis[g2[i][j]]=1;vis[g2[i][j+1]]=1;
                answer[vis[g2[i][j]]][vis[g2[i][j+1]]]=1;
                answer[vis[g2[i][j+1]]][vis[g2[i][j]]]=1;
                if(g2[g2[i][j]]!=g2[g2[i][j+1]])return 0;
            }
        }
	}





	build(answer);
	return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 10 ms 1516 KB Output is correct
7 Correct 195 ms 28184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 10 ms 1516 KB Output is correct
7 Correct 195 ms 28184 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 8 ms 1244 KB Output is correct
13 Correct 178 ms 24112 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 5 ms 1000 KB Output is correct
17 Correct 125 ms 16992 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 54 ms 6272 KB Output is correct
21 Correct 175 ms 24620 KB Output is correct
22 Correct 169 ms 24096 KB Output is correct
23 Correct 195 ms 26108 KB Output is correct
24 Correct 167 ms 24132 KB Output is correct
25 Correct 88 ms 14624 KB Output is correct
26 Correct 71 ms 14112 KB Output is correct
27 Correct 204 ms 27172 KB Output is correct
28 Correct 175 ms 24116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 1 ms 332 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 332 KB Output is correct
2 Incorrect 1 ms 332 KB b[1][1] is not 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 10 ms 1516 KB Output is correct
7 Correct 195 ms 28184 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 8 ms 1244 KB Output is correct
13 Correct 178 ms 24112 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 5 ms 1000 KB Output is correct
17 Correct 125 ms 16992 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 54 ms 6272 KB Output is correct
21 Correct 175 ms 24620 KB Output is correct
22 Correct 169 ms 24096 KB Output is correct
23 Correct 195 ms 26108 KB Output is correct
24 Correct 167 ms 24132 KB Output is correct
25 Correct 88 ms 14624 KB Output is correct
26 Correct 71 ms 14112 KB Output is correct
27 Correct 204 ms 27172 KB Output is correct
28 Correct 175 ms 24116 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Incorrect 1 ms 332 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 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 10 ms 1516 KB Output is correct
7 Correct 195 ms 28184 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 352 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 8 ms 1244 KB Output is correct
13 Correct 178 ms 24112 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 5 ms 1000 KB Output is correct
17 Correct 125 ms 16992 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 54 ms 6272 KB Output is correct
21 Correct 175 ms 24620 KB Output is correct
22 Correct 169 ms 24096 KB Output is correct
23 Correct 195 ms 26108 KB Output is correct
24 Correct 167 ms 24132 KB Output is correct
25 Correct 88 ms 14624 KB Output is correct
26 Correct 71 ms 14112 KB Output is correct
27 Correct 204 ms 27172 KB Output is correct
28 Correct 175 ms 24116 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Incorrect 1 ms 332 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -