Submission #970607

# Submission time Handle Problem Language Result Execution time Memory
970607 2024-04-26T19:15:49 Z Lalic Toy Train (IOI17_train) C++17
11 / 100
8 ms 1884 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 : adjT[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 : adjT[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 1112 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 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Incorrect 1 ms 604 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 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 Correct 5 ms 1372 KB Output is correct
2 Correct 6 ms 1472 KB Output is correct
3 Correct 6 ms 1628 KB Output is correct
4 Correct 6 ms 1628 KB Output is correct
5 Correct 6 ms 1628 KB Output is correct
6 Correct 5 ms 1628 KB Output is correct
7 Correct 7 ms 1580 KB Output is correct
8 Correct 6 ms 1684 KB Output is correct
9 Correct 5 ms 1628 KB Output is correct
10 Correct 6 ms 1628 KB Output is correct
11 Correct 6 ms 1884 KB Output is correct
12 Correct 6 ms 1628 KB Output is correct
13 Correct 6 ms 1696 KB Output is correct
14 Correct 6 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1372 KB Output is correct
2 Correct 6 ms 1628 KB Output is correct
3 Correct 8 ms 1592 KB Output is correct
4 Correct 5 ms 1624 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 3 ms 1116 KB Output is correct
7 Correct 4 ms 1372 KB Output is correct
8 Incorrect 4 ms 1244 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1112 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -