Submission #732774

# Submission time Handle Problem Language Result Execution time Memory
732774 2023-04-29T09:41:08 Z raul2008487 Connecting Supertrees (IOI20_supertrees) C++17
21 / 100
225 ms 28008 KB
#include "supertrees.h"
#include<algorithm>
#include <vector>
std::vector<std::vector<int>> ans;
std::vector<bool> vis;
std::vector<std::vector<int>> dp;
std::vector<std::pair<int,int>> pp;
void dfs(int i, int j, int n){
    vis[j]=1;
    pp.push_back({i,j});
    for(int k1=0;k1<n;k1++){
        if(dp[j][k1] && !vis[k1]){
            ans[j][k1]=ans[k1][j]=1;
            dfs(j,k1,n);
        }
    }
}	
int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	vis.resize(n,false);
	for(int i=0;i<n;i++){
	    std::vector<int> row;
	    row.resize(n,0);
	    ans.push_back(row);
	}
	for(int i=0;i<n;i++){
	    std::vector<int> d;
	    for(int j=0;j<n;j++){
	        d.push_back(p[i][j]);
	    }
	    dp.push_back(d);
	}
	for (int i = 0; i < n; i++) {
	    if(!vis[i]){
	        vis[i]=1;
	        for(int j=i+1;j<n;j++){
		        if(p[i][j] && !vis[j]){ 
		            ans[i][j]=ans[j][i]=1;
		            dfs(i,j,n);
		        }
		    }
	    }
	}
	for(int i=0;i<pp.size();i++){
	    for(int j=0;j<n;j++){
	        if((p[pp[i].first][j] && !p[pp[i].second][j]) || (!p[pp[i].first][j] && p[pp[i].second][j])){
	            return 0;
	        }
	    }
	}
	build(ans);
	return 1;
}

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for(int i=0;i<pp.size();i++){
      |              ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1340 KB Output is correct
7 Correct 181 ms 26024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1340 KB Output is correct
7 Correct 181 ms 26024 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 10 ms 1236 KB Output is correct
13 Correct 179 ms 25952 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 5 ms 980 KB Output is correct
17 Correct 97 ms 18072 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 47 ms 7148 KB Output is correct
21 Correct 181 ms 28004 KB Output is correct
22 Correct 216 ms 27940 KB Output is correct
23 Correct 203 ms 27980 KB Output is correct
24 Correct 214 ms 27928 KB Output is correct
25 Correct 81 ms 18024 KB Output is correct
26 Correct 77 ms 17948 KB Output is correct
27 Correct 196 ms 28008 KB Output is correct
28 Correct 225 ms 27876 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 Incorrect 0 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 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Too few ways to get from 0 to 1, should be 2 found 1
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1340 KB Output is correct
7 Correct 181 ms 26024 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 10 ms 1236 KB Output is correct
13 Correct 179 ms 25952 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 5 ms 980 KB Output is correct
17 Correct 97 ms 18072 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 47 ms 7148 KB Output is correct
21 Correct 181 ms 28004 KB Output is correct
22 Correct 216 ms 27940 KB Output is correct
23 Correct 203 ms 27980 KB Output is correct
24 Correct 214 ms 27928 KB Output is correct
25 Correct 81 ms 18024 KB Output is correct
26 Correct 77 ms 17948 KB Output is correct
27 Correct 196 ms 28008 KB Output is correct
28 Correct 225 ms 27876 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 Incorrect 0 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 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 8 ms 1340 KB Output is correct
7 Correct 181 ms 26024 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 10 ms 1236 KB Output is correct
13 Correct 179 ms 25952 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 292 KB Output is correct
16 Correct 5 ms 980 KB Output is correct
17 Correct 97 ms 18072 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 47 ms 7148 KB Output is correct
21 Correct 181 ms 28004 KB Output is correct
22 Correct 216 ms 27940 KB Output is correct
23 Correct 203 ms 27980 KB Output is correct
24 Correct 214 ms 27928 KB Output is correct
25 Correct 81 ms 18024 KB Output is correct
26 Correct 77 ms 17948 KB Output is correct
27 Correct 196 ms 28008 KB Output is correct
28 Correct 225 ms 27876 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 Incorrect 0 ms 212 KB Answer gives possible 1 while actual possible 0
33 Halted 0 ms 0 KB -