Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

How can find the value from set given an index. suppose our set is st. st.insert(2); st.insert(6); st.insert(1);

Now i want to know the value of index 2 from set. Is there any logarithmic away? Thanks advance .

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

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

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

Give me some tricks to solve it. problem : Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the subsequence ai, ai+1, ..., aj.

Input

Line 1: n (1 ≤ n ≤ 30000). Line 2: n numbers a1, a2, ..., an (1 ≤ ai ≤ 106). Line 3: q (1 ≤ q ≤ 200000), the number of d-queries. In the next q lines, each line contains 2 numbers i, j representing a d-query (1 ≤ i ≤ j ≤ n). Output

For each d-query (i, j), print the number of distinct elements in the subsequence ai, ai+1, ..., aj in a single line. Example

Input 5 1 1 2 1 3 3 1 5 2 4 3 5

Output 3 2 3

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

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

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

problem :http://www.lightoj.com/volume_showproblem.php?problem=1111.. why its WA. Give me some critical case..

problem: K people are having a picnic. They are initially in N cities, conveniently numbered from 1 to N. The roads between cities are connected by M one-way roads (no road connects a city to itself).

Now they want to gather in the same city for their picnic, but (because of the one-way roads) some people may only be able to get to some cities. Help them by figuring out how many cities are reachable by all of them, and hence are possible picnic locations.

Input Input starts with an integer T (≤ 10), denoting the number of test cases.

Each case starts with three integers K (1 ≤ K ≤ 100), N (1 ≤ N ≤ 1000), M (1 ≤ M ≤ 10000). Each of the next K lines will contain an integer (1 to N) denoting the city where the ith person lives. Each of the next M lines will contain two integers u v (1 ≤ u, v ≤ N, u ≠ v) denoting there is a road from u to v.

Output For each case, print the case number and the number of cities that are reachable by all of them via the one-way roads.

Sample Input 1 2 4 4 2 3 1 2 1 4 2 3 3 4 Output for Sample Input Case 1: 2

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

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

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

How can solve this-> http://www.lightoj.com/volume_showproblem.php?problem=1083 problem with segment tree. Please give me some hints.. Thanks..

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

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

Автор slow_coder4, история, 8 лет назад, По-английски
  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

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

I got this problem TLE. help How can i handle my code . My code

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

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