Submission #1034753

# Submission time Handle Problem Language Result Execution time Memory
1034753 2024-07-25T17:30:02 Z ALeonidou Toy Train (IOI17_train) C++17
5 / 100
2000 ms 1588 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

#define ll int
#define sz(x) (ll)x.size()
#define endl "\n"
#define pb push_back
#define F first
#define S second

typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;

#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;

void printVct(vi &v){
	for (ll i =0; i<sz(v); i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
}

void printVct2D(vector <vi> &adj){
	cout<<endl;
	for (ll i =0; i<sz(adj); i++){
		cout<<i<<": ";
		for (ll j =0; j<sz(adj[i]); j++){
			cout<<adj[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
}

vector <vi> adj;
vi r,a,u,v;
vi self_cycles;

bool dfs(ll u){
	if (self_cycles[u]){
		if (r[u] && a[u]) return true;
		if (!r[u] && !a[u]) return false;
	}
	if (adj[u].empty()){
		return r[u];
	}
	return dfs(adj[u][0]);
}

vi who_wins(vi A, vi R, vi U, vi V) {
	r = R, a = A, u = U, v = V;;
	ll n = sz(a), m = sz(u);
	
	adj.assign(n,vi());
	self_cycles.assign(n, 0);
	for(ll i =0; i<m; i++){
		if (v[i] == u[i]) self_cycles[v[i]] = 1;
		else adj[u[i]].pb(v[i]);
	}

	vi ans(n,0);
	for (ll i =0; i<n; i++){
		ans[i] = dfs(i);
	}

	return ans;
}


/*
7 9
1 1 1 1 1 1 1
0 1 0 0 0 1 0
0 2
0 1
2 3
1 4
4 5
5 3
3 4
3 6
6 6
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1112 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 964 KB Output is correct
4 Correct 2 ms 1116 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2040 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 69 ms 1368 KB Output is correct
2 Correct 60 ms 1588 KB Output is correct
3 Correct 55 ms 1372 KB Output is correct
4 Execution timed out 2011 ms 1368 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2019 ms 1368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2021 ms 1368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1112 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 964 KB Output is correct
4 Correct 2 ms 1116 KB Output is correct
5 Correct 2 ms 860 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 2 ms 860 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Execution timed out 2040 ms 344 KB Time limit exceeded
13 Halted 0 ms 0 KB -