답안 #972047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
972047 2024-04-30T00:05:54 Z mariaclara 장난감 기차 (IOI17_train) C++17
11 / 100
190 ms 1636 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, grau[5005], at_grau[5005];
bool valid[5005], A[5005];
vector<int> edges[5005];
 
void dfs(int x) {
	for(int viz : edges[x]) {
		if(valid[viz]) continue;
		if(A[viz]) valid[viz] = 1, dfs(viz);
		else at_grau[viz]--;
		if(at_grau[viz] == 0) valid[viz] = 1, dfs(viz);
	}
}
 
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> ans(n);
 
	for(int i = 0; i < m; i++) edges[v[i]].pb(u[i]), grau[u[i]]++;
	for(int i = 0; i < n; i++) A[i] = a[i];

	queue<int> fila;
 
	for(int i = 0; i < n; i++) {
		if(!r[i]) continue;
		for(int j = 0; j < n; j++) at_grau[j] = grau[i], valid[j] = 0;
		dfs(i);
		if(valid[i]) fila.push(i);
	}

	while(!fila.empty()) {
		int x = fila.front();
		fila.pop();

		if(ans[x]) continue;
		ans[x] = 1;

		for(int viz : edges[x]) {
			grau[viz]--;
			if(grau[viz] == 0) fila.push(viz);
			else if(a[viz]) fila.push(viz);
		}
	}

	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 1116 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 1628 KB Output is correct
2 Correct 55 ms 1628 KB Output is correct
3 Correct 64 ms 1628 KB Output is correct
4 Correct 190 ms 1620 KB Output is correct
5 Correct 41 ms 1564 KB Output is correct
6 Correct 10 ms 1372 KB Output is correct
7 Correct 181 ms 1440 KB Output is correct
8 Correct 5 ms 1372 KB Output is correct
9 Correct 5 ms 1372 KB Output is correct
10 Correct 5 ms 1348 KB Output is correct
11 Correct 5 ms 1348 KB Output is correct
12 Correct 4 ms 1116 KB Output is correct
13 Correct 5 ms 1636 KB Output is correct
14 Correct 6 ms 1624 KB Output is correct
15 Correct 6 ms 1628 KB Output is correct
16 Correct 6 ms 1628 KB Output is correct
17 Correct 5 ms 1632 KB Output is correct
18 Correct 99 ms 1112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 89 ms 1368 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1476 KB Output is correct
2 Correct 6 ms 1504 KB Output is correct
3 Correct 6 ms 1368 KB Output is correct
4 Correct 6 ms 1372 KB Output is correct
5 Correct 1 ms 568 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
7 Correct 3 ms 1076 KB Output is correct
8 Incorrect 4 ms 1116 KB 3rd lines differ - on the 5th token, expected: '0', found: '1'
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 1116 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -