답안 #112852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
112852 2019-05-22T07:07:35 Z ckodser Amusement Park (JOI17_amusement_park) C++14
10 / 100
27 ms 3924 KB
#include<bits/stdc++.h>
#include "Joi.h"
#define pb push_back
using namespace std;
const int MXN = 12345;
vector < int > Adj[MXN];
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
	for (int i = 0; i < M; i++)
		Adj[A[i]].pb(B[i]), Adj[B[i]].pb(A[i]);
	vector < int > D(N, -1);
	vector < int > P(N, -1);
	vector < int > qu(N, 0);
	int l = 0, r = 0;
	qu[r ++] = 0; D[0] = 0;
	bool OK = 0;
	while (r - l)
	{
		int v = qu[l ++];
		if (D[v] == 59)
			OK = 1;
		for (int &u : Adj[v])
			if (D[u] == -1)
				D[u] = (D[v] + 1) % 60, P[u] = v, qu[r ++] = u;
	}
	if (OK)
	{
		for (int i = 0; i < N; i++)
			MessageBoard(i, (X >> D[i]) & 1LL);
		return ;
	}
	vector < int > F(N, -1);
	vector < int > rev(N, -1);
	for (int i = 0; i < N; i++)
		rev[qu[i]] = i;
	for (int i = 0; i < 60; i++)
		MessageBoard(qu[i], (X >> i) & 1LL), F[qu[i]] = i;
	for (int i = 60; i < N; i++)
	{
		int v = qu[i];
		vector < int > Mark(60, 0);
		for (int p = P[v]; p >= 0; p = P[p])
			Mark[F[p]] = 1;
		F[v] = 59;
		while (Mark[F[v]])
			F[v] --;
		MessageBoard(v, (X >> F[v]) & 1LL);
	}
	return ;
}
#include<bits/stdc++.h>
#include "Ioi.h"
#define pb push_back
using namespace std;
const int MXN = 12345;
bool toSee[MXN], seen[MXN];
vector < int > vec, Adj[MXN];
void DFS(int v)
{
	seen[v] = 1;
	for (int &u : Adj[v])
		if (!seen[u] && toSee[u])
		{
			vec.pb(u);
			DFS(u);
			vec.pb(v);
		}
}
long long Ioi(int N, int M, int A[], int B[], int ST, int VL, int T)
{
	for (int i = 0; i < M; i++)
		Adj[A[i]].pb(B[i]), Adj[B[i]].pb(A[i]);
	vector < int > D(N, -1);
	vector < int > qu(N, 0);
	vector < int > P(N, -1);
	int l = 0, r = 0;
	qu[r ++] = 0; D[0] = 0;
	bool OK = 0;
	while (r - l)
	{
		int v = qu[l ++];
		if (D[v] % 60 == 59)
			OK = 1;
		for (int &u : Adj[v])
			if (D[u] == -1)
				D[u] = D[v] + 1, P[u] = v, qu[r ++] = u;
	}
	if (OK)
	{
		if (D[ST] >= 59)
		{
			long long X = 0;
			for (int i = 0; i < 60; i++)
			{
				X |= (1LL * VL) << (D[ST] % 60);
				if (i < 59)
					ST = P[ST], VL = Move(ST);
			}
			return (X);
		}
		int start = -1;
		for (int i = 0; i < N; i++)
			if (D[i] == 59)
				start = i;
		assert(start != -1);
		vector < int > ids(60, -1);
		for (int i = 59; i >= 0; i--)
			ids[i] = start, start = P[start];
		long long X = 0;
		while (ST != 0)
			ST = P[ST], VL = Move(ST);
		for (int i = 0; i < 60; i++)
		{
			X |= (1LL * VL) << (D[ST] % 60);
			if (i + 1 < 60)
				ST = ids[i + 1], VL = Move(ST);
		}
		return (X);
	}
  	return (12);
	vector < int > F(N, -1);
	vector < int > rev(N, -1);
	for (int i = 0; i < N; i++)
		rev[qu[i]] = i;
	for (int i = 0; i < 60; i++)
		F[qu[i]] = i;
	for (int i = 60; i < N; i++)
	{
		int v = qu[i];
		vector < int > Mark(60, 0);
		for (int p = P[v]; p >= 0; p = P[p])
			Mark[F[p]] = 1;
		F[v] = 59;
		while (Mark[F[v]])
			F[v] --;
	}
	long long X = 0;
	for (int i = 0; i < 60; i++)
		toSee[qu[i]] = 1;
	while (ST != 0)
	{
		X |= (1LL * VL) << (F[ST]);
		toSee[qu[F[ST]]] = 0;
		ST = P[ST]; VL = Move(ST);
	}
	X |= VL;
	DFS(0);
	for (int v : vec)
	{
		ST = v; VL = Move(ST);
		X |= (1LL * VL) << (F[ST]);
	}
	return (X);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1328 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 3924 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1408 KB Output is correct
2 Correct 4 ms 1408 KB Output is correct
3 Correct 4 ms 1408 KB Output is correct
4 Correct 6 ms 1700 KB Output is correct
5 Correct 6 ms 1692 KB Output is correct
6 Correct 6 ms 1756 KB Output is correct
7 Correct 5 ms 1748 KB Output is correct
8 Correct 6 ms 1700 KB Output is correct
9 Correct 13 ms 2888 KB Output is correct
10 Correct 14 ms 3060 KB Output is correct
11 Correct 14 ms 3036 KB Output is correct
12 Correct 4 ms 1408 KB Output is correct
13 Correct 4 ms 1408 KB Output is correct
14 Correct 4 ms 1288 KB Output is correct
15 Correct 4 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 3740 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 3836 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -