Submission #296085

# Submission time Handle Problem Language Result Execution time Memory
296085 2020-09-10T08:59:49 Z Dovran Toy Train (IOI17_train) C++11
Compilation error
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])
      |                    ^