Submission #27126

# Submission time Handle Problem Language Result Execution time Memory
27126 2017-07-09T12:39:12 Z RayaBurong25_1 Amusement Park (JOI17_amusement_park) C++14
0 / 100
1652 ms 212120 KB
#include <stdio.h>
#include "Joi.h"
#include <vector>
#include <set>
#define SZ 60
static std::vector<int> AdjList[10005];
static std::set<int> Set[10005];
static int Vis[10005];
static int Role[10005];
static void FirstSet(int u, int pa)
{
	if (Set[0].size() < SZ)
	{
		Role[u] = Set[0].size();
		Set[0].insert(u);
	}
	int i, v, s = AdjList[u].size();
	Vis[u] = 1;
	for (i = 0; i < s; i++)
	{
		v = AdjList[u][i];
		if (v != pa && !Vis[v])
		{
			FirstSet(v, u);
		}
	}
}
static void OtherSet(int u, int pa)
{
	int i, j, v, s, d;
	if (u != 0)
	{
		Set[u] = Set[pa];
		if (Set[u].find(u) == Set[u].end())
		{
			std::set<int>::iterator it;
			for (it = Set[u].begin(); it != Set[u].end(); it++)
			{
				if (*it == pa)
					continue;
				s = AdjList[*it].size();
				d = 0;
				for (j = 0; j < s; j++)
				{
					if (Set[*it].find(AdjList[*it][j]) != Set[*it].end())
						d++;
				}
				if (d == 1)
					break;
			}
			if (it != Set[u].end())
			{
				Role[u] = Role[*it];
				Set[u].erase(it);
			}
			Set[u].insert(u);
		}
	}
	s = AdjList[u].size();
	for (i = 0; i < s; i++)
	{
		v = AdjList[u][i];
		if (v != pa && Set[v].size() == 0)
		{
			OtherSet(v, u);
		}
	}
}
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
	int i;
	for (i = 0; i < M; i++)
	{
		AdjList[A[i]].push_back(B[i]);
		AdjList[B[i]].push_back(A[i]);
	}
	FirstSet(0, -1);
	// printf("FirstSet fin\n");
	OtherSet(0, -1);

	int val[SZ];
	for (i = 0; i < SZ; i++)
	{
		val[i] = X%2;
		X >>= 1;
	}
	for (i = 0; i < N; i++)
	{
		MessageBoard(i, val[Role[i]]);
	}
	// printf("Joi fin\n");
}
#include <stdio.h>
#include "Ioi.h"
#include <vector>
#include <set>
#define SZ 60
static std::vector<int> AdjList[10005];
static std::set<int> Set[10005];
static int Vis[10005];
static int Role[10005];
static void FirstSet(int u, int pa)
{
	if (Set[0].size() < SZ)
	{
		Role[u] = Set[0].size();
		Set[0].insert(u);
	}
	int i, v, s = AdjList[u].size();
	Vis[u] = 1;
	for (i = 0; i < s; i++)
	{
		v = AdjList[u][i];
		if (v != pa && !Vis[v])
		{
			FirstSet(v, u);
		}
	}
}
static void OtherSet(int u, int pa)
{
	int i, j, v, s, d;
	if (u != 0)
	{
		Set[u] = Set[pa];
		if (Set[u].find(u) == Set[u].end())
		{
			std::set<int>::iterator it;
			for (it = Set[u].begin(); it != Set[u].end(); it++)
			{
				if (*it == pa)
					continue;
				s = AdjList[*it].size();
				d = 0;
				for (j = 0; j < s; j++)
				{
					if (Set[*it].find(AdjList[*it][j]) != Set[*it].end())
						d++;
				}
				if (d == 1)
					break;
			}
			if (it != Set[u].end())
			{
				Role[u] = Role[*it];
				Set[u].erase(it);
			}
			Set[u].insert(u);
		}
	}
	s = AdjList[u].size();
	for (i = 0; i < s; i++)
	{
		v = AdjList[u][i];
		if (v != pa && Set[v].size() == 0)
		{
			OtherSet(v, u);
		}
	}
}
static int val[SZ];
void GetVal(int P, int u, int pa)
{
	int i, v, s = AdjList[u].size();
	for (i = 0; i < s; i++)
	{
		v = AdjList[u][i];
		if (v != pa && !Vis[v] && Set[P].find(v) != Set[P].end())
		{
			val[Role[v]] = Move(v);
			GetVal(P, v, u);
			Move(u);
		}
	}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
	int i;
	for (i = 0; i < M; i++)
	{
		AdjList[A[i]].push_back(B[i]);
		AdjList[B[i]].push_back(A[i]);
	}
	FirstSet(0, -1);
	OtherSet(0, -1);

	val[P] = V;
	for (i = 0; i < N; i++)
		Vis[i] = 0;
	GetVal(P, P, -1);

	long long X = 0;
	for (i = SZ - 1; i >= 0; i--)
	{
		X <<= 1;
		X += val[i];
	}
	return X;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5156 KB Output is correct
2 Correct 0 ms 5420 KB Output is correct
3 Correct 3 ms 6476 KB Output is correct
4 Incorrect 0 ms 5156 KB Wrong Answer [7]
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1392 ms 189848 KB Wrong Answer [8]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5156 KB Output is correct
2 Correct 0 ms 5156 KB Output is correct
3 Incorrect 0 ms 5156 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1652 ms 212120 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1192 ms 176220 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -