답안 #1025849

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025849 2024-07-17T10:46:29 Z parsadox2 장난감 기차 (IOI17_train) C++17
11 / 100
662 ms 1372 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];

void Dfs(int v)
{
	//cout << v << " : " << endl;
	marked[v] = true;
	for(auto u : adj[v])
	{
		//cout << u << endl;
		if(u == st)
			cyc[st] = true;
		if(!dead[u] && !marked[u])
			Dfs(u);
	}
}

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;
		for(int j = 0 ; j < n ; j++)
			marked[j] = false;
		Dfs(i);
	}
	for(int i = 0 ; i < n ; i++)
	{
		memset(marked , false , sizeof marked);
		res[i] = (Solve(i) ? 0 : 1);
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 856 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 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 1372 KB Output is correct
2 Correct 38 ms 1268 KB Output is correct
3 Correct 8 ms 1112 KB Output is correct
4 Incorrect 367 ms 1116 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 450 ms 1116 KB Output is correct
2 Correct 107 ms 1092 KB Output is correct
3 Correct 185 ms 1004 KB Output is correct
4 Correct 130 ms 1164 KB Output is correct
5 Correct 340 ms 1192 KB Output is correct
6 Correct 277 ms 1168 KB Output is correct
7 Correct 270 ms 1112 KB Output is correct
8 Correct 179 ms 1112 KB Output is correct
9 Correct 13 ms 1116 KB Output is correct
10 Correct 653 ms 1312 KB Output is correct
11 Correct 662 ms 1316 KB Output is correct
12 Correct 644 ms 1112 KB Output is correct
13 Correct 342 ms 1116 KB Output is correct
14 Correct 202 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 657 ms 1112 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 856 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -