답안 #257629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257629 2020-08-04T13:44:22 Z Blagojce Amusement Park (JOI17_amusement_park) C++17
10 / 100
36 ms 11996 KB
#include <bits/stdc++.h> 
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
#include <time.h>
#include <cmath>
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
 
const int i_inf = 1e9;
const ll inf = 1e17;
const ll mod = 1000000007;
const ld eps = 1e-13;
const ld pi  = 3.14159265359;
 
mt19937 _rand(time(NULL));
clock_t timer = clock();
const int mxn = 1e5;

#include "Joi.h"
/*int VAL[mxn];
void MessageBoard(int u, int val){
	VAL[u] = val;
	return;
}*/

int n, m;
int a[mxn], b[mxn];
bool vis[mxn];
vector<int> g[mxn];


int itopos[mxn];
int postoi[mxn];
int temp_p = 0;
int depth[mxn];
int mx_depth[mxn];

void dfs(int u){
	itopos[u] = temp_p;
	postoi[temp_p] = u;
	++temp_p;
	
	vis[u] = true;
	mx_depth[u] = depth[u];
	
	for(auto e : g[u]){
		if(vis[e]) continue;
		depth[e] = depth[u] + 1;
		dfs(e);
		mx_depth[u] = max(mx_depth[u], mx_depth[e]);
	}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
	n = N, m = M;
	fr(i, 0, m) a[i] = A[i], b[i] = B[i];
	fr(i, 0, m){
		g[a[i]].pb(b[i]);
		g[b[i]].pb(a[i]);
	}
	dfs(0);
	if(mx_depth[0] < 59){
		fr(i, 0, n){
			if(X&(1LL<<(i%60))) MessageBoard(postoi[i],1); 
			else MessageBoard(postoi[i],0);
		}
	}
	else{
		fr(i, 0, n){
			if(X&(1LL<<(depth[i]%60))) MessageBoard(postoi[i],1);
			else MessageBoard(postoi[i],0);
		}
	}
}
#include <bits/stdc++.h> 
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
#include <time.h>
#include <cmath>
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
 
const int i_inf = 1e9;
const ll inf = 1e17;
const ll mod = 1000000007;
const ld eps = 1e-13;
const ld pi  = 3.14159265359;
 
mt19937 _rand(time(NULL));
clock_t timer = clock();
const int mxn = 1e5;
#include "Ioi.h"
/*
int mark[60] = {1,1,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int Move(int u){
	cout<<u<<endl;
	return mark[u];
}*/

int n, m;
int a[mxn], b[mxn];
bool vis[mxn];
vector<int> g[mxn];


int itopos[mxn];
int postoi[mxn];
int temp_p = 0;
int depth[mxn];
int mx_depth[mxn];

int parent[mxn];
int best_child[mxn];

vector<int> G[mxn];

vector<int> v;
int val[mxn];

void dfs(int u, int p){
	v.pb(u);
	
	parent[u] = p;
	itopos[u] = temp_p;
	postoi[temp_p] = u;
	++temp_p;
	
	vis[u] = true;
	mx_depth[u] = depth[u];
	
	best_child[u] = u;
	
	for(auto e : g[u]){
		if(vis[e]) continue;
		G[u].pb(e);
		
		depth[e] = depth[u] + 1;
		dfs(e, u);
		v.pb(u);
		
		if(mx_depth[u] < mx_depth[e]){
			mx_depth[u] = mx_depth[e];
			best_child[u] = e;
		}
	}
}



long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
	n = N, m = M;
	fr(i, 0, m) a[i] = A[i], b[i] = B[i];
	fr(i, 0, m){
		g[a[i]].pb(b[i]);
		g[b[i]].pb(a[i]);
	}
	dfs(0, 0);
	if(mx_depth[0] < 59){
		memset(val, -1, sizeof(val));
		val[P] = V;
		
		int pos;
		fr(i, 0, (int)v.size()){
			if(v[i] == P){
				pos = i;
				break;
			}
		}
		int done = 1;
		while(done < 60){
			++pos;
			if(pos == (int)v.size()) pos = 0;
			V = Move(v[pos]);
			if(val[v[pos]] == -1){
				val[v[pos]] = V;
				++done;
			}
		}
		int tmp = itopos[P];
		ll X = 0;
		fr(i, 0, 60){
			X |= (1LL << i)*val[postoi[(tmp+i)%n]];
		}
		return X;
	}
	else{
		while(depth[P]%60 != 0){
			V = Move(parent[P]);
			P = parent[P];
		}
		ll X = 0;
		if(mx_depth[P]-depth[P] < 59){
			fr(i, 0, 60){
				V = Move(parent[P]);
				P = parent[P];
				X |= (1LL<<(59-i))*V;
			}	
		}
		else{
			X |= (1LL << 0) * V;
			fr(i, 1, 60){
				V = Move(best_child[P]);
				P = best_child[P];
				X |= (1LL << i) * V;
			}
		}
		return X;
	}
}

Compilation message

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:104:4: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
    ++pos;
    ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 8196 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 11876 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 7972 KB Output is correct
2 Correct 6 ms 7980 KB Output is correct
3 Correct 6 ms 7956 KB Output is correct
4 Correct 8 ms 8552 KB Output is correct
5 Correct 7 ms 8556 KB Output is correct
6 Correct 7 ms 8372 KB Output is correct
7 Correct 8 ms 8556 KB Output is correct
8 Correct 7 ms 8372 KB Output is correct
9 Correct 19 ms 11612 KB Output is correct
10 Correct 18 ms 11692 KB Output is correct
11 Correct 19 ms 11764 KB Output is correct
12 Correct 6 ms 7816 KB Output is correct
13 Correct 6 ms 7976 KB Output is correct
14 Correct 6 ms 7984 KB Output is correct
15 Correct 6 ms 7816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 11996 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 11996 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -