Submission #970606

# Submission time Handle Problem Language Result Execution time Memory
970606 2024-04-26T19:11:59 Z Lalic Toy Train (IOI17_train) C++17
0 / 100
8 ms 1624 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int N, type[5005];
vector<int> adj[5005], adjT[5005];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	N=(int)a.size();
	for(int i=0;i<N;i++) type[i]=a[i];
	
	vector<int> gin(N, 0);
	for(int i=0;i<(int)u.size();i++){
		adj[u[i]].pb(v[i]);
		adjT[v[i]].pb(u[i]);
		gin[u[i]]++;
	}
	
	vector<int> rem(N, 0);
	queue<int> q;
	for(int i=0;i<N;i++){
		if(r[i]){
			q.push(i);
			rem[i]=1;
		}
	}
	
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		
		for(auto at : adj[curr]){
			if(rem[at]) continue;
			gin[at]--;
			if(type[at] || !gin[at]){
				rem[at]=1;
				q.push(at);
			}
		}
	}
	
	vector<int> ans(N, 1);
	for(int i=0;i<N;i++){
		if(!rem[i]){
			ans[i]=0;
			q.push(i);
		}
	}
	
	gin.assign(N, 0);
	for(auto val : u) gin[val]++;
	
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		
		for(auto at : adj[curr]){
			if(!ans[at]) continue;
			gin[at]--;
			if(!type[at] || !gin[at]){
				ans[at]=0;
				q.push(at);
			}
		}
	}
	
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1116 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 1 ms 604 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1624 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 5 ms 1372 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1624 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 Incorrect 3 ms 1116 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -