답안 #825087

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
825087 2023-08-14T14:19:19 Z Marco_Escandon 슈퍼트리 잇기 (IOI20_supertrees) C++17
컴파일 오류
0 ms 0 KB
#include <vector>
#include<bits/stdc++.h>
using namespace std;
struct st
{
    vector<int> cad;
    int findf(int a)
    {
        if(a==cad[a])return a;
        else return cad[a]=findf(cad[a]);
    }
    void unionf(int a, int b){
        a=findf(a);
        b=findf(b);
        if(a!=b){
            cad[a]=b;
        }
    }
    st(int 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(int)':
supertrees.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int i=0; i<cad.size(); i++)
      |                      ~^~~~~~~~~~~
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:43:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   43 |     for(int i=0; i<n; i++)
      |     ^~~
supertrees.cpp:59:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   59 |  build(answer);
      |  ^~~~~
supertrees.cpp:59:2: error: 'build' was not declared in this scope