답안 #41770

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41770 2018-02-21T07:58:02 Z RockyB Amusement Park (JOI17_amusement_park) C++14
0 / 100
49 ms 27056 KB
/// In The Name Of God

#include <bits/stdc++.h>
#include "Joi.h"

#define ioi exit(0);

using namespace std;

const int N1 = 1e5 + 7;

vector <int> g[N1];

bool was[N1];
int cnt;
void dfs(int v, long long x) {
	was[v] = 1;
	if (cnt <= 59) {
		int type = (x & (1LL << cnt)) > 0;
		MessageBoard(v, type);
	}
	else {
		MessageBoard(v, 0);
	}
	++cnt;
	for (auto to : g[v]) {
		if (!was[to]) dfs(to, x);
	}
}
void Joi(int n, int m, int a[], int b[], long long x, int T) {
	for (int i = 0; i < m; i++) {
		g[a[i]].push_back(b[i]);
		g[b[i]].push_back(a[i]);
	}
	dfs(0, x);
}

/*int32_t main() {

	return 0;
}*/

/*#ifdef IOI2018
int main() {
	freopen ("in.txt", "r", stdin);
	
	ioi
}
#endif
*/
/// In The Name Of God

#include "Ioi.h"
#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

static const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

using namespace std;



map <int, int> dp;
int ask(int p) {
	if (dp.count(p)) return dp[p];
	return dp[p] = Move(p);
}


int n;
vector <int> g[N];

ll res;

int last;
bool found;
bool was[N];

int len;
void dfs(int v) {
	was[v] = 1;
	if (found || !v) {
		found = 1;
		return;
	}
	for (auto to : g[v]) {
		if (!was[to] && !found) {
			last = ask(to);
			dfs(to);
			if (!found) {
				last = ask(v);
			}
		}
	}
}

int cnt;
void dfs1(int v) {
	was[v] = 1;
	if (cnt <= 59) {
		res += (1LL << cnt) * ask(v);
	}
	cnt++;
	if (cnt >= 60) return;
	for (auto to : g[v]) {
		if (!was[to]) {
			last = ask(to);
			dfs1(to);
			if (cnt >= 60) return;
			ask(v);
		}
	}
}

ll 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]].pb(b[i]);
		g[b[i]].pb(a[i]);
	}
	last = v;
	dp[p] = v;
	dfs(p);
	memset(was, 0, sizeof(was));
	dfs1(0);
	return res;
}	

/*#ifdef IOI2018
int main() {
	freopen ("in.txt", "r", stdin);
	
	ioi
}
#endif*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 14900 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 43 ms 25512 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 26584 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 49 ms 26820 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 47 ms 27056 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -