Submission #56944

# Submission time Handle Problem Language Result Execution time Memory
56944 2018-07-13T09:13:06 Z hamzqq9 Amusement Park (JOI17_amusement_park) C++14
0 / 100
15 ms 4000 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 10005
#define pw(x) (1LL<<(x))

int N,M,X,CurBit,A[MAX],B[MAX],Bit[MAX],VAL[MAX];
vector<int> v[MAX];

void CreateGraph() {

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

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

	}

}

void CreateBits() {

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

		Bit[i]=((X&pw(i))>0);

	}

}

void SpanningTree(int node,int ata) {

	if(CurBit==59) return ;

	MessageBoard(node,Bit[++CurBit]);

	for(int child:v[node]) {

		if(child==ata) continue ;

		SpanningTree(child,node);

	}

}

void SUB2() {

	CreateGraph();
	CreateBits();

	CurBit=-1;

	SpanningTree(0,-1);

}

void SUB3() {

}

void SUB4() {

}

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

	::X=X;

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

		::A[i]=A[i];
		::B[i]=B[i];

	}

	for(int i=0;i<N;i++) VAL[i]=-1;

	if(T==1 || T==4) SUB4();

	if(T==2) SUB2();

	if(T==3) SUB3();

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

		if(~VAL[i]) continue ;

		MessageBoard(i,0);

	}

}
#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 10005
#define pw(x) (1LL<<(x))

int CurBit,M,N,P,V;
int A[MAX],B[MAX];
vector<int> v[MAX],v2[MAX];
ll X;

void CreateGraph() {

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

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

	}

}

void SpanningTree(int node,int ata) {

	if(CurBit==59) return ;

	++CurBit;

	if(~ata) {

		v2[ata].pb(node);

	}

	for(int child:v[node]) {

		if(child==ata) continue ;

		SpanningTree(child,node);

	}

}

void dfs(int node,int ata) {

	++CurBit;

	X+=pw(CurBit)*V;

	for(int child:v2[node]) {

		V=move(child);

		dfs(child,node);

		if(CurBit<59) V=move(node);

	}

}

int dist[MAX];
bool vis[MAX];

void findPath(int TO) {

	queue< pair<int,int> > Q;

	for(int i=0;i<N;i++) dist[i]=N+10,vis[i]=0;

	Q.push({TO,0});

	while(!Q.empty()) {

		pair<int,int> cur=Q.front();

		Q.pop();

		if(vis[cur.st]) continue ;

		vis[cur.st]=true;

		dist[cur.st]=cur.nd;

		for(int child:v[cur.st]) {

			Q.push({child,cur.nd+1});

		}

	}

	while(P!=TO) {

		for(int child:v[P]) {

			if(dist[child]==dist[P]-1) {

				V=move(child);

				P=child;

				break ;

			}

		}

	}

}

ll SUB2() {

	CreateGraph();

	CurBit=-1;

	SpanningTree(0,-1);

	findPath(0);

	CurBit=-1;

	dfs(P,-1);

	return X;

}

ll SUB4() {

	return -1;

}

ll SUB3() {

	return -1;

}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
  
	::N=N;
	::M=M;
	::P=P;
	::V=V;

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

		::A[i]=A[i];
		::B[i]=B[i];

	}

	if(T==1 || T==4) return SUB4();

	if(T==2) return SUB2();

	if(T==3) return SUB3();	

	assert(0); 

}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1620 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 3128 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 3128 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 3696 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 4000 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -