답안 #970609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970609 2024-04-26T19:21:45 Z Lalic 장난감 기차 (IOI17_train) C++17
11 / 100
7 ms 1120 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;
vector<int> adj[5005];

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	N=(int)a.size();
	
	vector<int> gin(N, 0);
	for(int i=0;i<(int)u.size();i++){
		adj[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(a[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(!a[at] || !gin[at]){
				ans[at]=0;
				q.push(at);
			}
		}
	}
	
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 860 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 364 KB 3rd lines differ - on the 4th token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1112 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1112 KB Output is correct
2 Correct 4 ms 1116 KB Output is correct
3 Correct 5 ms 1116 KB Output is correct
4 Correct 5 ms 1116 KB Output is correct
5 Correct 5 ms 1120 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 6 ms 1116 KB Output is correct
8 Correct 5 ms 1116 KB Output is correct
9 Correct 4 ms 988 KB Output is correct
10 Correct 5 ms 1116 KB Output is correct
11 Correct 5 ms 1116 KB Output is correct
12 Correct 5 ms 1116 KB Output is correct
13 Correct 7 ms 1004 KB Output is correct
14 Correct 5 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1116 KB Output is correct
2 Correct 5 ms 1000 KB Output is correct
3 Correct 5 ms 1116 KB Output is correct
4 Correct 4 ms 1116 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 3 ms 860 KB Output is correct
8 Incorrect 3 ms 860 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 860 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -