답안 #860948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860948 2023-10-14T22:02:43 Z BlancaHM 사육제 (CEOI14_carnival) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include <map>
#include <unordered_set>
#include <set>
#include <algorithm>
using namespace std;

vector<int> resolver(int N) {
	vector<int> mismoDisfraz = vector<vector<int>>(N, vector<int>(N, 0));
	int respuesta;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			cout << "2 " << i+1 << ' ' << j+1 << '\n';
			cin >> respuesta;
			mismoDisfraz[i][j] = mismoDisfraz[j][i] = 2-respuesta;
		}
	}
	vector<int> disfraces(N, 0);
	int disfracesDescubiertos = 0;
	for (int j = 0; j < N; j++) {
		for (int i = 0; i < j; i++) {
			if (mismoDisfraz[i][j]) {
				disfraces[j] = disfraces[i];
			}
		}
		if (disfraces[j] == 0) {
			disfracesDescubiertos++;
			disfraces[j] = disfracesDescubiertos;
		}
	}
	return disfraces;
}

int main() {
	int N;
	cin >> N;
	vector<int> disfraces = resolver(N);
	cout << '0';
	for (int & disfraz: disfraces) {
		cout << ' ' << disfraz;
	}
	cout << '\n';
	return 0;
}

Compilation message

carnival.cpp: In function 'std::vector<int> resolver(int)':
carnival.cpp:10:29: error: conversion from 'vector<std::vector<int>>' to non-scalar type 'vector<int>' requested
   10 |  vector<int> mismoDisfraz = vector<vector<int>>(N, vector<int>(N, 0));
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:16:19: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   16 |    mismoDisfraz[i][j] = mismoDisfraz[j][i] = 2-respuesta;
      |                   ^
carnival.cpp:16:40: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   16 |    mismoDisfraz[i][j] = mismoDisfraz[j][i] = 2-respuesta;
      |                                        ^
carnival.cpp:23:23: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   23 |    if (mismoDisfraz[i][j]) {
      |                       ^