답안 #57623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57623 2018-07-15T13:32:42 Z hamzqq9 Amusement Park (JOI17_amusement_park) C++14
0 / 100
61 ms 6816 KB
#include "Joi.h"
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define st first
#define nd second
#define pb push_back
#define MAX 20005
#define sz(x) ((int)x.size())
#define pw(x) (1LL<<(x))
 
static int Time;
static int beg[MAX];
static bool Bit[MAX],vis[MAX];
static vector<int> v[MAX];

static void createbits(ll x) {

	for(int i=0;i<60;i++) Bit[i]=((x>>i)&1);

}

static void dfs(int node,int ata) {

	vis[node]=true;

	beg[node]=Time++;

	MessageBoard(node,Bit[beg[node]%60]);

	for(int i:v[node]) {

		if(i==ata || vis[i]) continue ;

		dfs(i,node);

	}

}

void Joi(int N, int M, int A[], int B[], long long X, int T) {
  	
	createbits(X);

	for(int i=0;i<M;i++) {

		v[A[i]].pb(B[i]);
		v[B[i]].pb(A[i]);

	}

	dfs(0,-1);

}
#include "Ioi.h"
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define st first
#define nd second
#define pb push_back
#define MAX 20005
#define sz(x) ((int) x.size())
#define pw(x) (1LL<<(x))
 
static int sub[MAX],Par[MAX],beg[MAX];
static int Time,total,V,P;
static ll X;
static vector<int> v[MAX],v2[MAX];
static bool vis[MAX];

static void dfs2(int node,int ata) {

	if(total==60) return ;

	X|=V*pw(beg[node]%60);

	for(int i:v2[node]) {

		if(i==ata || total==60) continue ;

		total++;

		V=Move(i);

		dfs2(i,node);

		if(total<60) V=Move(node);

	}

}

static void solve() {

	total=1;

	while(1) {

		if(sub[P]>=60) break ;

		P=Par[P];

		V=Move(P);
	
	}

	dfs2(P,Par[P]);

}

static void dfs(int node,int ata) {

	vis[node]=true;

	sub[node]=1;

	beg[node]=Time++;

	Par[node]=ata;

	if(~ata) v2[ata].pb(node);

	for(int i:v[node]) {

		if(i==ata || vis[i]) continue ;

		dfs(i,node);

		sub[node]+=sub[i];

	}

}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
  
	for(int i=0;i<M;i++) {

		v[A[i]].pb(B[i]);
		v[B[i]].pb(A[i]);

	}

	::P=P;
	::V=V;

	dfs(0,-1);

	solve();

	return X;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2148 KB Output is correct
2 Incorrect 5 ms 2908 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 5728 KB Output is correct
2 Incorrect 36 ms 6792 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6816 KB Output is correct
2 Correct 7 ms 6816 KB Output is correct
3 Correct 9 ms 6816 KB Output is correct
4 Correct 9 ms 6816 KB Output is correct
5 Correct 7 ms 6816 KB Output is correct
6 Correct 10 ms 6816 KB Output is correct
7 Incorrect 9 ms 6816 KB Wrong Answer [7]
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 6816 KB Output is correct
2 Incorrect 34 ms 6816 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 6816 KB Output is correct
2 Incorrect 39 ms 6816 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -