답안 #296085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
296085 2020-09-10T08:59:49 Z Dovran 장난감 기차 (IOI17_train) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "train.h"

#define N 20009
#define pii pair <int, int>
#define ff first
#define ss second
#define sz() size()
#define pb push_back
#define ll long long

using namespace std;

bool v[N];
vector<int>ans;

std::vector<int> who_wins(std::vector<int>o, std::vector<int>p, std::vector<int>u, std::vector<int>v){
	int n=o.sz();
	int m=u.sz();
	vector<int>e[N];
	int c[N];
	map<int, int>M;
	for(int i=0; i<m; i++){
		e[u[i]].pb(v[i]), M[u[i]][v[i]]=1;
		if(u[i]==v[i])
			c[u[i]]=1;
	}
	for(int i=0; i<n; i++){
		if(p[i]==1 and o[i]==1 and c[i]==1)
			v[i]=1;
		if(M[v[i]][v[i]+1])
			v[i]=v[i+1];
		ans.pb(v[i]);
	}
	return ans;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:24:33: error: invalid types 'std::map<int, int>::mapped_type {aka int}[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   24 |   e[u[i]].pb(v[i]), M[u[i]][v[i]]=1;
      |                                 ^
train.cpp:31:20: error: invalid types 'std::map<int, int>::mapped_type {aka int}[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   31 |   if(M[v[i]][v[i]+1])
      |                    ^