Submission #835753

# Submission time Handle Problem Language Result Execution time Memory
835753 2023-08-23T19:18:42 Z Josia Toy Train (IOI17_train) C++17
0 / 100
619 ms 1172 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> graph;
vector<bool> own;
vector<bool> station;


vector<int> dp;
vector<bool> vis;
// int dfs(int v) {
// 	if (station[v]) return 1;

// 	if (dp[v]!=-1) return dp[v];

// 	if (vis[v]) return 0;
// 	vis[v] = 1;

// 	set<int> poss;

// 	for (int i: graph[v]) {
// 		poss.insert(dfs(i));
// 	}

// 	if (own[v]) {
// 		if (poss.count(1)) return 1;
// 		return 0;
// 	}
// 	if (!own[v]) {
// 		if (poss.count(0)) return 0;
// 		return 1;
// 	}
// }

int dfs(int v) {
	if (station[v]) return 1;

	if (vis[v]) return 0;
	vis[v] = 1;


	for (int i: graph[v]) {
		if(dfs(i)) return 1;
	}

	return 0;
}


vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = a.size();
	graph.assign(n, vector<int>());
	for (int i = 0; i<(int)u.size(); i++) {
		// graph[u[i]].push_back(v[i]);
		graph[v[i]].push_back(u[i]);
	}
	own.resize(n);
	station.resize(n);
	for (int i = 0; i<n; i++) {
		own[i] = a[i];
		station[i] = r[i];
	}


	vector<int> res(n);
	for (int i = 0; i<n; i++) {
		vis.assign(n, 0);
		dp.assign(n, -1);
		res[i] = dfs(i);
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 724 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 0 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 201 ms 1172 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 12 ms 852 KB 3rd lines differ - on the 21st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 619 ms 1108 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 11 ms 724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -