Submission #432099

# Submission time Handle Problem Language Result Execution time Memory
432099 2021-06-17T20:51:53 Z Platanito_Frito Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
258 ms 22084 KB
#include<bits/stdc++.h>
#include "supertrees.h"
#include <vector>
#define pb push_back

using namespace std;

void dfs(int a, int cl, vector<bool>& mk, vector<int>& scc, vector<int> v[], vector<vector<int>>& answer){
    mk[a]=true;
    scc[a]=cl;
    for(auto b:v[a]){
        if(!mk[b]){ answer[a][b]=answer[b][a]=1; dfs(b, cl, mk, scc, v, answer); }
    }
}

int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
    vector<int> scc(n), v[n];
    vector<bool> mk(n, 0);
    vector<vector<int>> answer;

	for (int i = 0; i < n; i++) {
		std::vector<int> row;
		row.resize(n);
		answer.push_back(row);
	}

	bool ans=true;

    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            if(i==j) continue;
            if(p[i][j]==1&&!mk[j]){
                v[i].pb(j);
                v[j].pb(i);
                mk[j]=true;
            }
        }
    }

    for(int i=0; i<n; i++) mk[i]=0;

    int id=0;
    for(int i=0; i<n; i++){
        if(!mk[i]){ dfs(i, id, mk, scc, v, answer); id++; }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if((p[i][j]==1&&scc[i]!=scc[j])||(p[i][j]==0&&scc[i]==scc[j])) ans=false;
        }
    }

	if(ans) build(answer);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 11 ms 1184 KB Output is correct
7 Correct 225 ms 22084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 11 ms 1184 KB Output is correct
7 Correct 225 ms 22084 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 9 ms 1152 KB Output is correct
13 Correct 219 ms 22008 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 5 ms 716 KB Output is correct
17 Correct 106 ms 12156 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 78 ms 5748 KB Output is correct
21 Correct 226 ms 22020 KB Output is correct
22 Correct 223 ms 21984 KB Output is correct
23 Correct 229 ms 22084 KB Output is correct
24 Correct 226 ms 21956 KB Output is correct
25 Correct 94 ms 12100 KB Output is correct
26 Correct 93 ms 12156 KB Output is correct
27 Correct 229 ms 22020 KB Output is correct
28 Correct 258 ms 21956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Answer gives possible 1 while actual possible 0
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Too few ways to get from 0 to 1, should be 2 found 0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 11 ms 1184 KB Output is correct
7 Correct 225 ms 22084 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 9 ms 1152 KB Output is correct
13 Correct 219 ms 22008 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 5 ms 716 KB Output is correct
17 Correct 106 ms 12156 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 78 ms 5748 KB Output is correct
21 Correct 226 ms 22020 KB Output is correct
22 Correct 223 ms 21984 KB Output is correct
23 Correct 229 ms 22084 KB Output is correct
24 Correct 226 ms 21956 KB Output is correct
25 Correct 94 ms 12100 KB Output is correct
26 Correct 93 ms 12156 KB Output is correct
27 Correct 229 ms 22020 KB Output is correct
28 Correct 258 ms 21956 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Incorrect 0 ms 204 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 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 11 ms 1184 KB Output is correct
7 Correct 225 ms 22084 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 9 ms 1152 KB Output is correct
13 Correct 219 ms 22008 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 5 ms 716 KB Output is correct
17 Correct 106 ms 12156 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 78 ms 5748 KB Output is correct
21 Correct 226 ms 22020 KB Output is correct
22 Correct 223 ms 21984 KB Output is correct
23 Correct 229 ms 22084 KB Output is correct
24 Correct 226 ms 21956 KB Output is correct
25 Correct 94 ms 12100 KB Output is correct
26 Correct 93 ms 12156 KB Output is correct
27 Correct 229 ms 22020 KB Output is correct
28 Correct 258 ms 21956 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Incorrect 0 ms 204 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -