G r a k n F o r c e s 2020 A − F \mathrm{Grakn\ Forces\ 2020 A-F} Grakn Forces 2020A−F brief solution
Grakn Forces 2020
Note: If the title is multiple sets of data nnn means∑ n \sum n∑n
A
Why于题eyes guarantee ai ≠ bi ≠ ci a_i ≠ b_i ≠ c_iai=bi=ciSo you can directly determine what to choose bit by bit, the time complexity is O (n) O(n)O ( n )
B
Greedy addition, until the sequence cannot be added to add a sequence, just simulate it again, the time complexity is O (n) O(n)O ( n )
C
We consider the bisection time ttt , and then simulate the left and right end points atttposition after t seconds ifr ≤ lr\leq lr≤l means thisttt is legal. Time complexityO (n log n) O(n\log n)O ( nlogn)
D
We consider dp. fi f_ifiMeans to move left iii at least move a few spaces up. Finally, take max from back to front. Thenans = min i = 1 1 0 6 fi + i ans=\min\limits_{i=1}^{10^6} f_i+ia n s=i=1min106fi+i . Time complexityO (n × m) O(n\times m)O ( n×m)
E
We consider the situation that will form a ring, that is, two different numbers x, yx, yx,y appears in two different setsS, TS, Tat the same timeS,T species. We consider the elementsxx ineach setx to the current setSSS connection cost isa S + bx a_S+b_xaS+bxThe side. Then the answer is (∑ i = 1 n ∑ j = 1 mai + bj) − (\sum\limits_{i=1}^{n}\sum\limits_{j=1}^{m}a_i+b_j)-(i=1∑nj=1∑mai+bj) − The weight of the maximum spanning tree after connecting edges. Because you want to delete the least expensive side. Time complexityO ((n + m) log (n + m)) O((n+m)\log (n+m))O ( ( n+m)log(n+m))
F
Structure questions. First, the two adjacent numbers are equal, and then four are adjacent, and so on.
For example, n = 5: n=5:n=5: 12345 ∼ \sim ∼ 66345 ∼ \sim ∼ 66775 ∼ \sim ∼ 86875 ∼ \sim ∼ 88885
We just need to divide and conquer to simulate, the time complexity is O (n log n) O(n \log n)O ( nlogn)