답안 #607358

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
607358 2022-07-26T15:53:26 Z fvogel499 장난감 기차 (IOI17_train) C++17
12 / 100
13 ms 3156 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

#define vi vector<int>
#define size(x) (int)((x).size())

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	int n = size(a);
	int chargingStation = -1;
	for (int i = 0; i < n; i++) if (r[i]) {
		chargingStation = i;
	}
	vector<vi> graph(3*n+1);
	vector<vi> ng(size(graph));
	vi inc(3*n+1, 0);
	vi typ(size(graph));
	typ.back() = 0;
	for (int i = 0; i < 3*n; i++) {
		typ[i] = a[i/3];
	}
	for (int k = 0; k < size(u); k++) {
		for (int i = 0; i < 3; i++) {
			int to = i;
			if (v[k] == chargingStation) {
				to++;
			}
			int toNode = v[k]*3+to;
			if (to == 3) toNode = size(graph)-1;
			graph[toNode].push_back(u[k]*3+i);
			ng[u[k]*3+i].push_back(toNode);
			inc[u[k]*3+i]++;
		}
	}
	vector<int> win(size(graph), 0);
	for (int i = 0; i < size(graph); i++) win[i] = false;
	queue<int> q;
	q.push(size(graph)-1);
	win[size(graph)-1] = true;
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		for (int y : graph[x]) {
			if (typ[y] == 1) {
				if (!win[y]) {
					q.push(y);
					win[y] = true;
				}
			}
			else {
				inc[y]--;
				assert(inc[y] >= 0);
				if (inc[y] == 0) {
					assert(!win[y]);
					q.push(y);
					win[y] = true;
				}
			}
		}
	}
	vi fin(n);
	for (int i = 0; i < n; i++) fin[i] = win[i*3+1];
	return fin;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2388 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 3124 KB Output is correct
2 Correct 10 ms 3156 KB Output is correct
3 Correct 10 ms 3156 KB Output is correct
4 Correct 12 ms 3036 KB Output is correct
5 Correct 12 ms 3028 KB Output is correct
6 Incorrect 12 ms 3028 KB 3rd lines differ - on the 47th token, expected: '1', found: '0'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 2656 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 3000 KB Output is correct
2 Correct 13 ms 3000 KB Output is correct
3 Correct 12 ms 3028 KB Output is correct
4 Correct 11 ms 2820 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 8 ms 2228 KB Output is correct
7 Correct 7 ms 1468 KB Output is correct
8 Correct 7 ms 1620 KB Output is correct
9 Correct 8 ms 1620 KB Output is correct
10 Correct 2 ms 596 KB Output is correct
11 Correct 6 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 2388 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -