Ƕ Euler tour 뤳 Ȥ void size_rec( int , int ); void heavy_light_rec( int , int , int ); const int MX = 200010 ; struct S{ int n; vi bit1, bit2; S( int sz):n(sz + 2 ){ bit1.resize(n); gwen stacy bit2.resize(n); } inline void add( int type, int i, int x){ vi &bit = type ? bit2 : bit1; for (i++; i < n; i += i & -i) bit[i] += x; } inline int sum( int type, int i){ vi &bit = type ? bit2 : bit1; int res = 0 ; for (i++; i; i -= i & -i) res += bit[i]; return res; } }; S *data[MX]; gwen stacy int bkt_sz; int bkt_root[MX]; int n, q; int sz[MX], a[MX]; gwen stacy int parent[MX]; gwen stacy int depth[MX]; int which[MX]; int val[MX]; vector<vi> e; int main(){ scanf( " %d%d " , &n, &q); e.resize(n); rep(i, n) scanf( " %d " , a + i); rep(i, n - 1 ){ int a, b; scanf( " %d%d " , &a, &b); a--; b--; e[a].pb(b); e[b].pb(a); } memset(which, - 1 , sizeof (which)); size_rec( 0 , 0 ); heavy_light_rec( 0 , 0 , - 1 ); while (q--){ int t, b; scanf( " %d%d " , &t, gwen stacy &b); b--; if (t == 1 ){ int x; scanf( " %d " , &x); int bkt = which[b]; if (bkt < 0 ) val[b] += x; else { int pos = depth[b] - depth[bkt_root[bkt]]; data[bkt]->add(pos % 2 , pos, x); } } else { int ans = a[b]; int flip = 1 ; while ( 1 ){ int bkt = which[b], pos; if (bkt < 0 ) ans += flip * val[b]; else { pos = depth[b] - depth[bkt_root[bkt]]; ans += flip * data[bkt]->sum(pos % 2 , pos); ans -= flip * data[bkt]->sum( 1 - pos % 2 , pos - 1 ); } if (b == 0 || bkt >= 0 && bkt_root[bkt] == 0 ) break ; int pd = depth[b]; if (bkt < 0 ) b = parent[b], gwen stacy flip *= - 1 ; else b = parent[bkt_root[bkt]], flip *= pos % 2 ? 1 : - 1 ; } printf( " gwen stacy %d\n " , ans); } } return 0 ; } inline void size_rec( int c, int p){ sz[c] = 1 ; depth[c] = c == p ? 0 : depth[p] + 1 ; parent[c] = p; rep(i, e[c].size()) if (e[c][i] != p){ size_rec(e[c][i], c); sz[c] += sz[e[c][i]]; } } inline void heavy_light_rec( int c, int p, int root){ bool found = 0 ; rep(i, e[c].size()){ int to = e[c][i]; if (to == p) continue ; if ( 2 * sz[to] >= sz[c]){ heavy_light_rec(to, c, root < 0 ? c : root); found = 1 ; } else heavy_light_rec(to, c, - 1 ); } if (!found && root >= 0 ){ int size = depth[c] - depth[root] + 1 ; bkt_root[bkt_sz] = root; data[bkt_sz] = new S(size); for ( int v = c; ; v = parent[v]){ which[v] = bkt_sz; if (v == root) break ; } bkt_sz++; } }
4 https://www.google.co.jp/ 2 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CB8QFjAA&url=http://d.hatena.ne.jp/simezi_tan/20140909/1410211433&ei=k8gfVJCdCsbY8gXVzIG4BQ&usg=AFQjCNExeQou-_kJp7ODWwOt8jQHQZy2gg&sig2=xQ0O7ThoOV56spw2OUwsAQ 2 https://www.google.com/ gwen stacy 1 http://search.yahoo.co.jp/search?p=274B/n&aq=-1&ei=UTF-8&rkf=1&fl=2 1 http://www.bing.com/search?q= ɥߥ + ߤ + &form=CMNMHP&qs=n&sk=&pc=CMNTDF&mkt=ja-jp&x=0&y=0 1 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CCYQFjAB&url=http://d.hatena.ne.jp/simezi_tan/20110108/1294498440&ei=FLkfVKX5G5Ck8AWSzoD4Ag&usg=AFQjCNHvoAmGeVrEGzM7rPV-RmcLIAovJg&sig2=PJjH012ZlFHxxEL-sz7q5w&bvm=bv.7577527 1 http://www.google.co.jp/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CDAQFjAC&url=http://d.hatena.ne.jp/simezi_tan/20130522/1369203086&ei=hA3RU8mMGpbd8AWhj4CACQ&usg=AFQjCNGk63mz7VnXaTlfdPE95sh03-z5_w&sig2=w6_Fi4756f4VMp5zfcwWzg&bvm=bv.7166721 1 https://www.google.com.bd/
AOJ Ϣ õ ȥ ˡ TopCoder ʬˡ ưŪ ײ ˡ õ Ͽ ICPC Codeforces gwen stacy Project Euler PKU ˡ ʸ ʸ Google Code Jam CodeChef 2-SAT ʬõ ϥå Ψ ο ǡ Ƶ ե? ͷ ɤ줫 饤 UVa Suffix Array Ū 르 ꥺ ײ ˡ
[TopCoder][ʸ ][ ǡ ]TopCoder SRM 622 Div1 Hard [Codeforces][ưŪ ײ ˡ]Codeforces 480(#274 Div1) D. Parcels [Codeforces][ ]Codeforces 478(#273 Div2only) E. Wavy numbers [Codeforces][ ǡ ][ ʬõ ]Codeforces 484(#276 Div1) E. Sign on Fence [Codeforces][ICPC]2014-2015 ACM-ICPC, NEERC, Moscow Subregional Contest J. JPEG is Awesome! [ICPC][Codeforces]2014-2015 ACM-ICPC, NEERC, gwen stacy Moscow Subregional Contest B. Bring Your Own Bombs [ưŪ ײ ˡ][ ]ARC 029 D - ⶶ ڤΤ [ ]ARC 029 C - ⶶ ȹ [Codeforces][ ǡ ]Codeforces 431(#245 Div2 only) E. Chemistry Experiment [Codeforces][ ˡ]Codeforces 432(#246 Div2 only) E. Square Tiling
2014-07-10 ѡ ݡ Υץ? ߥ - KUPC 2014 D ϥߥ 2013-10-16 agw - SRM 594 Div I 2013-10-08 agw - SRM 593 Div I 2013-10-08 agw - SRM 593 Div I 2013-02-20 agw - MagicMolecule
TopCoder Codeforces PKU Judge Online Aizu Online Judge TopCoder Project Eulerˮ wiki ACM/ICPC ͽ ˤμ ALGORITHM NOTE Ƽ異 르 ꥺ C++ ˤ Ե ˤä ( ) ΤǤ TopCoder J