Submission #422902

# Submission time Handle Problem Language Result Execution time Memory
422902 2021-06-10T13:51:55 Z schse Toy Train (IOI17_train) C++17
Compilation error
0 ms 0 KB
#include "train.h"
#ifndef EVAL
#include "grader.cpp"
#endif

#define DEACTIVATED -1
#define UNKNOWN 0
#include <bits/stdc++.h>
using namespace std;

struct node
{
	vector<int> edges;
	bool been;
	bool actice;
	int chargingsationsbefore = INT32_MAX;
	bool charging = false;
	bool owner;
	bool winningpos = false;
};

vector<node> g;

int dfs(int n, bool charging)
{
	if (g[n].actice && g[n].chargingsationsbefore < charging)
		return true;
	else if (g[n].been)
		return false;
	g[n].been = true;
	g[n].actice = true;
	g[n].chargingsationsbefore = charging;

	if (g[n].charging)
		charging++;

	bool b = false;
	for (int i : g[n].edges)
	{
		b |= dfs(i, charging);
	}
	g[n].actice = false;
	return b;
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v)
{
	g.resize(a.size());
	for (int i = 0; i < a.size(); i++)
	{
		g[i].owner = a[i];
		g[i].charging = r[i];
	}
	for (int i = 0; i < u.size(); i++)
	{
		g[u[i]].edges.push_back(v[i]);
	}

	vector<int> res(a.size(), 0);
	for (int i = 0; i < (int)a.size(); i++)
	{
		for (int i = 0; i < a.size(); i++)
			g[i].been = false;
		res[i] = dfs(i, 0);
	}
	return res;
}

Compilation message

train.cpp: In function 'int dfs(int, bool)':
train.cpp:35:3: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17
   35 |   charging++;
      |   ^~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for (int i = 0; i < a.size(); i++)
      |                  ~~^~~~~~~~~~
train.cpp:54:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for (int i = 0; i < u.size(); i++)
      |                  ~~^~~~~~~~~~
train.cpp:62:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |   for (int i = 0; i < a.size(); i++)
      |                   ~~^~~~~~~~~~