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

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

We will hold ZONe Energy Programming Contest.

The point values will be 100,200,400,300,500,600.

Attention This contest is equivalent to AtCoder Beginner Contest. Please pay attention to the point values bellow. Problem C is 400 points. We are looking forward to your participation!

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

»
6 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +36 Проголосовать: не нравится

Hints for problems : A. Check for every 4 length substring of original string. Time complexity is O(N*4).

B. Do a binary search within given accuracy to get such a minimum answer such that (H-ans)/D > max((hi-ans)/di) over all i's. Time complexity is O(N*log2(accuracy)).

C. We can basically binary search on the answer. Inside a binary search, let's check if it's possible for the answer to be more than equal to the middle element of the binary search. For each person find mask of powers which are more than considered middle element of binary search. Now we need to take any 3 masks from given array of masks such that total overlap is (2^5 — 1) or the complete power set mask. Repeating a mask is also a possibility. Time complexity is O(log(A)*(32*4*N))

D. We first need to get the string after 'R''s are removed. We can notice that if number of blocks of strings between 'R's are S1 R S2 R ..... SK R SK+1, 2 possible cases arise : - if K is even, final string is SK' SK-2' .... S2 S1 S3 .... SK-1 SK+1 - if K is odd, final string is SK' SK-2' .... S1 S2 S4 .... SK-1 SK+1 where S' is the reverse of a string S. After obtaining this string, we can build the answer string using a stack based solution where we push a character only if stack is empty or it's top is not equal to my current character to get the minimized answer string. Note that there won't be any possible operation possible after 1 reversal sequence and 1 reduction sequence. Time complexity is O(N).

E. For each cell create a dummy node, and add adge (i,j) -> (i,j,dummy) with weight 1 and also (i,j,dummy) -> (i,j) with weight 0. Also add edges corresponding to "i" in "1+i" transition from (i,j,dummy) -> (i-1,j,dummy) with weight 1. Now between all the normal nodes(cells), add rest of the edges from the first 3 transitions given. Answer will be shortest path between (1,1) to (R,C) in this graph. Time complexity is (O(R*C*log(R*C)).

F. Since we cannot make a transition from a node with value from given value set, let's find the remaining value set, ie, complement value set from {0,1,....n-1}. Now from each node, it is easy to see we can make a transition to other node if and only if their xor is some subset xor of this complemented set. To find how many subset xors are possible, let's build the basis of this set, also keeping the minimal elements added(this will help us build the tree) to the basis. If basis has k elements, then total possible elements in connected component of any node is 2^k including itself. If n is not equal to 2^k, we cannot build an answer. Otherwise we can. Add an edge from each node i to it's xor with each of the original element that was inserted into basis. There are log(n) such elements for each i. Hence graph has nlog(n) edges. Now we can find any spanning tree of this graph and print it. Time Complexity is O(nlog(n)).

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone please clarify why this is giving tle for the task D

Code
»
6 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Can someone explain to me the 3D DP solution of Problem C , which is mentioned in the editorial .

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    dp[people==3000][levels==3][bits==32].For each candidate we need to decide what mask should I take. If in the final answer if we are considering the particular mask of a person then obviously the lowest valued power of that particular person will come out in the final answer.

    Second thing we have to do is calculate the max value of a particular mask+level along the iteration. We also have to keep in mind if you are replacing some mask value of with another mask , if some information that might be used further is not lost (basically if our transition is not losing any information that can be use further).I would encourage you to simulate whole process with same problem diff constraints , i.e we have to choose 2 person and each have 3 powers only(power > # of people to choose).

    https://atcoder.jp/contests/zone2021/submissions/22254672

»
6 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +17 Проголосовать: не нравится

F: Random solution passed the tests, just take vertices randomly vertices and take all edges incident to them and find any possible spanning tree. This way by taking around 40*n edges passed the time limit. Code

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

F, "from each node, it is easy to see we can make a transition to other node if and only if their xor is some subset xor of this complemented set."

Actually, I still do not see why this is. Can somebody explain with simple example?

Let $$$B=(1,2)$$$, and $$$v_1\oplus v_2 = 1$$$ and $$$v_3\oplus v_4 = 2$$$

Then how can we see that $$$v_1$$$ is somehow connected to $$$v_3$$$ ?

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    i and i ^ j are connected if j isn't part of A ie part of B , lets say you want reach some X that be represented as the xor sum of some subset of B xor-ed with i, call the elements of this subset x1,x2,..,xk then simply connect i to i ^ x1,i ^ x1 to i ^ x2 ^ x3 , i ^ x1 ^ x2 ^ x3 to i^ x1 ^ x2 ^ x3 ^ x4 ... so on and so forth

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +29 Проголосовать: не нравится

chokudai, tatyam, why not just switch C & D instead of having the point values out of order and adding a note? Just curious.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can someone explain why the following editorial code for F works ,taking y as min of its xor with elements of elim,I tried randomly permutating elim when considering a new x and it fails the sol surprisingly so order matters

int y = x;
for(int b : elim) chmin(y, y ^ b);
if(y){
      base.push_back(x);
      elim.push_back(y);
 }