답안 #296088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
296088 2020-09-10T09:01:22 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 a[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)
			a[i]=1;
		if(M[i][i+1]])
			a[i]=a[i+1];
		ans.pb(a[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:14: error: invalid types 'std::map<int, int>::mapped_type {aka int}[int]' for array subscript
   31 |   if(M[i][i+1]])
      |              ^
train.cpp:31:15: error: expected ')' before ']' token
   31 |   if(M[i][i+1]])
      |     ~         ^
      |               )
train.cpp:31:15: error: expected primary-expression before ']' token