Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

Блог пользователя mehthemez

Автор mehthemez, история, 9 лет назад, По-английски

Hello. I've been doing a problem on poj.com ( link : http://poj.org/problem?id=1195 )

The main idea of the problem is that we are given a S * S grid and there is 2 kind of operations.

Operation 1 : Change the cell x, y by adding a certain value A.

Operation 2 : Answer the sum of the rectangle which is defined by the two points; top leftmost : (l, b), bottom rightmost (r, t)

So obviously we need a 2D Binary Indexed Tree (because of operation 1). But I tried to implement a 2D Segment Tree, and I'm getting a TLE.

Can someone help me figure out why ? Are Segment Trees not efficient here or my implementation of 2D Segment Tree is just bad ?

Link to my C++ code (getting TLE): http://pastebin.com/KA3UXm3N

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор mehthemez, 9 лет назад, По-английски

A strongly connected component of a digraph is defined as the maximal set of vertices in which there is a path from any one vertex to any other vertex in the set.

In this example ( link : http://lcm.csa.iisc.ernet.in/dsa/img386.gif ): I can't see why (C), (A, B, C) are the strong components of G rather than (A, B, C, D). (We can see that in (A, B, C, D), there is always a path from any one vertex to any other)

Any clue ?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится