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

Автор arsijo, 7 лет назад, По-английски
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Разбор задач Codeforces Round 571 (Div. 2)
  • Проголосовать: нравится
  • +119
  • Проголосовать: не нравится

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

What about shuffle solutions in F? Just mistake?

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

Is it possible to add this case to the system tests for F and hopefully a rejudge?

https://pastebin.com/dgWMkY4z

Both the following and possibly many more submissions fail on this case:

https://mirror.codeforces.com/contest/1186/submission/56222396

https://mirror.codeforces.com/contest/1186/submission/56210105

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

I want a prove for the incorrectness of the greedy solutions in F. Really puzzled...

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

It's easy to see that f(c,d) is even if and only if cntb and cntc have same parity
Someone can help to understand this in problem C? I don't see why that is always true

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

Can anyone elaborate 3rd solution? Cossack Vous and numbers

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

    Just take every element floor value and mark those point which are integers. Now sum the numbers. Sum can be less than equal to 0 . if 0 then print it, otherwise increment those value which are not marked by 1

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

Can you give a more formal proof od problem D?

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

(Problem F) For which case will such a solution fail? (Test case-31)

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

B is missing :p

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

In problem C one of the tags is FFT, how is FFT applied here?

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

Problem C submission code. How can i optimize more it is giving TLE on test 7.

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

Can you explain the solution of B task? It is interesting problem

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

what is the error in this code for problem c??

include<bits/stdc++.h>

using namespace std; int main() { string a,b; cin>>a>>b; int al=a.length(),bl=b.length(),i,j,x,ans=0; for(i=0;i<=al-bl;i++) { int x=i,count=0; for(j=0;j<bl;j++) if(a[j+x]==b[j]) count++; if(count%2==0) ans++; } cout<<ans<<endl; return 0; }

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

another solution for C:

let the changes be equal to total position such that b[i]!=b[i+1].

now let cnt stores the total mismatch between first substring of a and b.

do cnt=cnt%2. if cnt is even: ans++

To calculate mismatch between just next substring of a and b: {

Better you draw 1st sample test case in notebook.(think now as we are shifting b to right.)

1.Now position where b[i]!=b[i+1] there will be +1( if previous match become mismatch ) or -1( if previous mismatch become a match ) in value of cnt and in either case cnt value change from odd to even or even to odd.

to keep it simple lets just +1 for those positions because we only concern about odd/even of the cnt.

so overall total +1 in cnt will be by + changes

2.take care about new mismatch and previous mismatch

(new) +1 the cnt if mismatch between last char of b and last char of current substring

(old) +1 the cnt if mismatch between first char of b and first char of current substring

if cnt is even: ans++

}

Link to my submission

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

how problem C can be solve using fft ?

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

can someone explain me in simple way in problem C why having same parity gives even no of change?

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

    f(b, c) == even no of changes

    let number of 1 in string b = x1, number of 1 in string c = x2, number of common 1 in both string = x,

    so, number of changes = x1 + x2 — 2*x, which should be even. /** 2*x is always even **/, x1 + x2 should be even , it implies x1 and x2 should be both even or both odd, hence should have same parity

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

    there can be two types of mismatch in the problem

    let one string be c and other be b;

    the two types can be if there c[i]=0 and b[i] = 1;

    other case can be if c[i]=1 and b[i] = 0

    so the number of mismatch of first type is numc-x and second type is numb-x .

    where numc and numb are number of 1 in c and b respectively.

    total mismatch = numc+numb-2*x

    to make this even numc and numb must have same parity

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

In problem E, while doing this multiplication, ((fieldx−1)⋅(fieldy−1)−1)⋅n⋅m / 2 it can lead to overflow. Can someone suggest how to handle the overflow? I think it requires some sort of trick.

My solution is here: https://mirror.codeforces.com/contest/1186/submission/56266238

It is failing on test 5 due to overflow (at least that's what I think).

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

Where is author's source code for F?

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

In problem C, It's easy to see that f(c,d) is even if and only if cntb and cntc have same parity. In other words if cntc≡cntd(mod2) then f(c,d) is even.

what is the meaning of parity here? I have looked up all the comments but cant found any clear explanation.

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

For problem F, you don't need to "find Euler cycle and do the following steps for each component independently."

Because adding fictive vertex makes the graph connected.

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

I think I have a good idea of understanding Problem C.

Find out how many different positions of two strings A and B are equivalent to $$$\sum{a_i\bigoplus b_i}$$$

Because it only judges parity, it is equivalent to $$$XOR(a_i)\bigoplus XOR(b_i)$$$

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

In problem C, I don't understand the explanation for the problem. Please explain the pseudo code for the solution.

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

I don't understand solution problem D, anybody explain better?,i was seeing some solutions and most of them have this solution

https://mirror.codeforces.com/contest/1186/submission/56278052

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

    Let a[] be the given array of doubles whose sum is 0

    We need to find b[] such that b[i] = ceil(a[i]) or floor(a[i]) such that sum of all elements in b[] is 0.

    Fact: ceil(x) — floor(x) = 1 for any real number with a non zero decimal part ceil(x) = floor(x) for any real number with zero decimal part

    So let's initialize b[] such that b[i] = ceil(a[i]). Let's call the sum of this array as s. We need to make s = 0, and we can do so only by subtracting 1 from a set of 's' b[i]s (whose corresponding a[i] has a non zero decimal part).

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

Can some one explain me last part of editorial E .I mean how author arrived at if bitcnt(a)+bitcnt(b) is an odd number, then the matrix is inversed. Also how do we determine if a field is inverted or not if its coordinates (x,y) are odd,odd or odd,even ?

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

One important note — (In tutorial of Problem E)in last statement "if bitcnt(a)+bitcnt(b) is an odd number, then the matrix is inversed" , indexing is considered from zero i.e suppose we are referring to first row and second column then that is (0,1). readers might get confused since in problem and in most of the part of tutorial of problem E indexing is considered from 1. Also bit count refers to number of 1's in binary representation of number and not least number of bits required to represent the number in binary.

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

For Problem $$$E$$$, $$$bitcnt(a)+bitcnt(b)$$$ tells you whether the matrix at position $$$(a,b)$$$ is inverted or not due to the following reason:

Imagine the whole infinite a grid as a big quadrant, which consists of $$$4$$$ quadrants, each of which consists of another $$$4$$$ quadrants, and so on. Then if you started looping on bits from the most to the least significant position (let the current bit in the loop be the $$$i_{th}$$$ bit), then checked the $$$i_{th}$$$ bit in both $$$a$$$ and $$$b$$$. If bits are $$$(0,0)$$$ you go to the top left quadrant, $$$(0,1)$$$ to the top right, $$$(1,0)$$$ to the bottom left, $$$(1,1)$$$ to the bottom right. Then you repeat the process for the quadrant you went to using the $$$(i-1)_{th}$$$ bit and so on. This shows then when you eventually reach your matrix, it will be inverted only if the parity of $$$bitcnt(a)+bitcnt(b)$$$ is odd.

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

Where is the author's code for problem F???

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

E problem , if bitcnt(a)+bitcnt(b) is an odd number, then the matrix is inversed. Who can prove it ?