Submission #52068

# Submission time Handle Problem Language Result Execution time Memory
52068 2018-06-23T15:31:52 Z aome Toy Train (IOI17_train) C++17
23 / 100
290 ms 6768 KB
#include "train.h"

#include <bits/stdc++.h>

using namespace std;

const int N = 5005;

int deg[N];
bool visit[N];
vector<int> G1[N], G2[N];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = a.size(), m = u.size();
	for (int i = 0; i < m; ++i) {
		G1[u[i]].push_back(v[i]), G2[v[i]].push_back(u[i]);
	}
	vector<int> res(n, 0);
	while (1) {
		for (int i = 0; i < n; ++i) visit[i] = 0;
		queue<int> qu;
		for (int i = 0; i < n; ++i) {
			deg[i] = G1[i].size();
		}
		for (int i = 0; i < n; ++i) {
			if (r[i]) qu.push(i);
		}
		while (qu.size()) {
			int u = qu.front(); qu.pop();
			for (auto v : G2[u]) {
				if (a[v]) {
					if (!visit[v]) {
						visit[v] = 1, qu.push(v);
					}
				}
				else {
					deg[v]--;
					if (deg[v] == 0) {
						visit[v] = 1, qu.push(v);
					}
				}
			}
		}
		bool flag = 0;
		for (int i = 0; i < n; ++i) {
			if (r[i] && !visit[i]) { r[i] = 0, flag = 1; }
		}
		if (flag) continue;
		for (int i = 0; i < n; ++i) res[i] = visit[i];
		break;
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1336 KB 3rd lines differ - on the 22nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1336 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 108 ms 1988 KB Output is correct
2 Correct 150 ms 2240 KB Output is correct
3 Correct 221 ms 2396 KB Output is correct
4 Correct 12 ms 2604 KB Output is correct
5 Correct 17 ms 2816 KB Output is correct
6 Correct 15 ms 3128 KB Output is correct
7 Correct 12 ms 3336 KB Output is correct
8 Correct 14 ms 3544 KB Output is correct
9 Correct 13 ms 3812 KB Output is correct
10 Correct 12 ms 3892 KB Output is correct
11 Correct 11 ms 4088 KB Output is correct
12 Correct 12 ms 4280 KB Output is correct
13 Correct 13 ms 4592 KB Output is correct
14 Correct 12 ms 4800 KB Output is correct
15 Correct 12 ms 4988 KB Output is correct
16 Correct 12 ms 5216 KB Output is correct
17 Correct 12 ms 5424 KB Output is correct
18 Correct 290 ms 5424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 5492 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 Correct 12 ms 5908 KB Output is correct
2 Correct 17 ms 6116 KB Output is correct
3 Correct 14 ms 6336 KB Output is correct
4 Correct 11 ms 6408 KB Output is correct
5 Correct 3 ms 6408 KB Output is correct
6 Correct 6 ms 6408 KB Output is correct
7 Correct 8 ms 6432 KB Output is correct
8 Correct 8 ms 6568 KB Output is correct
9 Correct 8 ms 6716 KB Output is correct
10 Correct 4 ms 6716 KB Output is correct
11 Correct 8 ms 6768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 1336 KB 3rd lines differ - on the 22nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -