답안 #1025869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025869 2024-07-17T10:53:24 Z parsadox2 장난감 기차 (IOI17_train) C++17
0 / 100
1424 ms 1472 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 5e3 + 10;

int n , m , st;
vector <int> adj[N];
bool dead[N] , marked[N] , cyc[N];
bool vis[N][2];

void Dfs(int v , int ty)
{
	vis[v][ty] = true;
	if(dead[v] && ty == 0)
	{
		Dfs(v , 1);
		return;
	}
	for(auto u : adj[v])
	{
		if(u == st && ty == 1)
			cyc[st] = true;
		if(!vis[u][ty])
			Dfs(u , ty);
	}
}

bool Solve(int v)
{
	marked[v] = true;
	if(cyc[v])
		return true;
	bool flg = false;
	for(auto u : adj[v])  if(!marked[u])
		flg |= Solve(u);
	return flg;
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	n = a.size();
	m = u.size();
	vector<int> res(a.size());
	for(int i = 0 ; i < n ; i++)
		dead[i] = r[i];
	for(int i = 0 ; i < m ; i++)
		adj[u[i]].push_back(v[i]);
	for(int i = 0 ; i < n ; i++)  if(!dead[i])
	{
		//cout << "DFS " << i << endl;
		st = i;
		memset(vis , false , sizeof vis);
		Dfs(i , 0);
	}
	for(int i = 0 ; i < n ; i++)
	{
		memset(marked , false , sizeof marked);
		res[i] = Solve(i);
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 164 ms 1116 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 241 ms 1472 KB Output is correct
2 Correct 194 ms 1436 KB Output is correct
3 Correct 179 ms 1420 KB Output is correct
4 Correct 1145 ms 1356 KB Output is correct
5 Correct 1067 ms 1308 KB Output is correct
6 Correct 776 ms 1204 KB Output is correct
7 Correct 204 ms 1116 KB Output is correct
8 Correct 337 ms 1112 KB Output is correct
9 Correct 320 ms 1448 KB Output is correct
10 Correct 454 ms 1168 KB Output is correct
11 Incorrect 387 ms 1112 KB 3rd lines differ - on the 89th token, expected: '1', found: '0'
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 469 ms 1184 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1424 ms 1316 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 164 ms 1116 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -