답안 #1021056

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1021056 2024-07-12T13:25:01 Z 0npata Amusement Park (JOI17_amusement_park) C++17
0 / 100
19 ms 5592 KB
#include "Joi.h"

using namespace std;
#include<bits/stdc++.h>

#define vec vector

namespace joi {

const int MXN = 10'005;

int t = 0;

vec<int> tree[MXN];
int depth[MXN];
int ind[MXN];
vec<int> g[MXN];

void dfs1(int u, vec<bool>& vis) {
	vis[u] = true;
	for(int v : g[u]) {
		if(vis[v]) continue;
		dfs1(v, vis);
		depth[u] = max(depth[u], 1+depth[v]);
		tree[u].push_back(v);
	}
	sort(tree[u].begin(), tree[u].end(), [&](int x, int y) { return depth[x] > depth[y]; });
}

void dfs2(int u) {
	ind[u] = t;
	t += 1;
	for(int v : tree[u]) {
		dfs2(v);
	}
}

void Joi(int N, int M, int A[], int B[], long long X, int T) {

	vec<bool> vis(N);

	for(int i = 0; i<M; i++) {
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}


	dfs1(0, vis);

	dfs2(0);


	for(int i = 0; i < N; i++){
		int bi = ind[i] % 60;

		int val = (X & ((long long)1<<bi)) != 0;
		MessageBoard(i, val);

	}
}

}


void Joi(int N, int M, int A[], int B[], long long X, int T) { joi::Joi(N, M, A, B, X, T); };
#include "Ioi.h"
#include<bits/stdc++.h>

using namespace std;

#define vec vector

namespace ioi {


	const int MXN = 10'005;

	vec<int> g[MXN];
	int par[MXN];
	int sz[MXN];

	vec<int> vals(MXN, -1);

	int t = 0;

	vec<int> tree[MXN];
	int depth[MXN];
	int ind[MXN];

	void dfs1(int u, vec<bool>& vis) {
		vis[u] = true;
		sz[u] = 1;
		for(int v : g[u]) {
			if(vis[v]) continue;
			par[v] = u;
			dfs1(v, vis);
			depth[u] = max(depth[u], 1+depth[v]);
			sz[u] += sz[v];
			tree[u].push_back(v);
		}
		sort(tree[u].begin(), tree[u].end(), [&](int x, int y) { return depth[x] == depth[y] ? x < y : depth[x] > depth[y]; });
	}

	void dfs2(int u) {
		ind[u] = t++;
		for(int v : tree[u]) {
			dfs2(v);
		}
	}

	void dfs3(int u, vec<int>& mvs, int rem) {
		rem -= 1;
		for(int v : tree[u]) {
			if(rem <= 0) {
				return;
			}
			mvs.push_back(v);
			dfs3(v, mvs, rem);
			rem -= sz[v];
			mvs.push_back(u);
		}
	}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {

	for(int i = 0; i<M; i++) {
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}

	vec<bool> vis(N);
	dfs1(0, vis);
	dfs2(0);

	long long x = 0;

	vals[P] = V;

	int cur = P;
	int cnt = 0;
	//while(sz[cur] < 60) {
	//	cnt++;
		//int cur_val = Move(par[cur]);

		//cur = par[cur];

		//vals[cur] = cur_val;
	//}

	vec<int> mvs(0);

	dfs3(cur, mvs, 60);

	//reverse(mvs.begin(), mvs.end());


	for(int i = 0; i<mvs.size(); i++) {
		int nxt = mvs[i];
		//vals[nxt] = Move(nxt);
	}

	for(int i = 0; i<N; i++) {
		if(vals[i] != -1) {
			int bi = ind[i]%60;
			x |= (((long long)vals[i]) << bi);
		}
	}
	return x;
}
}


long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) { return ioi::Ioi(N, M, A, B, P, V, T); }

Compilation message

Ioi.cpp: In function 'long long int ioi::Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:92:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |  for(int i = 0; i<mvs.size(); i++) {
      |                 ~^~~~~~~~~~~
Ioi.cpp:93:7: warning: unused variable 'nxt' [-Wunused-variable]
   93 |   int nxt = mvs[i];
      |       ^~~
Ioi.cpp:75:6: warning: unused variable 'cnt' [-Wunused-variable]
   75 |  int cnt = 0;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1808 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 5216 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1808 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 5212 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 5592 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -