The following n−1n−1 lines representing edges, each line contains two integers uiui and vivi. uiui-vivi is an undirected edge of TT. Output should contain n−1n−1 lines, each line is a query. The ii-th (1≤i≤n−11≤i≤n−1) line represents the winner if Alice and Bo...
The first line of each test case contains two integers nn and mm (1≤n,m≤2⋅1051≤n,m≤2⋅105).The second line of each test case contains nn pairwise distinct integers a1,a2,…,ana1,a2,…,an— the points on y=0y=0 (−109≤ai≤109−109≤ai≤109)....
(Note: actually the summation with expected values is a more general definition of MGF, as it can be defined for random variables that are not only taking values of non-negative integers.) Lastly, for the random variable XX taking the value of non-negative integers, like in our problem, ...
Karen is stuck on one level, and wants to know a way to beat this level using the minimum number of moves. Please, help her with this task! Input The first line of input contains two integers,nandm(1 ≤ n, m ≤ 100), the number of rows and the number of columns in ...
At the beginning of the game pieces of all the ten players, indexed with consecutive integers from00to99, are at the home vertex. After that on each turn some of the players can ask Misha to simultaneously move their pieces along the corresponding edges. Misha will not answer more thanqqsu...
In the last line are two integers a, b (1 ≤ a, b ≤ n, a 6= b), representing the node A’s token and B’s token is on initially. Output One line “Yes” or “No”, denoting the winner. Example Solution 😀 算法标签:最短路/LCA 规律 ...
Karen is stuck on one level, and wants to know a way to beat this level using the minimum number of moves. Please, help her with this task! Input The first line of input contains two integers,nandm(1 ≤ n, m ≤ 100), the number of rows and the number of columns in...
The first line contains three integersnn,kkandx(1≤n≤200000,1≤k≤10,2≤x≤8)x(1 ≤ n ≤ 200 000,1 ≤ k ≤ 10,2 ≤ x ≤ 8). The second line containsnnintegersa1,a2,...,an(0≤ai≤109)a1, a2, ..., an(0 ≤ ai ≤ 109)...
Some of the problems were much easier to explain in detail together with the story itself. On the other hand, one or two problems, they were telling me the algorithm really in detail and I didn't know how it would look like in advance. It was like: "Read 4 integers" (I didn't ...
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);intbit=-1; cin>>n>>x>>y;for(inti=0; i<=9; ++i) { vector<int>a;for(intj=1; j<=n; ++j)if(j & (1<<i)) a.push_back(j);intres=query(a);if(res==y || res==(x^y)) ...