Submission #405725

# Submission time Handle Problem Language Result Execution time Memory
405725 2021-05-16T20:51:48 Z peuch Toy Train (IOI17_train) C++17
Compilation error
0 ms 0 KB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;

int n;

vector<int> ar[MAXN];

int dp[MAXN]

vector<int> sub1(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v){
	vector<int> w(n, 0);
	for(int i = n - 1; i >= 0; i--){
		if(ar[i].size() == 2){
			if(a[i]){
				if(r[i]) w[i] = w[i + 1];
				else w[i] = 1;
			}
			else{
				if(r[i]) w[i] = 1;
				else w[i] = w[i + 1];
			}
		}
		else if(ar[i][0] == i + 1) w[i] = !r[i];
		else w[i] = w[i + 1];
	}
	return w;
}


vector<int> sub2(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v);
vector<int> sub3(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v);
vector<int> sub4(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v);
vector<int> sub5(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v);

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	n = a.size();
	
	return sub1(a, r, u, v);
	
	for(int i = 0; i < u.size(); i++)
		ar[u[i]].push_back(v[i]);
	
	if(n <= 15) return sub2(a, r, u, v); 
	
	bool flag = true;
	for(int i = 0; i < n; i++)
		flag &= a[i];
		
	if(flag) return sub3(a, r, u, v);
	
	flag = true;
	for(int i = 0; i < n; i++)
		flag &= !a[i];
		
	if(flag) return sub4(a, r, u, v);
	
	int cnt = 0;
	
	for(int i = 0; i < n; i++)
		cnt += r[i];
	
	if(cnt == 1) return sub5(a, r, u, v);
	
	return sub1(a, r, u, v);
	
	
	return res;
}

Compilation message

train.cpp:7:16: error: 'MAXN' was not declared in this scope
    7 | vector<int> ar[MAXN];
      |                ^~~~
train.cpp:9:8: error: 'MAXN' was not declared in this scope
    9 | int dp[MAXN]
      |        ^~~~
train.cpp:11:1: error: expected initializer before 'vector'
   11 | vector<int> sub1(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v){
      | ^~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:39:9: error: 'sub1' was not declared in this scope; did you mean 'sub5'?
   39 |  return sub1(a, r, u, v);
      |         ^~~~
      |         sub5
train.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 0; i < u.size(); i++)
      |                 ~~^~~~~~~~~~
train.cpp:42:3: error: 'ar' was not declared in this scope; did you mean 'a'?
   42 |   ar[u[i]].push_back(v[i]);
      |   ^~
      |   a
train.cpp:68:9: error: 'res' was not declared in this scope
   68 |  return res;
      |         ^~~