답안 #790307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790307 2023-07-22T14:26:03 Z Valaki2 장난감 기차 (IOI17_train) C++14
12 / 100
334 ms 1592 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;

#define pb push_back

const int maxn = 5000;

int n, m;
vector<int> g[1 + maxn], rg[1 + maxn];
int own[1 + maxn], charge[1 + maxn];
bool has_self[1 + maxn];

int charged;
bool good[1 + maxn];
bool good_cycle;

void decide() {
	for(int i = 1; i <= n; i++) {
		if(charge[i]) {
			charged = i;
		}
	}
	good[charged] = true;
	for(int iter = 1; iter <= n; iter++) {
		for(int cur = 1; cur <= n; cur++) {
			bool this_good;
			if(own[cur] == 1) {
				this_good = false;
				for(int nei : g[cur]) {
					if(good[nei]) {
						this_good = true;
					}
				}
			} else {
				this_good = true;
				for(int nei : g[cur]) {
					if(!good[nei]) {
						this_good = false;
					}
				}
			}
			if(this_good) {
				good[cur] = true;
				if(cur == charged) {
					good_cycle = true;
				}
			}
		}
	}
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
	n = a.size();
	m = u.size();
	for(int i = 0; i < m; i++) {
		g[u[i] + 1].pb(v[i] + 1);
		rg[v[i] + 1].pb(u[i] + 1);
		if(u[i] == v[i]) {
			has_self[u[i] + 1] = true;
		}
	}
	for(int i = 1; i <= n; i++) {
		own[i] = a[i - 1];
		charge[i] = r[i - 1];
	}
	decide();
	vector<int> res(n, 0);
	if(good_cycle) {
		for(int i = 0; i < n; i++) {
			res[i] = good[i + 1];
		}
	}
	return res;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 128 ms 1060 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 468 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 1432 KB Output is correct
2 Correct 234 ms 1412 KB Output is correct
3 Correct 202 ms 1436 KB Output is correct
4 Correct 211 ms 1376 KB Output is correct
5 Correct 307 ms 1368 KB Output is correct
6 Incorrect 256 ms 1384 KB 3rd lines differ - on the 47th token, expected: '1', found: '0'
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 182 ms 1216 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 330 ms 1372 KB Output is correct
2 Correct 267 ms 1592 KB Output is correct
3 Correct 334 ms 1584 KB Output is correct
4 Correct 274 ms 1480 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 119 ms 1096 KB Output is correct
7 Correct 11 ms 1264 KB Output is correct
8 Correct 13 ms 1320 KB Output is correct
9 Correct 12 ms 1236 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 16 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 128 ms 1060 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -