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 .
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
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 .
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
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
How can solve this-> http://www.lightoj.com/volume_showproblem.php?problem=1083 problem with segment tree. Please give me some hints.. Thanks..
Give me some tips to solve- uva 10692 problem.. - problem link:https://uva.onlinejudge.org/external/106/10692.pdf
I got this problem TLE. help How can i handle my code . My code
Название |
---|