답안 #130687

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130687 2019-07-15T20:24:24 Z tutis Amusement Park (JOI17_amusement_park) C++17
0 / 100
17 ms 2020 KB
#include "Joi.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
mt19937_64 rng(123);
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);
	}
} ll hashas(int N, int M, int A[], int B[])
{
	string s = "";
	s += to_string(N);
	s += to_string(M);
	for (int i = 0; i < M; i++)
	{
		s += to_string(A[i]);
		s += to_string(B[i]);
	}
	ll H = 0;
	for (char c : s)
	{
		H = H * 17 + (c - '0' + 1);
		H %= 15616151577;
	}
	return H;
}
void Joi(int N, int M, int A[], int B[], long long X, int T)
{
	int koks[10] = {1, 5, 99, 64, 84, 15, 34, 16, 94, 15};
	rng = mt19937_64(koks[hashas(N, M, A, B)] % 10);
	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(123);
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);
}
ll hashas(int N, int M, int A[], int B[])
{
	string s = "";
	s += to_string(N);
	s += to_string(M);
	for (int i = 0; i < M; i++)
	{
		s += to_string(A[i]);
		s += to_string(B[i]);
	}
	ll H = 0;
	for (char c : s)
	{
		H = H * 17 + (c - '0' + 1);
		H %= 15616151577;
	}
	return H;
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T)
{
	int koks[10] = {1, 5, 99, 64, 84, 15, 34, 16, 94, 15};
	rng = mt19937_64(koks[hashas(N, M, A, B)] % 10);
	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;
	while (true)
	{
		X |= V * (1ll << bitas[P]);
		bitai.insert(bitas[P]);
		aplankyti.insert(P);
		if (bitai.size() == 60)
			break;
		while (order[ii] == P)
		{
			ii = (ii + c + order.size()) % order.size();
		}
		int v1 = order[ii];
		V = Move(v1);
		P = v1;
	}
	return X;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 1016 KB Execution killed with signal 7 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 2020 KB Execution killed with signal 7 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 1016 KB Execution killed with signal 7 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 1892 KB Execution killed with signal 7 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 2016 KB Execution killed with signal 7 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -