Submission #422903

# Submission time Handle Problem Language Result Execution time Memory
422903 2021-06-10T13:52:40 Z schse Toy Train (IOI17_train) C++17
0 / 100
1845 ms 1416 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, int 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 '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++)
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 291 ms 1064 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 219 ms 1348 KB Output is correct
2 Correct 224 ms 1304 KB Output is correct
3 Correct 235 ms 1356 KB Output is correct
4 Correct 1713 ms 1240 KB Output is correct
5 Correct 1279 ms 1416 KB Output is correct
6 Correct 849 ms 1344 KB Output is correct
7 Correct 679 ms 1348 KB Output is correct
8 Incorrect 403 ms 1228 KB 3rd lines differ - on the 27th token, expected: '1', found: '0'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1317 ms 1076 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1845 ms 1208 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 291 ms 1064 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -