답안 #139518

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139518 2019-07-31T23:31:12 Z MohamedAhmed04 Amusement Park (JOI17_amusement_park) C++14
0 / 100
36 ms 4344 KB
#include <bits/stdc++.h>
#include "Joi.h"
//#include "grader.cpp"
//#include "Ioi.cpp"

using namespace std ;

const int _MAX = 10005 ;

int _vis[_MAX] ;

int _cnt = 0 ;

long long _x ;

vector< vector<int> >_adj(_MAX) ;

void dfss(int node)
{
	_vis[node] = 1 ;
	int assign ;
	if(_cnt >= 60)
		assign = 0 ;
	else
		assign = (_x & (1ll << _cnt)) ;
	if(assign)
		assign = 1 ;
	_cnt++ ;
	MessageBoard(node , assign) ;
	for(auto &child : _adj[node])
	{
		if(_vis[child])
			continue ;
		dfss(child) ;
	}
	return ;
}
void Joi(int N, int M, int A[], int B[], long long X, int T) 
{
	_x = X ;
	srand(123321) ;
    for(int i = 0 ; i < M ; ++i)
    {
  		_adj[A[i]].push_back(B[i]) ;
   	    _adj[B[i]].push_back(A[i]) ;
	}
	for(int i = 0 ; i < N ; ++i)
		sort(_adj[i].begin() , _adj[i].end()) ;
	for(int i = 0 ; i < N ; ++i)
		random_shuffle(_adj[i].begin() , _adj[i].end()) ;
	int node = rand() % N ;
	dfss(node) ;
	return ;
}
#include <bits/stdc++.h>
#include "Ioi.h"

using namespace std ;

const int MAX = 10005 ;

vector< vector<int> >adj(MAX) ; 

int par[MAX] , vis[MAX];

int root ;

void BFS(int node)
{
	queue<int>q ;
	q.push(node) ;
	par[node] = node ;
	while(!q.empty())
	{
		int node = q.front() ;
		q.pop() ;
		for(auto &child : adj[node])
		{
			if(par[child] != -1)
				continue ;
			par[child] = node ;
			q.push(child) ;
		}
	}
	return ;
}

int cnt = 0 ;

long long x = 0;

bool final = 0 ;
int v ;

int last = -1;

void dfs(int node , int parent)
{
	vis[node] = 1 ;
	if(cnt >= 60)
	{
		final = 1 ;
		return ;
	}
	int a ;
	if(parent == -1)
		a = last ;
	else
	    a = Move(node) ;
	if(a == 1)
	{
		x += (1ll << (cnt * 1ll)) ;
	}
	cnt++ ;
	if(cnt >= 60)
	{
		final = 1 ;
		return ;
	}
	for(auto &child : adj[node])
	{
		if(final)
			return ;
		if(vis[child])
			continue ;
		dfs(child , node) ;
		if(final)
			return ;
	}
	if(parent != -1)
		Move(parent) ;
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) 
{
	v = V ;
	memset(par , -1 , sizeof(par)) ;
	srand(123321) ;
    for(int i = 0 ; i < M ; ++i)
    {
  		adj[A[i]].push_back(B[i]) ;
   	    adj[B[i]].push_back(A[i]) ;
	}
	for(int i = 0 ; i < N ; ++i)
		sort(adj[i].begin() , adj[i].end()) ;
	for(int i = 0 ; i < N ; ++i)
		random_shuffle(adj[i].begin() , adj[i].end()) ; 
	BFS(P) ;
	root = rand() % N; ;
	vector<int>v ;
	int now = root; 
	while(true)
	{
		if(now == P)
			break ;
		v.push_back(now) ;
		now = par[now] ;
	}
	sort(v.begin() , v.end()) ;
	if(v.size() == 0)
		last = V ;
	else
	{
		for(int i = 0 ; i < v.size()-1 ; ++i)
			Move(v[i]) ;
		last = Move(v.back()) ; 
	}
	dfs(root , -1) ;
	return x ;
}

Compilation message

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:109:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0 ; i < v.size()-1 ; ++i)
                   ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1360 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 4336 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 1396 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 4344 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 4080 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -