답안 #205570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
205570 2020-02-29T08:17:47 Z ArshiaDadras Amusement Park (JOI17_amusement_park) C++14
0 / 100
40 ms 4376 KB
/* In the name of Allah */
#include<bits/stdc++.h>
#include<Joi.h>
using namespace std;

const int N = 1e4 + 5;
vector<int> adj[N], V;
bool mark[N];

void dfs(int u) {
	mark[u] = true, V.push_back(u);
	for (auto v: adj[u])
		if (!mark[v])
			dfs(v);
}

void Joi(int n, int m, int a[], int b[], long long x, int t) {
	V.clear();
	for (int u = 0; u < n; u++)
		adj[u].clear();
	memset(mark, false, sizeof mark);
	for (int i = 0; i < m; i++) {
		adj[a[i]].push_back(b[i]);
		adj[b[i]].push_back(a[i]);
	}
	dfs(0);
	for (int i = 0; i < n; i++)
		MessageBoard(V[i], x >> i % 60 & 1);
}
/* In the name of Allah */
#include<bits/stdc++.h>
#include<Ioi.h>
using namespace std;

const int N = 1e4 + 5;
vector<int> adj[N], V, path;
long long answer;
int root, id;
bool mark[N];

void build(int u) {
	mark[u] = true, V.push_back(u);
	for (auto v: adj[u])
		if (!mark[v])
			build(v);
}

bool go(int u) {
	mark[u] = true;
	if (u == root)
		return true;
	for (auto v: adj[u])
		if (!mark[v] && go(v)) {
			path.push_back(v);
			return true;
		}
	return false;
}

void dfs(int u, long long b) {
	mark[u] = true;
	answer |= b << id++;
	for (auto v: adj[u])
		if (!mark[v] && id < 60) {
			dfs(v, Move(v));
			if (id < 60)
				Move(u);
		}
}

long long Ioi(int n, int m, int a[], int b[], int p, int v, int t) {
	answer = id = 0;
	V.clear(), path.clear();
	for (int u = 0; u < n; u++)
		adj[u].clear();
	memset(mark, false, sizeof mark);
	for (int i = 0; i < m; i++) {
		adj[a[i]].push_back(b[i]);
		adj[b[i]].push_back(a[i]);
	}
	build(0), memset(mark, false, sizeof mark);
	for (int i = 0; i < n; i++)
		if (V[i] == p)
			root = V[i - i % 60];
	go(p), reverse(path.begin(), path.end());
	for (auto u: path)
		v = Move(p = u);
	memset(mark, false, sizeof mark), dfs(p, v);
	return answer;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1368 KB Output is correct
2 Incorrect 10 ms 1508 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 4188 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1396 KB Output is correct
2 Correct 10 ms 1536 KB Output is correct
3 Incorrect 10 ms 1364 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 4360 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 4376 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -