Submission #130682

# Submission time Handle Problem Language Result Execution time Memory
130682 2019-07-15T20:08:17 Z tutis Amusement Park (JOI17_amusement_park) C++17
10 / 100
83 ms 7856 KB
#include "Joi.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
mt19937_64 rng(1561561);
int bitas[11000];
vector<int>adj[11000];
set<int>aplankyta;
int t = 0;
set<pair<int, int>>EE;
void dfs(int v, int p = -2)
{
	if (aplankyta.count(v))
		return;
	EE.insert({v, p});
	EE.insert({p, v});
	aplankyta.insert(v);
	t++;
	t %= 60;
	bitas[v] = t;
	for (int x : adj[v])
	{
		dfs(x, v);
	}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
	vector<int>PP(N);
	iota(PP.begin(), PP.end(), 0);
	shuffle(PP.begin(), PP.end(), rng);
	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++)
		shuffle(adj[i].begin(), adj[i].end(), rng);
	dfs(rng() % N);
	for (int i = 0; i < N; i++)
	{
		int s = 0;
		if ((X & (1ll << bitas[i])) > 0)
			s = 1;
		MessageBoard(i, s);
	}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
mt19937_64 rng(1561561);
int bitas[11000];
vector<int>adj[11000];
set<int>aplankyta;
int t = 0;
set<pair<int, int>>EE;
vector<int>order;
void dfs(int v, int p = -2)
{
	if (aplankyta.count(v))
		return;
	order.push_back(v);
	EE.insert({v, p});
	EE.insert({p, v});
	aplankyta.insert(v);
	t++;
	t %= 60;
	bitas[v] = t;
	bool ok = false;
	for (int x : adj[v])
	{
		if (aplankyta.count(x))
			continue;
		dfs(x, v);
		order.push_back(v);
		ok = true;
	}
	if (ok == false)
		order.push_back(v);
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
	vector<int>PP(N);
	iota(PP.begin(), PP.end(), 0);
	shuffle(PP.begin(), PP.end(), rng);
	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++)
		shuffle(adj[i].begin(), adj[i].end(), rng);
	dfs(rng() % N);
	ll X = 0;
	vector<int>stak = {P};
	set<int>bitai;
	set<int>aplankyti;
	int ii = find(order.begin(), order.end(), P) - order.begin();
	int c = -1;
	if (rng() % 2 == 0)
		c = 1;
	while (true)
	{
		X |= V * (1ll << bitas[P]);
		bitai.insert(bitas[P]);
		aplankyti.insert(P);
		if (bitai.size() == 60)
			break;
		int v1 = adj[P][rng() % adj[P].size()];
		for (int j : adj[P])
		{
			if (EE.count({j, P}) == 0)
				continue;
			if ((bitas[j] + 1) % 60 == bitas[P])
				v1 = j;
		}
		for (int j : adj[P])
		{
			if (EE.count({j, P}) == 0)
				continue;
			if (bitai.count(bitas[j]) == 0 && (bitas[P] + 1) % 60 == bitas[j])
				v1 = j;
		}
		V = Move(v1);
		P = v1;
	}
	return X;
}

Compilation message

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:52:6: warning: unused variable 'ii' [-Wunused-variable]
  int ii = find(order.begin(), order.end(), P) - order.begin();
      ^~
Ioi.cpp:53:6: warning: variable 'c' set but not used [-Wunused-but-set-variable]
  int c = -1;
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1264 KB Wrong Answer [8]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 69 ms 7192 KB Output is correct
2 Correct 69 ms 7360 KB Output is correct
3 Correct 73 ms 7460 KB Output is correct
4 Correct 55 ms 5824 KB Output is correct
5 Correct 47 ms 6736 KB Output is correct
6 Correct 51 ms 6080 KB Output is correct
7 Incorrect 52 ms 6208 KB Wrong Answer [8]
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1272 KB Output is correct
2 Correct 4 ms 1400 KB Output is correct
3 Correct 4 ms 1392 KB Output is correct
4 Correct 9 ms 2200 KB Output is correct
5 Correct 9 ms 2268 KB Output is correct
6 Correct 8 ms 2256 KB Output is correct
7 Correct 11 ms 2200 KB Output is correct
8 Correct 8 ms 2324 KB Output is correct
9 Correct 31 ms 6568 KB Output is correct
10 Correct 31 ms 6708 KB Output is correct
11 Correct 31 ms 6360 KB Output is correct
12 Correct 5 ms 1468 KB Output is correct
13 Correct 4 ms 1264 KB Output is correct
14 Correct 4 ms 1392 KB Output is correct
15 Correct 4 ms 1392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 7216 KB Output is correct
2 Correct 70 ms 7332 KB Output is correct
3 Correct 83 ms 7324 KB Output is correct
4 Incorrect 61 ms 5824 KB Wrong Answer [8]
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 70 ms 7232 KB Output is correct
2 Correct 70 ms 7736 KB Output is correct
3 Correct 71 ms 7856 KB Output is correct
4 Incorrect 53 ms 5912 KB Wrong Answer [8]
5 Halted 0 ms 0 KB -