답안 #439069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439069 2021-06-29T07:28:11 Z flappybird 장난감 기차 (IOI17_train) C++17
11 / 100
11 ms 1708 KB
#include "train.h"

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

using namespace std;
typedef int ll;

#define MAX 6000

vector<ll> A, s;
ll N, M;
vector<ll> adj[MAX], rev[MAX], deg, d;
ll mp[MAX][MAX];

std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) {
	ll i;
	A = a;
	N = a.size();
	M = u.size();
	d.resize(N);
	deg.resize(N);
	vector<ll> res;
	res.resize(N);
	for (i = 0; i < N; i++) if (r[i]) s.push_back(i);
	for (i = 0; i < M; i++) adj[u[i]].push_back(v[i]), rev[v[i]].push_back(u[i]), d[u[i]]++;
	deg = d;
	for (auto st : s) {
		ll j;
		queue<ll> q;
		q.push(st);
		res[st] = 1;
		while (!q.empty()) {
			ll t = q.front();
			q.pop();
			for (auto x : rev[t]) {
				if (res[x]) continue;
				deg[x]--;
				if (a[x]) q.push(x), res[x] = 1;
				else if (deg[x] <= 0) q.push(x), res[x] = 1;
			}
		}
	}
	//impossible
	vector<ll> imp;
	for (i = 0; i < N; i++) if (!res[i]) imp.push_back(i);
	deg = d;
	res.clear();
	res.resize(N);
	for (auto st : imp) {
		ll j;
		queue<ll> q;
		q.push(st);
		res[st] = 1;
		while (!q.empty()) {
			ll t = q.front();
			q.pop();
			for (auto x : rev[t]) {
				if (res[x]) continue;
				deg[x]--;
				if (!a[x]) q.push(x), res[x] = 1;
				else if (deg[x] <= 0) q.push(x), res[x] = 1;
			}
		}
	}
	for (i = 0; i < N; i++) res[i] = !res[i];
	return res;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:32:6: warning: unused variable 'j' [-Wunused-variable]
   32 |   ll j;
      |      ^
train.cpp:54:6: warning: unused variable 'j' [-Wunused-variable]
   54 |   ll j;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1100 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Incorrect 1 ms 460 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1484 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1228 KB Output is correct
2 Correct 9 ms 1488 KB Output is correct
3 Correct 11 ms 1708 KB Output is correct
4 Correct 11 ms 1680 KB Output is correct
5 Correct 10 ms 1672 KB Output is correct
6 Correct 10 ms 1612 KB Output is correct
7 Correct 10 ms 1612 KB Output is correct
8 Correct 10 ms 1612 KB Output is correct
9 Correct 10 ms 1492 KB Output is correct
10 Correct 11 ms 1612 KB Output is correct
11 Correct 11 ms 1696 KB Output is correct
12 Correct 11 ms 1648 KB Output is correct
13 Correct 10 ms 1612 KB Output is correct
14 Correct 9 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1484 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 1100 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -