Submission #249612

# Submission time Handle Problem Language Result Execution time Memory
249612 2020-07-15T11:12:27 Z staniewzki Amusement Park (JOI17_amusement_park) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.ST << ", " << p.ND << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;
 
#include "Joi.h"
 
vector<vector<int>> adj, tree, subtree
vector<int> dep, par, val, is_par;
 
void gen_tree(int v = 0, int d = 0) {
	dep[v] = d;
	for(int u : adj[v]) {
		if(dep[u] == -1) {
			par[u] = v;
			tree[v].emplace_back(u);
			gen_tree(u, d + 1);
		}
	}
}
 
void init_subtree(int v = 0) {
	if(size(subtree[0]) == 60) return;
	val[v] = size(subtree[0]);
	subtree[0].emplace_back(v);
	for(int u : tree[v])
		init_subtree(u);
}
 
void cal_subtree(int v = 0) {
	if(size(subtree[v]) == 0) {
		int p = par[v], leaf = -1;
		for(int u : subtree[p])
			if(par[u] != -1)
				is_par[par[u]] = true;
		for(int u : subtree[p])
			if(u != p && !is_par[u])
				leaf = u;
		for(int u : subtree[p])
			if(par[u] != -1)
				is_par[par[u]] = false;
		if(leaf == -1) {
			PII min_dep = {1e9, -1};
			for(int u : subtree[p])
				min_dep = min(min_dep, {dep[u], u});
			leaf = min_dep.ND;
		}
		val[v] = val[leaf];
		subtree[v] = {v};
		for(int u : subtree[p]) if(u != leaf)
			subtree[v].emplace_back(u);
	}
 
	for(int u : tree[v])
		cal_subtree(u);
}
 
void preprocess(int n) {
	tree.resize(n);
	val = dep = par = vector<int>(n, -1);
	is_par.resize(n);
	subtree.resize(n);
	gen_tree();
	init_subtree();
	for(int v : subtree[0]) {
		if(v) subtree[v] = subtree[0];
	}
	cal_subtree();
}
 
void Joi(int n, int m, int a[], int b[], LL x, int t) {
	adj.resize(n);
	REP(i, m) {
		adj[a[i]].emplace_back(b[i]);
		adj[b[i]].emplace_back(a[i]);
	}
	preprocess(n);
	REP(i, n) MessageBoard(i, bool(x & (1LL << val[i])));
}
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.ST << ", " << p.ND << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;
 
#include "Ioi.h"
 
vector<vector<int>> adj, tree, subtree;
vector<int> dep, par, val, is_par;
 
void gen_tree(int v = 0, int d = 0) {
	dep[v] = d;
	for(int u : adj[v]) {
		if(dep[u] == -1) {
			par[u] = v;
			tree[v].emplace_back(u);
			gen_tree(u, d + 1);
		}
	}
}
 
void init_subtree(int v = 0) {
	if(size(subtree[0]) == 60) return;
	val[v] = size(subtree[0]);
	subtree[0].emplace_back(v);
	for(int u : tree[v])
		init_subtree(u);
}
 
void cal_subtree(int v = 0) {
	if(size(subtree[v]) == 0) {
		int p = par[v], leaf = -1;
		for(int u : subtree[p])
			if(par[u] != -1)
				is_par[par[u]] = true;
		for(int u : subtree[p])
			if(u != p && !is_par[u])
				leaf = u;
		for(int u : subtree[p])
			if(par[u] != -1)
				is_par[par[u]] = false;
		if(leaf == -1) {
			PII min_dep = {1e9, -1};
			for(int u : subtree[p])
				min_dep = min(min_dep, {dep[u], u});
			leaf = min_dep.ND;
		}
		val[v] = val[leaf];
		subtree[v] = {v};
		for(int u : subtree[p]) if(u != leaf)
			subtree[v].emplace_back(u);
	}
 
	for(int u : tree[v])
		cal_subtree(u);
}
 
void preprocess(int n) {
	tree.resize(n);
	val = dep = par = vector<int>(n, -1);
	subtree.resize(n);
	gen_tree();
	init_subtree();
	for(int v : subtree[0]) {
		if(v) subtree[v] = subtree[0];
	}
	cal_subtree();
}
 
LL x;
vector<int> in, q;
 
void dfs(int v) {
	in[v] = false;
	x += (1LL << val[v]) * q[v];
	tree[v].emplace_back(par[v]);
	for(int u : tree[v]) {
		if(in[u]) {
			q[u] = Move(u);
			dfs(u);
			Move(v);
		}
	}
}
 
LL Ioi(int n, int m, int a[], int b[], int p, int v, int t) {
	adj.resize(n);
	REP(i, m) {
		adj[a[i]].emplace_back(b[i]);
		adj[b[i]].emplace_back(a[i]);
	}
	in = q = is_par = vector<int>(n);
	preprocess(n);
	q[p] = v;
	for(int u : subtree[p])
		in[u] = true;
	dfs(p);
	return x;
}

Compilation message

Joi.cpp:45:1: error: expected initializer before 'vector'
 vector<int> dep, par, val, is_par;
 ^~~~~~
Joi.cpp: In function 'void gen_tree(int, int)':
Joi.cpp:48:2: error: 'dep' was not declared in this scope
  dep[v] = d;
  ^~~
Joi.cpp:48:2: note: suggested alternative: 'dump'
  dep[v] = d;
  ^~~
  dump
Joi.cpp:51:4: error: 'par' was not declared in this scope
    par[u] = v;
    ^~~
Joi.cpp: In function 'void init_subtree(int)':
Joi.cpp:59:10: error: 'subtree' was not declared in this scope
  if(size(subtree[0]) == 60) return;
          ^~~~~~~
Joi.cpp:59:10: note: suggested alternative: 'tree'
  if(size(subtree[0]) == 60) return;
          ^~~~~~~
          tree
Joi.cpp:60:2: error: 'val' was not declared in this scope
  val[v] = size(subtree[0]);
  ^~~
Joi.cpp:60:16: error: 'subtree' was not declared in this scope
  val[v] = size(subtree[0]);
                ^~~~~~~
Joi.cpp:60:16: note: suggested alternative: 'tree'
  val[v] = size(subtree[0]);
                ^~~~~~~
                tree
Joi.cpp: In function 'void cal_subtree(int)':
Joi.cpp:67:10: error: 'subtree' was not declared in this scope
  if(size(subtree[v]) == 0) {
          ^~~~~~~
Joi.cpp:67:10: note: suggested alternative: 'tree'
  if(size(subtree[v]) == 0) {
          ^~~~~~~
          tree
Joi.cpp:68:11: error: 'par' was not declared in this scope
   int p = par[v], leaf = -1;
           ^~~
Joi.cpp:71:5: error: 'is_par' was not declared in this scope
     is_par[par[u]] = true;
     ^~~~~~
Joi.cpp:71:5: note: suggested alternative: 'isupper'
     is_par[par[u]] = true;
     ^~~~~~
     isupper
Joi.cpp:73:18: error: 'is_par' was not declared in this scope
    if(u != p && !is_par[u])
                  ^~~~~~
Joi.cpp:73:18: note: suggested alternative: 'isupper'
    if(u != p && !is_par[u])
                  ^~~~~~
                  isupper
Joi.cpp:74:5: error: 'leaf' was not declared in this scope
     leaf = u;
     ^~~~
Joi.cpp:74:5: note: suggested alternative: 'feof'
     leaf = u;
     ^~~~
     feof
Joi.cpp:77:5: error: 'is_par' was not declared in this scope
     is_par[par[u]] = false;
     ^~~~~~
Joi.cpp:77:5: note: suggested alternative: 'isupper'
     is_par[par[u]] = false;
     ^~~~~~
     isupper
Joi.cpp:78:6: error: 'leaf' was not declared in this scope
   if(leaf == -1) {
      ^~~~
Joi.cpp:78:6: note: suggested alternative: 'feof'
   if(leaf == -1) {
      ^~~~
      feof
Joi.cpp:81:29: error: 'dep' was not declared in this scope
     min_dep = min(min_dep, {dep[u], u});
                             ^~~
Joi.cpp:81:29: note: suggested alternative: 'dump'
     min_dep = min(min_dep, {dep[u], u});
                             ^~~
                             dump
Joi.cpp:81:39: error: no matching function for call to 'min(PII&, <brace-enclosed initializer list>)'
     min_dep = min(min_dep, {dep[u], u});
                                       ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from Joi.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = std::pair<int, int>]
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   no known conversion for argument 2 from '<brace-enclosed initializer list>' to 'const std::pair<int, int>&'
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
Joi.cpp:81:39: note:   candidate expects 3 arguments, 2 provided
     min_dep = min(min_dep, {dep[u], u});
                                       ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from Joi.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
Joi.cpp:81:39: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
     min_dep = min(min_dep, {dep[u], u});
                                       ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from Joi.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
Joi.cpp:81:39: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
     min_dep = min(min_dep, {dep[u], u});
                                       ^
Joi.cpp:84:3: error: 'val' was not declared in this scope
   val[v] = val[leaf];
   ^~~
Joi.cpp:84:16: error: 'leaf' was not declared in this scope
   val[v] = val[leaf];
                ^~~~
Joi.cpp:84:16: note: suggested alternative: 'feof'
   val[v] = val[leaf];
                ^~~~
                feof
Joi.cpp: In function 'void preprocess(int)':
Joi.cpp:96:2: error: 'val' was not declared in this scope
  val = dep = par = vector<int>(n, -1);
  ^~~
Joi.cpp:96:8: error: 'dep' was not declared in this scope
  val = dep = par = vector<int>(n, -1);
        ^~~
Joi.cpp:96:8: note: suggested alternative: 'dump'
  val = dep = par = vector<int>(n, -1);
        ^~~
        dump
Joi.cpp:96:14: error: 'par' was not declared in this scope
  val = dep = par = vector<int>(n, -1);
              ^~~
Joi.cpp:97:2: error: 'is_par' was not declared in this scope
  is_par.resize(n);
  ^~~~~~
Joi.cpp:97:2: note: suggested alternative: 'isupper'
  is_par.resize(n);
  ^~~~~~
  isupper
Joi.cpp:98:2: error: 'subtree' was not declared in this scope
  subtree.resize(n);
  ^~~~~~~
Joi.cpp:98:2: note: suggested alternative: 'tree'
  subtree.resize(n);
  ^~~~~~~
  tree
Joi.cpp: In function 'void Joi(int, int, int*, int*, LL, int)':
Joi.cpp:114:45: error: 'val' was not declared in this scope
  REP(i, n) MessageBoard(i, bool(x & (1LL << val[i])));
                                             ^~~