Submission #732772

# Submission time Handle Problem Language Result Execution time Memory
732772 2023-04-29T09:39:15 Z raul2008487 Connecting Supertrees (IOI20_supertrees) C++17
Compilation error
0 ms 0 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<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].F][j] && !p[pp[i].S][j]) || (!p[pp[i].F][j] && p[pp[i].S][j])){
	            return 0;
	        }
	    }
	}
	build(ans);
	return 1;
}

Compilation message

supertrees.cpp:7:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    7 | std::vector<pair<int,int>> pp;
      |             ^~~~
      |             std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from supertrees.h:1,
                 from supertrees.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
supertrees.cpp:7:25: error: template argument 1 is invalid
    7 | std::vector<pair<int,int>> pp;
      |                         ^~
supertrees.cpp:7:25: error: template argument 2 is invalid
supertrees.cpp: In function 'void dfs(int, int, int)':
supertrees.cpp:10:8: error: request for member 'push_back' in 'pp', which is of non-class type 'int'
   10 |     pp.push_back({i,j});
      |        ^~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:44:19: error: request for member 'size' in 'pp', which is of non-class type 'int'
   44 |  for(int i=0;i<pp.size();i++){
      |                   ^~~~
supertrees.cpp:46:18: error: invalid types 'int[int]' for array subscript
   46 |          if((p[pp[i].F][j] && !p[pp[i].S][j]) || (!p[pp[i].F][j] && p[pp[i].S][j])){
      |                  ^
supertrees.cpp:46:36: error: invalid types 'int[int]' for array subscript
   46 |          if((p[pp[i].F][j] && !p[pp[i].S][j]) || (!p[pp[i].F][j] && p[pp[i].S][j])){
      |                                    ^
supertrees.cpp:46:56: error: invalid types 'int[int]' for array subscript
   46 |          if((p[pp[i].F][j] && !p[pp[i].S][j]) || (!p[pp[i].F][j] && p[pp[i].S][j])){
      |                                                        ^
supertrees.cpp:46:73: error: invalid types 'int[int]' for array subscript
   46 |          if((p[pp[i].F][j] && !p[pp[i].S][j]) || (!p[pp[i].F][j] && p[pp[i].S][j])){
      |                                                                         ^