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

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

1304A — Two Rabbits

Tutorial
Solution

1304B — Longest Palindrome

Tutorial
Solution

1304C — Air Conditioner

Tutorial
Solution

1304D — Shortest and Longest LIS

Tutorial
Solution

1304E — 1-Trees and Queries

Tutorial
Solution

1304F1 — Animal Observation (easy version)

Tutorial
Solution

1304F2 — Animal Observation (hard version)

Tutorial
Solution: O(nmlogm)
Solution: O(nm)
Разбор задач Codeforces Round 620 (Div. 2)
  • Проголосовать: нравится
  • +205
  • Проголосовать: не нравится

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

Interesting, I was just talking to a friend a few days ago about how I've never seen max-queue used in a Codeforces problem. The solution for F2 is nice.

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

✓ Nice problems

✓ Clear statements

✓ Fast editorial

Great effort mate, very nice contest!

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

Thanks for the quick tutorial <3 Thanks for the contest <3 Have some good days problem setters <3

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

Editorial of B: Instead of "pick any one of them and put it in the middle.", pick the longest one.

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

So I guess, that I found the best way to have good score in contest.

You should test the round, and the Power From MikeMirzayanov will come to you.

Thanks MikeMirzayanov

And thank you for the great contest. I really enjoyed problems.

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

Can someone explain why this greedy method for problem D is correct? 71148664

(topological sort with heap/priority_queue)

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

I think i have an easier to code solution to D using two pointers and reverse() function in C++.

Here's my submission.

I can explain it if you want but it's easy to understand I guess.

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

For D to make LIS exactly k I think, the k must be possible to be represented by sum of length of increasing consecutive groups + 1 and be more than length of max group Example:

>>><<>>><>>><><<

we have 4 groups << < < <<

so k can be 3 (our minimum, because it is maximal length of single increasing group +1) k, can also be 4 and 5 and 6,7 for 3: I first fill rightmost group of size two, and others should be filled up from right to left (to avoid random LIS):


<< < < << 12

then I do

 << < < <<
 56 4 3 12

and then on not filled space I follow in increasing order from right to left

>  >  >  < < >  >  >  < >  >  > < > < <
17 16 15 5 6 14 13 12 4 11 10 9 3 8 1 2 7

so we have 5, 6, 14, or 1, 2, 7

for k=4: I would do:


> > > < < > > > < > > > < > < < 5 6 4 1 2 3

then fill up again:

>  >  >  < < >  >  >  < >  >  > < > < <
17 16 15 5 6 14 13 12 4 11 10 9 1 8 2 3 7

and we have 1,2,3,7

need more detailed analysis for how we can combine different groups, but for problem that was given in editorial, I was putting all together by filling up groups from left to right for longest LIS, and from right to left to shortest LIS. So I by offsetting start point we can get different k

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

Question on A

On 71161349 I got WA on test 3 and after I had changed long long into int I got accepted. I wasted 6 resubmissions and a lot of time during the contest thinking my Idea was wrong. This is the good one 71163490.

Anyone know what's going on here?

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

In problem div 2 C how are we updating the value of mx and mn? Can anyone explain it please?

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

Whats wrong with this code failing test 3 3rd token :
https://mirror.codeforces.com/contest/1304/submission/71185623

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

There is another solution for F(maybe only a bit different).

We don't need to calculate sum(animal[i][j…j+k−1]) for each j.

First let us solve max(1,j-k+1)<=x<=j,then the other part can be solved using the same idea.

we define P[i][j] as dp[i][j]-sum(animal[i+1][1....j-k+1])

then dp[i][j] is updated by max(P[i-1][max(1,j-k+1).....j]+sum(animal[i…i+1][j…j+k−1])+sum[i-1][1...j-1]).

Since sum(animal[i…i+1][j…j+k−1])+sum[i-1][1...j-1] is a constant for each <i,j>

We can find out the max value by simple RMQ algorithms on array P[i-1]

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

Nice Problemset and editorial. I really Enjoy the contest. Thanks to problem setter.djm03178

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

I believe there's something wrong with the second question's answer as if it wants the longest palindromic string then for the case like

5 2 oo ox xo xx xx

The answer can be "10 , xoxxooxxox" but the answer given by the above code is "6 , oxxxxo" which I don't believe is longest one . Even for the test case like

3 2 xx xx xx

The output from the code is "2 , xx" and not "6 , xxxxxx" . If I'm wrong anywhere please let me know .

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

What's the problem wtih my code?

https://mirror.codeforces.com/contest/1304/submission/71196899

My method as similar sa the editorial.

Just he use the arrays.Please tell me where my code is wrong.

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

Can somebody please tell me why I am getting Runtime Error on pretest 3 on this submission for problem C?

There is an assert statement which verifies whether the visit time of customers are in non decreasing order. Runtime error seems to suggest that there is a test case in which visit time of customers are not in non decreasing order.

When I removed the assert statement, I got WA. See this.

And, when I myself sorted the customers according to their visit time, I got "Accepted" verdict. See this.

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

In problem E,

  • The simple path from $$$a$$$ to $$$b$$$ without using the added edge.
  • The simple path from $$$a$$$ to $$$x$$$ without using the added edge, plus the added edge, plus the simple path from $$$y$$$ to $$$b$$$ without using the added edge.
  • The simple path from $$$a$$$ to $$$y$$$ without using the added edge, plus the added edge, plus the simple path from $$$x$$$ to $$$b$$$ without using the added edge.

What is the difference between the second and the third case? For example, in the case below:

5
1 2
1 4
2 3
4 5
1
3 5 2 4 k

We can see that the three paths are as follow: $$$2 \to 1 \to 4$$$ $$$2 \to 3 \to 5 \to 4$$$ $$$2 \to 1 \to 4 \to 5 \to 3 \to 2 \to 1 \to 4$$$ But in this path, noticing that the edge (1, 2) and (1, 4) are used twice, we can ignore the influence they bring to the parity of the total length, thus the path becomes: $$$2 \to 3 \to 5 \to 4$$$ And the second and the third path become the same. So what's the meaning of considering the third case? Or did I forget to consider some other situation?

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

Can anyone please look into My code for Problem C. My logic is similar to the editorial but it shows WA for the 32nd token of test 3.

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

71201513 Could someone please debug the run-time error I'm getting on this solution? Apparently the error happens in the last loop, where the assert condition fails.

for(i=store.size()-1; i>=0; i--){
        assert(i>=0 && i<store.size());
        string temp1 = inp[store[i]];
        reverse(temp1.begin(), temp1.end());
        out.append(temp1);
    }

I tried printing i, and it printed out a large value.

for(i=store.size()-1; i>=0; i--){
        if(i<0 || i>=store.size())
        {
            cout<<"OOH!: "<<i<<'\n';
            break;
        }
        string temp1 = inp[store[i]];
        reverse(temp1.begin(), temp1.end());
        out.append(temp1);
    }

OUTPUT:

OOH!: 4294967295

It's really puzzling and I would appreciate any help. Thanks!

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

for problem D. How to find a sequence for fixed length k LIS?

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

My solution to the problem E is the same as author's, even my implementation is quite similar to his but I have repeatedly got TLE on test 2. I've generated lots of huge testcase to check but it runs all the way fine, no probs. And test 2 is a small test, so I tried to generate as similar to the testcase as possible but no issues found so I desperately ask for your help on my case: https://mirror.codeforces.com/contest/1304/submission/71262563 I'd be very thankful.

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

I'm not understanding why I'm getting WA in Problem C My Submission. Can anyone help?

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

In problem E, we need to determine the root to use LCA. But as there is no info about that and all the edges are bidirectional, how are we going to determine the root? Sorry to bother you.

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

In problem C, can someone explain how the condition mn-k <= R and mx+k >= L is working?? Thanks in advance :)

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

for solution of (B) — Longest Palindrome:

input:
3 3
aba
aba
aba
given output:
3
aba

but, it should be

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

Hi, your tutorial is very good but i have one doubt with the solution of B(Longest palindrome). for example if my input is : input: 3 3 tat cat tat output: tat i think right answer is : tattat

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

Please anyone can help me to figure out what wrong with my submission. I struggle in many hours on test case 8, problem E.

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

Honestly, for Problem D

is comment ne bacha liye, Editorial me to chutiya kaat diya.

English Translation:

For Problem D, this comment saved my ass. Editorial is really messy and not clear.

P.S.: If anyone got Editorial's explanation for Problem D, Please Explain.

(Also what is perm[] array in editorial ?! :/)

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

    I don't know which part you think is messy. The comment you linked is identical to the editorial, even the explanation's logic and the solution's outputs are the same. Maybe the comment's implementation is a little easier.

    Anyways, perm means permutation sequence the problem is asking you to find. perm[i] is the i-th number of the answer.