Submission #112838

# Submission time Handle Problem Language Result Execution time Memory
112838 2019-05-22T06:45:35 Z MAMBA Amusement Park (JOI17_amusement_park) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "Joi.h"

using namespace std;

typedef long long ll;
typedef vector<int> vi;
#define rep(i , j , k) for(int i = j; i < (int)k; i++)
#define pb push_back

constexpr int N = 1e4 + 10;

void Joi(int n, int m, int a[] , int b[], ll x , int t) {
	init(n , m , a , b);
	if (len >= 60) {
		rep(i , 0 , n) 
			MessageBoard(i , (x >> (lvl[i] % 60)) & 1);		
	}
	else {
		int root2 = max_element(lvl , lvl + n) - lvl;
		m1.reset();
		dfs2(root , root2);
		dfs3(root);
		rep(i , 0 , n)
			MessageBoard(i , (x >> (val[i] - 1)) & 1);	
	}
	return;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
#define rep(i , j , k) for(int i = j; i < (int)k; i++)
#define pb push_back

constexpr int N = 1e4 + 10;

ll res , cnt;

int root = -1, len = -1;
int lvl[N], val[N];
vi adj[N];
bitset<N << 1> m1, m2;

void dfs0(int v, int a[], int b[]) {
	m1[v] = true;
	for (auto e : adj[v]) {
		int u = v ^ a[e] ^ b[e];
		if (!m1[u]) {
			m2[e] = true;
			dfs0(u, a, b);
		}
	}
}

void dfs1(int v, int par = -1) {
	for (auto e : adj[v])
		if (par ^ e) {
			lvl[e] = lvl[v] + 1;
			dfs1(e , v);
		}
}

bool dfs2(int v , int dst , int par = -1) {
	for (auto e :adj[v])
		if (e ^ par && dfs2(e  , dst , v)) {
			m1[v] = true;
			val[v] = ++cnt;
			return true;
		}
}

void dfs3(int v, int par = -1) {
	if (!m1[v]) val[v] = ++cnt;
	for (auto e :adj[v]) 
		if (e ^ par)
			dfs3(e , v);
}

inline void init(int n , int m , int a[], int b[]) {
  res = 0;
  cnt = 0;
  m1.reset();
  m2.reset();
  rep(i , 0 , n) adj[i].clear();
	rep(i , 0 , m) 
	{	adj[a[i]].pb(i);
		adj[b[i]].pb(i);
	}
	dfs0(0, a, b);
	rep(i , 0 , n) adj[i].clear();
	rep(i , 0 , m) if(m2[i]) {
		adj[a[i]].pb(b[i]);
		adj[b[i]].pb(a[i]);
	}
	lvl[0] = 1;
	dfs1(0);
	root = max_element(lvl , lvl + n) - lvl;
	lvl[root] = 1;
	dfs1(root);
	len = *max_element(lvl , lvl + n);
	return;
}



void dfs4(int v, int &p , int &me, int par = -1) {
	res |= (1ll * me) << (val[v] - 1);
	for (auto e : adj[v]) 
		if (e ^ par && !m1[e] && val[e] <= 60) {
			me = Move(e);
			p = e;
			dfs4(e , p , me , v);
		}
	for (auto e :adj[v])
		if (e ^ par && m1[e] && val[e] <= 60) {
			me = Move(e);
			p = e;
			dfs4(e , p  , me , v);
		}
	if (!m1[v]) {
		me = Move(par);
		p = par;
	}
}


ll Ioi(int n, int m, int a[], int b[], int p ,int me, int t) {
	init(n , m , a , b);
	if (len >= 60) {

		m1.reset();
		dfs2(p , root);
		if (lvl[p] >= 60) {
			rep(i , 0 , 60) {
				res |= (1ll * me) << (lvl[p] % 60);
				for (auto e : adj[p])
					if (m1[e]) {
						me = Move(e);
						m1[p] = false;
						p = e;
						break;
					}
			}
		}
		else {
			while(true) {
				bool flag = false;
				for (auto e : adj[p]) 
					if (m1[e]) {
						me = Move(e);
						m1[p] = false;
						flag = true;
						p = e;
						break;
					}
				if (!flag) break;
			}
			int root2 = max_element(lvl , lvl + n) - lvl;
			dfs2(p , root2);
			rep(i , 0 , 60) {
				res |= (1ll * me) << (lvl[p] % 60);
				for (auto e : adj[p])
					if (m1[e]) {
						me = Move(e);
						m1[p] = false;
						p = e;
						break;
					}
			}
		}
		return res;		
	}
	////////////////////////////////////////
	int root2 = max_element(lvl , lvl + n) - lvl;


	m1.reset();
	dfs2(p  ,root);

	while(true) {
		bool flag = false;
		for (auto e : adj[p]) 
			if (m1[e]) {
				me = Move(e);
				m1[p] = false;
				flag = true;
				p = e;
				break;
			}
		if (!flag) break;
	}
	cnt = 0;
	m1.reset();
	dfs2(root , root2);
	dfs3(root);
	m1.reset();
	dfs4(root, p , me);
	return res;
}

Compilation message

Joi.cpp: In function 'void Joi(int, int, int*, int*, ll, int)':
Joi.cpp:14:2: error: 'init' was not declared in this scope
  init(n , m , a , b);
  ^~~~
Joi.cpp:14:2: note: suggested alternative: 'int'
  init(n , m , a , b);
  ^~~~
  int
Joi.cpp:15:6: error: 'len' was not declared in this scope
  if (len >= 60) {
      ^~~
Joi.cpp:17:28: error: 'lvl' was not declared in this scope
    MessageBoard(i , (x >> (lvl[i] % 60)) & 1);  
                            ^~~
Joi.cpp:17:28: note: suggested alternative: 'll'
    MessageBoard(i , (x >> (lvl[i] % 60)) & 1);  
                            ^~~
                            ll
Joi.cpp:20:27: error: 'lvl' was not declared in this scope
   int root2 = max_element(lvl , lvl + n) - lvl;
                           ^~~
Joi.cpp:20:27: note: suggested alternative: 'll'
   int root2 = max_element(lvl , lvl + n) - lvl;
                           ^~~
                           ll
Joi.cpp:21:3: error: 'm1' was not declared in this scope
   m1.reset();
   ^~
Joi.cpp:21:3: note: suggested alternative: 'm'
   m1.reset();
   ^~
   m
Joi.cpp:22:8: error: 'root' was not declared in this scope
   dfs2(root , root2);
        ^~~~
Joi.cpp:22:8: note: suggested alternative: 'root2'
   dfs2(root , root2);
        ^~~~
        root2
Joi.cpp:22:3: error: 'dfs2' was not declared in this scope
   dfs2(root , root2);
   ^~~~
Joi.cpp:22:3: note: suggested alternative: 'ffsl'
   dfs2(root , root2);
   ^~~~
   ffsl
Joi.cpp:23:3: error: 'dfs3' was not declared in this scope
   dfs3(root);
   ^~~~
Joi.cpp:23:3: note: suggested alternative: 'ffsl'
   dfs3(root);
   ^~~~
   ffsl
Joi.cpp:25:28: error: 'val' was not declared in this scope
    MessageBoard(i , (x >> (val[i] - 1)) & 1); 
                            ^~~

Ioi.cpp: In function 'bool dfs2(int, int, int)':
Ioi.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^