답안 #112843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
112843 2019-05-22T06:51:22 Z Mahdi_Jfri Amusement Park (JOI17_amusement_park) C++14
83 / 100
36 ms 5400 KB
#include "Joi.h"
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define pb push_back
#define bit(a , b) (((a)>>(b))&1)
 
const int maxn = 1e4 + 20;
 
vector<int> g1[maxn] , adj1[maxn] , shit1;
 
bool visited1[maxn];
 
int n1 , m1 , h1[maxn];
 
void plant1(int v)
{
	visited1[v] = 1;
	shit1.pb(v);
	for(auto u : g1[v])
		if(!visited1[u])
		{
			adj1[v].pb(u);
			h1[u] = h1[v] + 1;
			plant1(u);
		}
}
 
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
	n1 = N , m1 = M;
	for(int i = 0; i < m1; i++)
		g1[A[i]].pb(B[i]) , g1[B[i]].pb(A[i]);
	plant1(0);
 
	int val = *max_element(h1 , h1 + n1) + 1;
	if(val < 60)
	{
		for(int i = 0; i < n1; i++)
		{
			if(i < 60)
				MessageBoard(shit1[i] , bit(X , i));
			else
				MessageBoard(shit1[i] , bit(X , h1[shit1[i]]));
		}
	}
	else
		for(int i = 0; i < n1; i++)
			MessageBoard(i , (X >> (h1[i] % 60))&1);
}
 
 
 
 
 
 
 
 
 
 
 
 
 
#include "Ioi.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define bit(a , b) (((a)>>(b))&1)

const int maxn = 1e4 + 20;

vector<int> g[maxn] , adj[maxn] , shit;

bool visited[maxn] , have[maxn];

int n , m , h[maxn] , par[maxn] , Pos[maxn];

void plant(int v)
{
	visited[v] = 1;

	Pos[v] = shit.size();
	shit.pb(v);
	for(auto u : g[v])
		if(!visited[u])
		{
			adj[v].pb(u);
			h[u] = h[v] + 1;
			par[u] = v;
			plant(u);
		}
}

vector<int> go(int v)
{
	vector<int> res;
	while(v)
		res.pb(v) , v = par[v];
	res.pb(v);

	reverse(res.begin() , res.end());
	return res;
}

void getval(int st , ll &V , int v)
{
	if(st == v)
		return;
	auto b = go(v);

	int ind = -1;
	for(int i = 0; i < h[v] + 1; i++)
		if(b[i] == st)
			ind = i;

	if(ind == -1)
	{
		assert(st != par[st]);
		st = par[st];
		V = Move(st);
		getval(st , V , v);
	}
	else
	{
		assert(st != b[ind + 1]);
		st = b[ind + 1];
		V = Move(st);
		getval(st , V , v);
	}
}

ll Ioi(int N, int M, int A[], int B[], int st , int VV, int T)
{
	ll V = VV;
	n = N , m = M;
	for(int i = 0; i < m; i++)
		g[A[i]].pb(B[i]) , g[B[i]].pb(A[i]);
	plant(0);

	int val = *max_element(h , h + n) + 1;

	ll res = 0;
	if(val < 60)
	{
		while(Pos[st] >= 60)
		{
			res |= (V << h[st]) , have[h[st]] = 1;
			V = Move(par[st]);
			st = par[st];
		}

		for(int i = Pos[st]; i < 60; i++)
		{
			if(have[i])
				continue;

			getval(st , V , shit[i]);
			st = shit[i];
			res |= (V << i);
			have[i] = 1;
		}

		for(int i = 59; i >= 0; i--)
		{
			if(have[i])
				continue;
			have[i] = 1;

			getval(st , V , shit[i]);
			st = shit[i];
			res |= (V << i);
		}
	}
	else
	{
		if(h[st] + 1 < 60)
		{
			while(st)
				V = Move(par[st]) , st = par[st];

			auto tmp = go(max_element(h , h + n) - h);

			for(int i = 0; i < 60; i++)
			{
				if(st != tmp[i])
					V = Move(tmp[i]);
				st = tmp[i];
				res |= (V << i);
			}
		}
		else
		{
			for(int i = 0; i < 60; i++)
			{
				res |= (V << (h[st] % 60));
				if(st != par[st])
					V = Move(par[st]);
				st = par[st];
			}
		}
	}

	return res;
}









# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1696 KB Output is correct
2 Correct 4 ms 1664 KB Output is correct
3 Correct 6 ms 1932 KB Output is correct
4 Correct 4 ms 1432 KB Output is correct
5 Correct 4 ms 1800 KB Output is correct
6 Correct 4 ms 1664 KB Output is correct
7 Correct 4 ms 2032 KB Output is correct
8 Correct 4 ms 1800 KB Output is correct
9 Correct 5 ms 1668 KB Output is correct
10 Correct 4 ms 2048 KB Output is correct
11 Correct 7 ms 2096 KB Output is correct
12 Correct 4 ms 1664 KB Output is correct
13 Correct 5 ms 1804 KB Output is correct
14 Correct 5 ms 1804 KB Output is correct
15 Correct 4 ms 1796 KB Output is correct
16 Correct 4 ms 1668 KB Output is correct
17 Correct 4 ms 1668 KB Output is correct
18 Correct 4 ms 1896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 5332 KB Output is correct
2 Correct 28 ms 5340 KB Output is correct
3 Correct 28 ms 5212 KB Output is correct
4 Correct 19 ms 3844 KB Output is correct
5 Correct 18 ms 4608 KB Output is correct
6 Correct 19 ms 4288 KB Output is correct
7 Correct 19 ms 4272 KB Output is correct
8 Correct 19 ms 4160 KB Output is correct
9 Correct 20 ms 4288 KB Output is correct
10 Correct 17 ms 3724 KB Output is correct
11 Correct 17 ms 3656 KB Output is correct
12 Correct 18 ms 3528 KB Output is correct
13 Correct 18 ms 3556 KB Output is correct
14 Correct 17 ms 3768 KB Output is correct
15 Correct 17 ms 3904 KB Output is correct
16 Correct 19 ms 4156 KB Output is correct
17 Correct 19 ms 3912 KB Output is correct
18 Correct 19 ms 3776 KB Output is correct
19 Correct 20 ms 3776 KB Output is correct
20 Correct 15 ms 4288 KB Output is correct
21 Correct 15 ms 4296 KB Output is correct
22 Correct 19 ms 4120 KB Output is correct
23 Correct 19 ms 4240 KB Output is correct
24 Correct 19 ms 4052 KB Output is correct
25 Correct 19 ms 4160 KB Output is correct
26 Correct 18 ms 4160 KB Output is correct
27 Correct 18 ms 4168 KB Output is correct
28 Correct 19 ms 4240 KB Output is correct
29 Correct 17 ms 4024 KB Output is correct
30 Correct 17 ms 4024 KB Output is correct
31 Correct 4 ms 1800 KB Output is correct
32 Correct 4 ms 1928 KB Output is correct
33 Correct 4 ms 1932 KB Output is correct
34 Correct 4 ms 1908 KB Output is correct
35 Correct 4 ms 1664 KB Output is correct
36 Correct 4 ms 1928 KB Output is correct
37 Correct 5 ms 1800 KB Output is correct
38 Correct 4 ms 1924 KB Output is correct
39 Correct 4 ms 1692 KB Output is correct
40 Correct 4 ms 1688 KB Output is correct
41 Correct 4 ms 1912 KB Output is correct
42 Correct 4 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1916 KB Output is correct
2 Correct 4 ms 1664 KB Output is correct
3 Correct 4 ms 1412 KB Output is correct
4 Correct 6 ms 2204 KB Output is correct
5 Correct 6 ms 2204 KB Output is correct
6 Correct 6 ms 2368 KB Output is correct
7 Correct 6 ms 2340 KB Output is correct
8 Correct 6 ms 2204 KB Output is correct
9 Correct 15 ms 5312 KB Output is correct
10 Correct 16 ms 5320 KB Output is correct
11 Correct 17 ms 5284 KB Output is correct
12 Correct 5 ms 1928 KB Output is correct
13 Correct 5 ms 1692 KB Output is correct
14 Correct 4 ms 1664 KB Output is correct
15 Correct 4 ms 1664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 5204 KB Output is correct
2 Correct 28 ms 5400 KB Output is correct
3 Correct 27 ms 5204 KB Output is correct
4 Correct 19 ms 3784 KB Output is correct
5 Correct 20 ms 4832 KB Output is correct
6 Correct 20 ms 4336 KB Output is correct
7 Correct 19 ms 4296 KB Output is correct
8 Correct 16 ms 4080 KB Output is correct
9 Correct 19 ms 4160 KB Output is correct
10 Correct 16 ms 3728 KB Output is correct
11 Correct 17 ms 3776 KB Output is correct
12 Correct 17 ms 3512 KB Output is correct
13 Correct 17 ms 3512 KB Output is correct
14 Correct 18 ms 3760 KB Output is correct
15 Correct 19 ms 4040 KB Output is correct
16 Correct 17 ms 3776 KB Output is correct
17 Correct 18 ms 3824 KB Output is correct
18 Correct 19 ms 3828 KB Output is correct
19 Correct 19 ms 3908 KB Output is correct
20 Correct 15 ms 4296 KB Output is correct
21 Correct 15 ms 4288 KB Output is correct
22 Correct 19 ms 4168 KB Output is correct
23 Correct 36 ms 4296 KB Output is correct
24 Correct 19 ms 4040 KB Output is correct
25 Correct 19 ms 4160 KB Output is correct
26 Correct 19 ms 4296 KB Output is correct
27 Correct 20 ms 4340 KB Output is correct
28 Correct 20 ms 4040 KB Output is correct
29 Correct 17 ms 3888 KB Output is correct
30 Correct 19 ms 4024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 5332 KB Output is correct
2 Correct 27 ms 5372 KB Output is correct
3 Correct 28 ms 5376 KB Output is correct
4 Correct 19 ms 3716 KB Output is correct
5 Correct 19 ms 5176 KB Output is correct
6 Correct 19 ms 4320 KB Output is correct
7 Correct 19 ms 4312 KB Output is correct
8 Correct 19 ms 4592 KB Output is correct
9 Correct 19 ms 4536 KB Output is correct
10 Correct 17 ms 4068 KB Output is correct
11 Correct 17 ms 3984 KB Output is correct
12 Correct 18 ms 3780 KB Output is correct
13 Correct 34 ms 3804 KB Output is correct
14 Correct 18 ms 3884 KB Output is correct
15 Correct 19 ms 4144 KB Output is correct
16 Correct 19 ms 4200 KB Output is correct
17 Correct 18 ms 4016 KB Output is correct
18 Correct 19 ms 4100 KB Output is correct
19 Correct 18 ms 4024 KB Output is correct
20 Correct 17 ms 4580 KB Output is correct
21 Correct 15 ms 4536 KB Output is correct
22 Correct 19 ms 4408 KB Output is correct
23 Correct 18 ms 4408 KB Output is correct
24 Correct 19 ms 4416 KB Output is correct
25 Correct 19 ms 4408 KB Output is correct
26 Correct 18 ms 4280 KB Output is correct
27 Correct 19 ms 4628 KB Output is correct
28 Correct 19 ms 4576 KB Output is correct
29 Correct 17 ms 4376 KB Output is correct
30 Correct 18 ms 4268 KB Output is correct
31 Correct 4 ms 1692 KB Output is correct
32 Correct 4 ms 1804 KB Output is correct
33 Correct 4 ms 1800 KB Output is correct
34 Correct 4 ms 1804 KB Output is correct
35 Correct 4 ms 1668 KB Output is correct
36 Correct 5 ms 1804 KB Output is correct
37 Correct 4 ms 1668 KB Output is correct
38 Correct 5 ms 1712 KB Output is correct
39 Correct 5 ms 1816 KB Output is correct
40 Incorrect 6 ms 1900 KB Output isn't correct
41 Halted 0 ms 0 KB -