Submission #51785

# Submission time Handle Problem Language Result Execution time Memory
51785 2018-06-21T07:30:27 Z ainta Amusement Park (JOI17_amusement_park) C++17
8 / 100
41 ms 6752 KB
#include "Joi.h"
#include <cstdio>
#include <algorithm>
#include <vector>
#define N_ 10100
using namespace std;

struct TTT {
	vector<int>E[N_];
	vector<int>G[N_];
	int Dep[N_], D[N_], C[N_], v[N_], par[N_];
	long long c = 0;
	struct point {
		int a, d;
		bool operator <(const point &p)const {
			return d > p.d;
		}
	};
	void DFS(int a, int pp) {
		C[a] = 1;
		D[a] = 1;
		v[a] = 1;
		vector<point>V;
		for (auto &x : E[a]) {
			if (v[x])continue;
			Dep[x] = Dep[a] + 1;
			DFS(x, a);
			D[a] = max(D[a], D[x] + 1);
			C[a] += C[x];
			par[x] = a;
			V.push_back({ x,D[x] });
		}
		if (!V.empty()) {
			sort(V.begin(), V.end());
			for (auto &x : V) {
				G[a].push_back(x.a);
			}
		}
	}
	int cnt = 0;
	long long xx;
	void Go(int a) {
		MessageBoard(a, (xx >> (cnt % 60)) & 1);
		cnt++;
		for (auto &x : G[a]) {
			Go(x);
		}
	}

}TT;
void Joi(int N, int M, int A[], int B[], long long X, int T) {
	TT.xx = X;
	int i;
	for (i = 0; i < M; i++) {
		TT.E[A[i]].push_back(B[i]);
		TT.E[B[i]].push_back(A[i]);
	}
	TT.DFS(0, -1);
	TT.Go(0);
}
#include "Ioi.h"

#include <cstdio>
#include <algorithm>
#include <vector>
#define N_ 10100
using namespace std;

vector<int>E[N_];
vector<int>G[N_];
int Dep[N_], D[N_], C[N_], par[N_], v[N_];
long long c = 0;
struct point {
	int a, d;
	bool operator <(const point &p)const {
		return d > p.d;
	}
};
void DFS(int a, int pp) {
	C[a] = 1;
	D[a] = 1;
	v[a] = 1;
	vector<point>V;
	for (auto &x : E[a]) {
		if (v[x])continue;
		Dep[x] = Dep[a] + 1;
		DFS(x, a);
		D[a] = max(D[a], D[x] + 1);
		C[a] += C[x];
		par[x] = a;
		V.push_back({ x,D[x] });
	}
	if (!V.empty()) {
		sort(V.begin(), V.end());
		for (auto &x : V) {
			G[a].push_back(x.a);
		}
	}
}
int cnt = 0, U[N_], Num[N_], Ed[N_], ReNum[N_];
long long xx;
void Go(int a) {
	U[a] = cnt % 60;
	cnt++;
	Num[a] = cnt;
	ReNum[cnt] = a;
	for (auto &x : G[a]) {
		Go(x);
	}
	Ed[a] = cnt;
}
int pv;
long long res;
void Add(int a, int x) {
	res += (1ll << U[a])*x;
}
void Calc(int a, int pp) {
	int ck = 0;
	if (a == pv)return;
	for (auto &x : G[a]) {
		if (Num[x] > 60)continue;
		if (Num[x] <= Num[pv] && Num[pv] <= Ed[x])continue;
		Add(x, Move(x));
		Calc(x, a);
	}
	for (auto &x : G[a]) {
		if (Num[x] <= Num[pv] && Num[pv] <= Ed[x]) {
			Add(x, Move(x));
			Calc(x, a);
			return;
		}
	}
	if (pp == -1) {
		while (1) {}
	}
	Move(pp);
	return;
}
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++) {
		E[A[i]].push_back(B[i]);
		E[B[i]].push_back(A[i]);
	}
	DFS(0, -1);
	Go(0);
	int a = P;
	while (a != 0 && D[a] < 60) {
		T = Move(par[a]);
		a = par[a];
	}
	Add(a, T);
	if (D[a] >= 60) {
		for (i = 0; i < 59; i++) {
			T = Move(G[a][0]);
			a = G[a][0];
			Add(a, T);
		}
		return res;
	}
	for (i = 1; i <= 60; i++) {
		if (Dep[ReNum[i]] == D[0]-1)pv = ReNum[i];
	}
	Calc(a,-1);
	return res;
}

Compilation message

Ioi.cpp: In function 'void Calc(int, int)':
Ioi.cpp:58:6: warning: unused variable 'ck' [-Wunused-variable]
  int ck = 0;
      ^~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1640 KB Output is correct
2 Correct 5 ms 1912 KB Output is correct
3 Correct 6 ms 1944 KB Output is correct
4 Correct 4 ms 2028 KB Output is correct
5 Correct 4 ms 2104 KB Output is correct
6 Correct 5 ms 2112 KB Output is correct
7 Correct 5 ms 2128 KB Output is correct
8 Correct 4 ms 2144 KB Output is correct
9 Correct 6 ms 2144 KB Output is correct
10 Correct 5 ms 2204 KB Output is correct
11 Correct 11 ms 2540 KB Output is correct
12 Correct 6 ms 2568 KB Output is correct
13 Correct 6 ms 2568 KB Output is correct
14 Correct 4 ms 2568 KB Output is correct
15 Correct 6 ms 2568 KB Output is correct
16 Correct 6 ms 2568 KB Output is correct
17 Correct 5 ms 2568 KB Output is correct
18 Correct 4 ms 2568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 6404 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 6616 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 6616 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 6752 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -