Submission #969297

# Submission time Handle Problem Language Result Execution time Memory
969297 2024-04-24T22:22:51 Z mariaclara Toy Train (IOI17_train) C++17
0 / 100
8 ms 1372 KB
#include "train.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
const int INF = 1e9+10;
const ll LINF = 1e18+10;
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define mk make_pair
#define pb push_back
#define f first 
#define s second

int t;
bool vis[5005], in_dfs[5005];
vector<int> edges[5005];

bool dfs(int x) {
	in_dfs[x] = 1;
	vis[x] = 1;

	for(auto viz : edges[x]) {
		if(vis[viz] and in_dfs[viz]) return 1;
		else if(vis[viz]) continue;
		if(dfs(viz)) return 1;
	}

	in_dfs[x] = 0;
	return 0;
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	int n = sz(a), m = sz(u);
	vector<int> res(n);

	for(int i = 0; i < m; i++) edges[v[i]].pb(u[i]);

	queue<int> fila;

	for(int i = 0; i < n; i++) {
		if(r[i]) {
			memset(vis, 0, sizeof(vis));
			memset(in_dfs, 0, sizeof(in_dfs));
			if(dfs(i)) fila.push(i);
		}
	}

	while(!fila.empty()) {
		int x = fila.front();
		fila.pop();
 
		if(res[x]) continue;
		res[x] = 1;
 
		for(auto viz : edges[x])
			fila.push(viz);
	}
	
	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 860 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 344 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 7 ms 1372 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 8 ms 1112 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 Incorrect 5 ms 1116 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 4 ms 860 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -