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

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

Hi, all!

This is not Tommyr7, but the impostor behind the round again (guess who I am? :P). The statements are written by me. Thank you, everyone, and hope you've all enjoyed the round!

Any feedback on problems and tutorials are welcome — we look forward to doing even better in the future!

Here are some of the detailed tutorials!

Tutorials

934A - A Compatible Pair

Author quailty / Preparation quailty / Tutorial quailty

Tutorial
Solution (quailty)

934B - A Prosperous Lot

Author Tommyr7 / Preparation cyand1317 / Tutorial cyand1317

Tutorial
Solution (Tommyr7)

933A - A Twisty Movement

Author visitWorld / Preparation visitWorld / Tutorial visitWorld

Tutorial
Solution (visitWorld)

933B - A Determined Cleanup

Author Tommyr7 / Preparation cyand1317 / Tutorial cyand1317

Tutorial
Solution (Tommyr7)

933C - A Colourful Prospect

Author quailty / Preparation quailty / Tutorial quailty

Tutorial
Solution (quailty)
Solution (cyand1317)

933D - A Creative Cutout

Author skywalkert / Preparation skywalkert / Tutorial skywalkert

Tutorial
Solution (skywalkert)
Solution (demon1999)

933E - A Preponderant Reunion

Author skywalkert / Preparation skywalkert / Tutorial skywalkert

Tutorial
Solution (skywalkert)

Thank you everyone!

Happy Valentine's Day and happy Lunar New Year!

Разбор задач Codeforces Round 462 (Div. 1)
Разбор задач Codeforces Round 462 (Div. 2)
  • Проголосовать: нравится
  • +66
  • Проголосовать: не нравится

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

Auto comment: topic has been updated by Tommyr7 (previous revision, new revision, compare).

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

Feedback: Terrible pretests for D and terrible spj for E.

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

Python2: 35268543

[igorjan@archlinux]$ du -b B.py
44	B.py

Perl: 35270787

[igorjan@archlinux]$ du -b B.pl
38	B.pl
»
8 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

div1C: find all intersections -> build graph -> count edges and vertices -> F = 2 + E — V . Am I right?

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

Why is div1C = gym100200C ?

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

Auto comment: topic has been updated by Tommyr7 (previous revision, new revision, compare).

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

For Div1 C, it should be 3 if n=2 and two circles are neither intersect nor tangent

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

Auto comment: topic has been updated by Tommyr7 (previous revision, new revision, compare).

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

The tutorial isn't up for Div1A, and the code looks quite complicated. Here's a much simpler way:

Let's say we flipped a segment and found the best subsequence. It will look something like this: 11111122222222

Suppose we unflip the segment. Now the sequence looks like this: 1111222211112222

That is, it will be composed of 4 regions, made of 1s,2s,1s,2s. So the problem reduces to simply figuring out the longest subsequence of such form in the original sequence, no flipping necessary.

This can easily be done with a single O(N) traversal of the sequence. At each point, keep 4 values: the longest sequence of 1s, the longest sequence of 1s2s, the longest sequence of 1s2s1s, and finally the longest sequence of 1s2s1s2s.

EDIT: The editorial is up and they put this solution in it. Still, strange that they would use the complicated N^2 solution as the sample.

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

For the benefit of all beginners, here's my O(nm) solution for Div 2 A.

http://mirror.codeforces.com/contest/934/submission/35280443

My idea was to find all products, find the maximum product A[i]B[j] in one O(nm) scan.

Then, find the maximum without that particular A[i], in another O(nm) scan.

The best A can do is hide at most one element and A has to hide the element that contributes to the greatest product.

https://github.com/MathProgrammer/CodeForces/blob/master/Explanations/Explanations%2019/A%20Compatipble%20Pair%20Explanation.txt

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

Div 2- C/ Div-1 A:

I am unable to understand this case for which my solution is failing. The editorial is not yet there. Can anyone explain how is the answer to pretest 3 is 116. Many thanks :)

http://mirror.codeforces.com/contest/934/submission/35263594

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

My solution for "A Prosperous Lot" : 54 bytes. can we have a look at Tester Solution please. n=int(input()) print(["8"*(n//2)+"9"*(n%2),-1][n>36])

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

Not the best idea in E task. Complicated geometry that required special knowledges — it is not for 2-hour contest :(

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

Auto comment: topic has been updated by Tommyr7 (previous revision, new revision, compare).

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

Where is Div2D ? Edit: Sorry.

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

Can someone explain me div2 C?

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

Can someone explain another solution for problem

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

for Problem C, my solution is to regard each a[i] as the position changes from 1 to 2. That means, we calculate all 1's before i and all 2's after i, so we can get all maxium length through a[i] in O(n).

Then we do the reverse, we can regard the reverse section [L, R], only L < i < R will affect a[i]'s max length, and i split the section into two parts, [L, i) and (i, R]. For section [L, i] after reverse, we can minus all 1 and plus all 2 in the section. And for (i, R], it's simmilar but we plus all 1 and minus all 2.

Also, these two section are distinct, so we can get max L and R, sepeartely. Therefor the whole algorithm is in O(n^2)

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

Can someone explain to me why my solution for problem C in JAVA is giving TLE in large value of n. I am using similar approch as sak3t described in this comment. I see that c++ solution easily passes whereas Java is having a hard time.

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

Can anyone please provide beginner friendly explanation of Div2 E?

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

Can someone help me with my solution of DIV2 C. http://mirror.codeforces.com/contest/934/submission/35292502

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

In Problem A i just sorted the 2 arrays and the answer was the mutliplication of a[n-2]*b[m-1]

i skipped the max of tommy and get the max of banban * the max of tommy after deleting the it's first max and i got WA on test 10 any help please

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

How could I get the intersection of two circle, my previous method didn't provide enough precision.

I can't get the main idea behind quailty's method.

Could someone explain it for me?

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

For Div.1 D, there's a terrible mistake in the tutorial which almost drove me mad this morning and took me hours to realize what was wrong.

That polynomial of L mentioned in the tutorial appeared to be ,

but the correct polynomial seems to be .

Please fix it as soon as possible!

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

Many thanks Codeforces for the interesting problems.

RE: 933C - A Colourful Prospect

Is there an explanation that the solution to test #115

3

0 0 1

0 3 2

4 0 3

is 5 not 4?

It seems that C1 = (0,0,1) is tangent to C2 = (0,3,2) at point P12 = (0,1), and is tangent to C3 = (4,0,3) at point P13 = (1,0). And, that C2 and C3 are not tangent and do not intersect. Therefore, the number of regions should be 4 not 5.

Thanks in advance for explaining.

Best wishes.

An update: A further analysis of the test case revealed that C2 and C3 are tangent at P23 = (8/5,9/5). Therefore, the area surrounded by the three arcs on C1, C2 and C3 extending between each pair of P12, P13, and P23 constitutes the fifth region.

Thanks again and best wishes.

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

can anyone please explain the approach behind div2A? I am not getting why do we need to print the minimum of maximums and not the 2nd maximum?

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

Please note tutorial for 933E has been revised for better understanding. Hope it will be helpful :)

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

For div2 E can anyone explain why is my algorithm wrong? Code

if n==1 , ans=2 ; if n==2 , ans=3 (two circle,universal region) , for every pair of circles intersecting:ans++ if n==3 , ans=4 (three circle,universal region), for every pair of circles intersecting: ans++. if all three intersects, ans++.

I cannot understand what is wrong with this algorithm? TIA.

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

Can anyone please explain the question "A twisty movement" DIV2 C with this test case n=12: 1 2 1 2 1 2 1 2 1 2 Length of the Longest subsequence after the reversal is 8! Can anyone please tell [l,r] which need to flip to get this answer

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

For 933 A, do not read the editorial's solution. It's, in simple words, bad. Use Um_nik's solution as well. Easy to understand.

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

How would you solve D1d's bonus? Sorry for necroposting but I can't find it anywhere.