Editing
2016 Jan Platinum Problem 2 Mowing the Field
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Python === <pre> import sys from collections import defaultdict MAXN = 1 << 17 MAXV = 1 << 30 class Node: def __init__(self): self.val = 0 self.child = [None, None] def get_child(self, c): if self.child[c] is None: self.child[c] = Node() return self.child[c] def add(self, x, v, lo, hi): self.val += v if hi - lo == 1: return mid = (lo + hi) // 2 if x < mid: self.get_child(0).add(x, v, lo, mid) else: self.get_child(1).add(x, v, mid, hi) def query(self, a, b, lo, hi): if a <= lo and hi <= b: return self.val elif hi <= a or b <= lo: return 0 mid = (lo + hi) // 2 return (self.child[0].query(a, b, lo, mid) if self.child[0] else 0) + \ (self.child[1].query(a, b, mid, hi) if self.child[1] else 0) bit = defaultdict(Node) def bit_add(x, y, v): j = y | MAXN while j < (MAXN << 1): bit[j ^ MAXN].add(x, v, 0, MAXV) j += j & -j def bit_get(x0, x1, y): ret = 0 j = y - 1 while j != 0: ret += bit[j].query(x0, x1, 0, MAXV) j &= j - 1 if j == 0: break return ret def main(): # Reads input, processes it, and writes output. # Implementation needed here. if __name__ == "__main__": main() </pre> [[Category:Yearly_2015_2016]] [[Category:Platinum]] [[Category:Geometry]] [[Category:Segment Tree]] [[Category:Sweep Line]]
Summary:
Please note that all contributions to Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
My wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information