답안 #977434

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977434 2024-05-08T01:56:53 Z Amaarsaa 슈퍼트리 잇기 (IOI20_supertrees) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
//#include "supertrees.h"
using namespace std;
vector < int > adj[1002];
int used[1002];
vector < int > v;
void Go(int x) {
	used[x] = 1;
	v.push_back(x);
	for ( int X : adj[x]) {
		if (!used[X]) {
			Go(X);
		}
	}
}
int construct(vector< vector< int> > a) {
	int n = a.size();
	vector < vector < int > > ans;
	ans.resize(n);
	for (int i = 0; i < n; i++) {
		ans[i].resize(n);
		for (int j = 0; j < n; j ++) {
			if ( a[i][j] != 0 && i != j) adj[i].push_back(j);
		}
	}
	for (int i = 0; i < n; i ++) {
		if ( used[i] == 0) {
			v.clear();
			Go(i);
			for (int j = 1; j < v.size(); j ++) ans[v[j]][v[j - 1]] = ans[v[j - 1]][v[j]] = 1;
		}
	}
	
	build(ans);
	return 1;
}
/*
vector < vector < int > > b;
inp() {
	int n, i, j, x;
	cin >>n;
	b.resize(n);
	for (i = 0; i < n; i ++) {
		for (j = 0; j < n; j ++) {
			cin >> x;
			b[i].push_back(x);
		}
	}
}
int main() {
	inp();
	cout << construct(b) << endl;
}
*/

Compilation message

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |    for (int j = 1; j < v.size(); j ++) ans[v[j]][v[j - 1]] = ans[v[j - 1]][v[j]] = 1;
      |                    ~~^~~~~~~~~~
supertrees.cpp:34:2: error: 'build' was not declared in this scope
   34 |  build(ans);
      |  ^~~~~