Submission #789942

# Submission time Handle Problem Language Result Execution time Memory
789942 2023-07-22T07:56:30 Z ymm Toy Train (IOI17_train) C++17
5 / 100
1103 ms 1644 KB
#include "train.h"
#include <bits/stdc++.h>
#define Loop(x,l,r) for (long long x = (l); x < (r); ++x)
typedef long long ll;
typedef std::pair<ll,ll> pll;
using namespace std;

const int N = 5050;
vector<int> A[N];
int col[N];
bool charg[N];
int n, m;
int win[N];
bool vis[N];
int height[N];

bool dfs(int v, int h, int mxc)
{
	height[v] = h;
	vis[v] = 1;
	if (charg[v])
		mxc = h;
	bool ans = col[v]? 0: 1;
	for (int u : A[v]) {
		bool wu;
		if (vis[u])
			wu = win[u] == 1 || height[u] <= mxc;
		else
			wu = dfs(u, h+1, mxc);
		if (col[v])
			ans |= wu;
		else
			ans &= wu;
	}
	win[v] = ans;
	return ans;
}

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> V, std::vector<int> U) {
	n = a.size();
	m = V.size();
	Loop (i,0,n) {
		col[i] = a[i];
		charg[i] = r[i];
	}
	Loop (i,0,m) {
		int v = V[i], u = U[i];
		A[v].push_back(u);
	}
	vector<int> ans(n);
	Loop (i,0,n) {
		memset(win, -1, sizeof(win));
		memset(vis, 0, sizeof(vis));
		memset(height, 0, sizeof(height));
		ans[i] = dfs(i, 0, -1);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 190 ms 1216 KB Output is correct
2 Correct 60 ms 1108 KB Output is correct
3 Correct 29 ms 1004 KB Output is correct
4 Correct 13 ms 980 KB Output is correct
5 Correct 10 ms 852 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 6 ms 852 KB Output is correct
8 Correct 6 ms 852 KB Output is correct
9 Correct 5 ms 852 KB Output is correct
10 Correct 5 ms 820 KB Output is correct
11 Correct 5 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 468 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 157 ms 1476 KB Output is correct
2 Correct 149 ms 1644 KB Output is correct
3 Correct 151 ms 1492 KB Output is correct
4 Correct 1103 ms 1464 KB Output is correct
5 Incorrect 838 ms 1460 KB 3rd lines differ - on the 11th token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 865 ms 1144 KB Output is correct
2 Correct 135 ms 1208 KB Output is correct
3 Correct 378 ms 1320 KB Output is correct
4 Correct 454 ms 1300 KB Output is correct
5 Correct 338 ms 1324 KB Output is correct
6 Incorrect 261 ms 1208 KB 3rd lines differ - on the 1524th token, expected: '0', found: '1'
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 984 ms 1268 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 Correct 190 ms 1216 KB Output is correct
2 Correct 60 ms 1108 KB Output is correct
3 Correct 29 ms 1004 KB Output is correct
4 Correct 13 ms 980 KB Output is correct
5 Correct 10 ms 852 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 6 ms 852 KB Output is correct
8 Correct 6 ms 852 KB Output is correct
9 Correct 5 ms 852 KB Output is correct
10 Correct 5 ms 820 KB Output is correct
11 Correct 5 ms 852 KB Output is correct
12 Incorrect 0 ms 468 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
13 Halted 0 ms 0 KB -