Submission #825083

# Submission time Handle Problem Language Result Execution time Memory
825083 2023-08-14T14:17:49 Z Marco_Escandon Connecting Supertrees (IOI20_supertrees) C++17
Compilation error
0 ms 0 KB
#include <vector>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct st
{
    vector<ll> cad;
    ll findf(ll a)
    {
        if(a==cad[a])return a;
        else return cad[a]=findf(cad[a]);
    }
    void unionf(ll a, ll b){
        a=findf(a);
        b=findf(b);
        if(a!=b){
            cad[a]=b;
        }
    }
    st(ll n){
        cad.resize(2*n);
        for(int i=0; i<cad.size(); i++)
            cad[i]=i;
    }
};
int construct(std::vector<std::vector<int>> cad) {
	int n = cad.size();
	std::vector<std::vector<int>> answer(n,vector<int>(n,0LL));
	st asdfg(n+1);
	for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            if(cad[i][j]!=0&&i!=j)
                asdfg.unionf(i,j);
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            if(cad[i][j]==0&&asdfg.findf(i)==asdfg.findf(j)&&i!=j)
                return 0;
    st asd(n+1);
	for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            if(cad[i][j]==1&&i!=j)
                asd.unionf(i,j);
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            if(cad[i][j]==2&&asd.findf(i)==asd.findf(j)&&i!=j)
                return 0;
            if(asd.cad[i]==j&&i!=j)
            {
                answer[i][j]=1;
                answer[j][i]=1;
            }
            if(cad[i][j]==2&&asd.cad[i]==i&&asd.cad[j]==j)
            {
                answer[i][j]=1;
                answer[j][i]=1;
            }
        }
	build(answer);
	return 1;
}

Compilation message

supertrees.cpp: In constructor 'st::st(ll)':
supertrees.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int i=0; i<cad.size(); i++)
      |                      ~^~~~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:44:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   44 |     for(int i=0; i<n; i++)
      |     ^~~
supertrees.cpp:60:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   60 |  build(answer);
      |  ^~~~~
supertrees.cpp:60:2: error: 'build' was not declared in this scope