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 .
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 150 |
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
Name |
---|