제출 #478393

#제출 시각아이디문제언어결과실행 시간메모리
478393ponytail슈퍼트리 잇기 (IOI20_supertrees)C++17
컴파일 에러
0 ms0 KiB
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
int construct(std::vector<std::vector<int>> p) {
	int n = p.size();
	std::vector<std::vector<int>> answer;
	for (int i = 0; i < n; i++) {
		std::vector<int> row;
		row.resize(n);
		answer.push_back(row);
	}
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(p[i][j] == 3) return 0;
        }
    }
    for(int i=0; i<n; i++) {
        dsu[i] = dsu2[i] = i;
    }
    vector<vector<int> > v(n);
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(p[i][j] == 1) {
                if(set_of(i) != set_of(j)) {
                    union_(i, j);
                    answer[i][j] = answer[j][i] = 1;
                }
            }
        }
    }
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(p[i][j] != 1 && set_of(i) == set_of(j)) {
                return 0;
            }
        }
    }
    vector<int> fin;
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(p[i][j] == 2 && set_of(i) != set_of(j)) {
                union2(set_of(i), set_of(j));
            }
        }
    }
    for(int i=0; i<n; i++) {
        v[set_of2(i)].push_back(i);
    }

    for(int i=0; i<n; i++) {
        if(v[i].size() == 2) return 0;
    }

    for(int i=0; i<n; i++) {
        if(v[i].size() > 2) {
            for(int j=0; j<v[i].size(); j++) {
                answer[v[i][j]][v[i][(j+1) % v[i].size()]] = 1;
                answer[v[i][(j+1) % v[i].size()]][v[i][j]] = 1;
                union_(v[i][j], v[i][(j+1) % v[i].size()]);
            }
        }
    }
    
    
	build(answer);
	return 1;
}

컴파일 시 표준 에러 (stderr) 메시지

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:18:9: error: 'dsu' was not declared in this scope
   18 |         dsu[i] = dsu2[i] = i;
      |         ^~~
supertrees.cpp:18:18: error: 'dsu2' was not declared in this scope
   18 |         dsu[i] = dsu2[i] = i;
      |                  ^~~~
supertrees.cpp:24:20: error: 'set_of' was not declared in this scope; did you mean 'setbuf'?
   24 |                 if(set_of(i) != set_of(j)) {
      |                    ^~~~~~
      |                    setbuf
supertrees.cpp:25:21: error: 'union_' was not declared in this scope; did you mean 'union'?
   25 |                     union_(i, j);
      |                     ^~~~~~
      |                     union
supertrees.cpp:33:32: error: 'set_of' was not declared in this scope; did you mean 'setbuf'?
   33 |             if(p[i][j] != 1 && set_of(i) == set_of(j)) {
      |                                ^~~~~~
      |                                setbuf
supertrees.cpp:41:32: error: 'set_of' was not declared in this scope; did you mean 'setbuf'?
   41 |             if(p[i][j] == 2 && set_of(i) != set_of(j)) {
      |                                ^~~~~~
      |                                setbuf
supertrees.cpp:42:17: error: 'union2' was not declared in this scope; did you mean 'union'?
   42 |                 union2(set_of(i), set_of(j));
      |                 ^~~~~~
      |                 union
supertrees.cpp:47:11: error: 'set_of2' was not declared in this scope
   47 |         v[set_of2(i)].push_back(i);
      |           ^~~~~~~
supertrees.cpp:56:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |             for(int j=0; j<v[i].size(); j++) {
      |                          ~^~~~~~~~~~~~
supertrees.cpp:59:17: error: 'union_' was not declared in this scope; did you mean 'union'?
   59 |                 union_(v[i][j], v[i][(j+1) % v[i].size()]);
      |                 ^~~~~~
      |                 union