Submission #838433

# Submission time Handle Problem Language Result Execution time Memory
838433 2023-08-26T22:35:18 Z thimote75 Toy Train (IOI17_train) C++14
0 / 100
1160 ms 1636 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

using idata = vector<int>;
using bdata = vector<bool>;
using igrid = vector<idata>;

idata controller, charger;
int N, M;

igrid roads;

idata visited; int stage = 1;
bdata status;

bool isBCycle (int node, int source, int depth) {
	if (depth != 0 && node == source) return true;
	if (charger[node] == 1) return false;
	if (visited[node] == stage) return status[node];
	visited[node] = stage;
	status [node] = true;

	bool rstatus = controller[node] == 1;
	for (int next : roads[node]) {
		bool result = isBCycle(next, source, depth + 1);

		if (controller[node] == 1) rstatus &= result;
		else rstatus |= result;
	}

	status[node] = rstatus;
	return rstatus;
}

idata who_wins(idata _controller, idata _charger, idata u, idata v) {
	N = _controller.size(); M = u.size();

	controller = _controller;
	charger    = _charger;

	roads.resize(N);

	for (int i = 0; i < M; i ++)
		roads[u[i]].push_back(v[i]);

	visited.resize(N);
	status .resize(N);

	idata answer(N, false);
	for (int i = 0; i < N; i ++) {
		answer[i] = isBCycle(i, i, 0) ? 0 : 1;
		stage ++;
	}

	return answer;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 852 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 212 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 88 ms 1636 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 4 ms 1080 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 1160 ms 1508 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 852 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -