답안 #298197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298197 2020-09-12T14:36:56 Z pit4h Amusement Park (JOI17_amusement_park) C++14
10 / 100
33 ms 4528 KB
#include "Joi.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int _N = 1e4+1, _B = 60;
vector<int> g[_N];
bool vis[_N];
int cnt_preorder, preord[_N];
ll X;
void dfs(int x) {
	vis[x] = 1;
	preord[x] = cnt_preorder;	
	cnt_preorder++;
	for(int i: g[x]) {
		if(!vis[i]) {
			dfs(i);
		}
	}
}
void Joi(int N, int M, int A[], int B[], ll _X, int T) {
	// MessageBoard();
	X = _X;
	for(int i=0; i<M; ++i) {
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}
	for(int i=0; i<N; ++i) {
		sort(g[i].begin(), g[i].end());
	}
	dfs(0);
	for(int i=0; i<N; ++i) {
		int set_bit = preord[i]%_B;
		MessageBoard(i, (bool)(X&(1LL<<set_bit)));
	}
}
#include "Ioi.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int __N = 1e4+1;
const int bits = 60;
int par[__N];
bool added[bits];
int cur, val;
int cnt_mv;
int value[__N];
bool is_set[__N];
void mv(int from, int to) {
	if(from != cur || cnt_mv>=2*bits) {
		return;
	}
	cnt_mv++;
	cur = to;
	val = Move(to);
	value[cur] = val;
	is_set[cur] = 1;
}
void _dfs(int x, vector<int>& vis, vector<vector<int>>& g, vector<int>& preorder, int& nr) {
	vis[x] = 1;
	preorder[x] = nr;
	nr++;
	for(int i: g[x]) {
		if(!vis[i]) {
			par[i] = x;
			mv(x, i);
			_dfs(i, vis, g, preorder, nr);
		}
	}
	if(x != 0) {
		mv(x, par[x]);
	}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
	vector<vector<int>> g(N);
	vector<int> vis(N), preorder(N);
	int nr = 0;
	for(int i=0; i<M; ++i) {
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}
	for(int i=0; i<N; ++i) {
		sort(g[i].begin(), g[i].end());
	}
	cur = P;
	val = V;
	_dfs(0, vis, g, preorder, nr);
	ll X = 0;
	for(int i=0; i<N; ++i) {
		if(is_set[i]) {
			int bit = preorder[i]%bits;
			if(!added[bit]) {
				X += (ll)value[i] * (1LL<<bit);	
				added[bit]=1;
			}
		}
	}
	return X;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1040 KB Output is correct
2 Incorrect 2 ms 1024 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 4324 KB Output is correct
2 Correct 31 ms 4324 KB Output is correct
3 Incorrect 31 ms 4524 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1028 KB Output is correct
2 Correct 2 ms 1156 KB Output is correct
3 Correct 2 ms 1032 KB Output is correct
4 Correct 3 ms 1536 KB Output is correct
5 Correct 4 ms 1676 KB Output is correct
6 Correct 4 ms 1536 KB Output is correct
7 Correct 4 ms 1536 KB Output is correct
8 Correct 4 ms 1572 KB Output is correct
9 Correct 19 ms 4180 KB Output is correct
10 Correct 17 ms 4292 KB Output is correct
11 Correct 15 ms 4172 KB Output is correct
12 Correct 1 ms 1044 KB Output is correct
13 Correct 1 ms 1024 KB Output is correct
14 Correct 1 ms 1036 KB Output is correct
15 Correct 2 ms 1044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 4324 KB Output is correct
2 Correct 31 ms 4452 KB Output is correct
3 Incorrect 31 ms 4452 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 4528 KB Output is correct
2 Incorrect 31 ms 4452 KB Wrong Answer [7]
3 Halted 0 ms 0 KB -