Tree

Description
its a tree

Please download to get full document.

View again

of 2
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information
Category:

Documents

Publish on:

Views: 12 | Pages: 2

Extension: TXT | Download: 0

Share
Transcript
  #include <iostream>#include <cstdio>#include <cmath>using namespace std;typedef long long ll;ll a1[50000], a[65535! 1];oid $uild%ll node, ll start, ll end&'if %start (( end&'a[node] ( a1[start];)else 'll mid ( %start * end&+!;$uild%!node * 1, start, mid&;$uild%!node * !, mid * 1, end&;if %a[!node * 1] >( 0  a[!node * !] >( 0&a[node] ( a[!node * 1] * a[!node * !];else if %a[!node * 1] >( 0&a[node] ( a[!node * 1];else if %a[!node * !] >( 0&a[node] ( a[!node * !];else a[node] ( ma-%a[!node * 1], a[!node * !]&;))ll .uery%ll node, ll start, ll end, ll left, ll right&'if %left > end / right < start&return 0;else if %start >( left  right >( end&return a[node];else'll mid ( %start * end&+!;ll p1 ( .uery%!node * 1, start, mid, left, right&;ll p! ( .uery%!node * !, mid * 1, end, left, right&;if %p1 >( 0  p! >( 0&return p1 * p!;else if %p1 >( 0&return p1;else if %p! >( 0&return p!;else return ma-%p1,p!&;))int main%& 'll n, m, -, y, i, n1;scanf%lld, n&;for%i ( 0; i < n; i**&'scanf%lld, a1[i]&;)ll pos ( po2%!, ceil%log!%n&&&;n1 ( !  pos 1;for%i ( 0; i < n1; i**&'a[i] ( 0;)$uild%0, 0, pos 1&;  for%i ( 0; i < n1; i**&'cout << a[i] <<  ;)scanf%lld, m&;for%i ( 0; i < m; i**&'scanf%lldlld, -,y&;printf%lld, .uery%0, 0, pos 1, - 1, y 1&&;)return 0;)
Related Search
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks