답안 #910181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
910181 2024-01-18T01:07:12 Z Maaxle Amusement Park (JOI17_amusement_park) C++17
0 / 100
19 ms 5760 KB
#include <bits/stdc++.h>
#include "Joi.h"

#define ll long long
#define range(i, a, b) for (ll i = a; i < b; i++)
#define all(x) begin(x), end(x)
#define INF ((ll) 1 << 60)
#define pqueue priority_queue

using namespace std;

ll x;
vector<vector<ll>> adj;
vector<bool> memo;

void dfs (ll i, ll dig) {
	memo[i] = 1;
	MessageBoard(i, (int) ((x & (1ll << dig)) > 0));
	for (ll k : adj[i]) {
		if (!memo[k])
			dfs(k, (dig + 1) % 60);
	}
}

void Joi(int N, int M, int A[], int B[], long long X, int T) {
	adj.resize(N);
	memo.resize(N);
	x = X;

	range(i, 0, M) {
		adj[A[i]].push_back(B[i]);
		adj[B[i]].push_back(A[i]);
	}
	dfs(0, 0);
}
#include <bits/stdc++.h>
#include "Ioi.h"

#define ll long long
#define range(i, a, b) for (ll i = a; i < b; i++)
#define all(x) begin(x), end(x)
#define INF ((ll) 1 << 60)
#define pqueue priority_queue

using namespace std;

struct TPos {
	ll node, dig;
};
bool operator < (const TPos& i, const TPos& j) { return i.node < j.node; }

ll p;
ll p_it = -1;
vector<vector<ll>> adj;
vector<bool> memo;
vector<ll> path;
vector<TPos> pre;

void dfs (ll i) {
	memo[i] = 1;
	path.push_back(i);

	if (i == p && p_it == -1)
		p_it = path.size() - 1;

	if (pre.empty())
		pre.push_back({i, 0});
	else 
		pre.push_back({i, (pre.back().dig + 1) % 60});

	for (ll k : adj[i]) {
		if (!memo[k])
			dfs(k);
	}

	if (path.back() != i)
		path.push_back(i);
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
	adj.resize(N);
	memo.resize(N);
	p = P;

	range(i, 0, M) {
		adj[A[i]].push_back(B[i]);
		adj[B[i]].push_back(A[i]);
	}
	dfs(0);
	sort(all(pre));

	vector<ll> freq (60);
	ll l = p_it, r = p_it;
	freq[pre[path[p_it]].dig]++;
	ll cnt = 1;
	while (r < path.size() - 1 && r - p_it + 1 < 250) {
		r++;
		freq[pre[path[r]].dig]++;
		if (freq[pre[path[r]].dig] == 1) cnt++;
	}

	while (l > 0 && r - l + 1 < 250) {
		l--;
		freq[pre[path[l]].dig]++;
		if (freq[pre[path[l]].dig] == 1) cnt++;
	}

	while (cnt < 60) {
		l--;
		freq[pre[path[l]].dig]++;
		if (freq[pre[path[l]].dig] == 1) cnt++;

		freq[pre[path[r]].dig]--;
		if (freq[pre[path[r]].dig] == 0) cnt--;
		r--;
	}

	ll ans = 0;
	range(i, p_it, r + 1) {
		if (path[i] == P) {
			ans |= ((ll) V << pre[path[i]].dig);
			continue;
		}
		ans |= (Move(path[i]) << pre[path[i]].dig);
	}

	for (ll i = r - 1; i >= r; i++) {
		if (path[i] == P) {
			ans |= ((ll) V << pre[path[i]].dig);
			continue;
		}
		ans |= (Move(path[i]) << pre[path[i]].dig);
	}

	return ans;
}

Compilation message

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:61:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |  while (r < path.size() - 1 && r - p_it + 1 < 250) {
      |         ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 792 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 5324 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 792 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 5760 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 5240 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -