Submission #67104

# Submission time Handle Problem Language Result Execution time Memory
67104 2018-08-13T10:41:27 Z reality None (JOI16_snowy) C++17
Compilation error
0 ms 0 KB
#include "Anyalib.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

static const int N = 1024;

static int n;

static vector < pii > g[N];

static int P[N][N];

static int fr[N];

static int coef[N];

static int lf[N];

static int rg[N];

static vii e;

static int Time = 0;

static void dfs(int node = 0,int index = 0) {
	++Time;
	lf[index] = Time;
	fr[node] = Time;
	coef[Time] = 1;
	for (auto it : g[node])
		if (it.se != index)
			dfs(it.fi,it.se);
	++Time;
	rg[index] = Time;
	coef[Time] = -1;
}

void InitAnya(int NN, int A[] , int B[]) {
	n = NN;
	for (int i = 0;i < n - 1;++i) {
		g[A[i]].pb(mp(B[i],i + 1));
		g[B[i]].pb(mp(A[i],i + 1));
		P[A[i]][B[i]] = P[B[i]][A[i]] = i + 1;
	}
	dfs();
}

static int sum[N];

void Anya(int C[]) {
	for (int i = 0;i <= n + n;++i)
		sum[i] = 0;
	for (int i = 1;i < n;++i) {
		sum[lf[i]] = C[i - 1];
		sum[rg[i]] = -C[i - 1];
	}
	for (int i = 1;i <= n + n;++i)
		sum[i] += sum[i - 1];
	for (int i = 0;i < n - 1;++i)
		Save(i,C[i]);
	for (int i = 0;i * 20 < n + n;++i) {
		int ed = min(n + n,(i + 1) * 20);
		for (int t = 0;t < 10;++t)
			Save(n - 1 + t + i * 10,(sum[ed] >> t) & 1);
	}
}
#include "Borislib.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}

static const int N = 1024;

static int n;

static vector < pii > g[N];

static int P[N][N];

static int fr[N];

static int coef[N];

static int lf[N];

static int rg[N];

static int ac[N];

static vii e;

static int Time = 0;

static void dfs(int node = 0,int index = 0) {
	++Time;
	lf[index] = Time;
	ac[Time] = index - 1;
	fr[node] = Time;
	coef[Time] = 1;
	for (auto it : g[node])
		if (it.se != index)
			dfs(it.fi,it.se);
	++Time;
	ac[Time] = index - 1;
	rg[index] = Time;
	coef[Time] = -1;
}

void InitBoris(int NN , int A[] , int B[]) {
  	n = NN;
	for (int i = 0;i < n - 1;++i) {
		g[A[i]].pb(mp(B[i],i + 1));
		g[B[i]].pb(mp(A[i],i + 1));
		P[A[i]][B[i]] = P[B[i]][A[i]] = i + 1;
	}
	dfs();
}

int Boris(int node) {
	int need = fr[node];
	int pos,beg;
	for (int i = 0;i * 20 < n + n;++i) {
		int ed = min(n + n,(i + 1) * 20);
		if (abs(pos - ed) <= 10) {
			pos = ed;
			beg = i * 10 + n - 1;
			break;
		}
	}
	assert(abs(pos - ed) <= 10);
	int ans = 0;
	for (int i = 0;i < 10;++i)
		assert(0 <= beg + i && beg + i < 1000),ans += Ask(beg + i) * (1 << i);
	while (pos < need) {
		++pos;
		if (ac[pos] >= 0)
			ans += Ask(ac[pos]) * coef[pos];
	}
	while (pos > need) {
		if (ac[pos] >= 0)
			ans -= Ask(ac[pos]) * coef[pos];
		--pos;
	}
	return ans;
}

Compilation message

In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from Boris.cpp:2:
Boris.cpp: In function 'int Boris(int)':
Boris.cpp:79:19: error: 'ed' was not declared in this scope
  assert(abs(pos - ed) <= 10);
                   ^
Boris.cpp:79:19: note: suggested alternative: 'e'