From 7784bb1a235bf250767ff09c4954aa71f0d2440d Mon Sep 17 00:00:00 2001 From: zscoder Date: Fri, 7 Oct 2016 16:39:59 +0800 Subject: [PATCH] Fixed Euler Count Bug --- Data Structures Class Template.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Data Structures Class Template.cpp b/Data Structures Class Template.cpp index 1c37b0b..4b92a03 100644 --- a/Data Structures Class Template.cpp +++ b/Data Structures Class Template.cpp @@ -1382,8 +1382,8 @@ struct Tree void calceuler() { eulercnt = 0; - level.assign(2*n, 0); - euler.assign(2*n, 0); + level.assign(2*n+1, 0); + euler.assign(2*n+1, 0); depth.assign(n, 0); firstocc.resize(n); dfseuler(0, -1); @@ -1404,22 +1404,22 @@ struct Tree { for(int i = 0; i < eulercnt; i++) { - rmqtable[i][j] = eulercnt; + rmqtable[j][i] = eulercnt; if(i + (1< firstocc[v]) swap(u, v); - //cout << firstocc[u] << ' ' << firstocc[v] << ' ' << rmq(firstocc[u], firstocc[v]) << ' ' << euler[rmq(firstocc[u], firstocc[v])] << endl; + //cerr << firstocc[u] << ' ' << firstocc[v] << ' ' << rmq(firstocc[u], firstocc[v]) << ' ' << euler[rmq(firstocc[u], firstocc[v])] << endl; return euler[rmq(firstocc[u], firstocc[v])]; }