Автор pinely, 3 года назад, По-русски

Hey, Codeforces!

Pinely is here! Just like every year, we are sponsoring the PTZ competitive programming camp. As a part of this, we have prepared a contest for the participants and invite everyone to join it on Codeforces.

Pinely Round 2 (Div. 1 + Div. 2) is scheduled to start on 30.08.2023 17:35 (Московское время).

During this round, you will have the opportunity to solve 9 problems within a time frame of 3 hours. The round will be rated for everyone.

The problems have been authored and prepared by the Pinely team: AndreySergunin, ch_egor, Endagorion, amethyst0, zeliboba, zemen along with our special friend Golovanov399.

We would like to express our special thanks to:

We sincerely hope that you enjoy our contest. Wishing you good luck and lots of fun!

UPD. Score distribution: $$$500$$$ — $$$750$$$ — $$$1000$$$ — $$$1250$$$ — $$$1750$$$ — $$$2500$$$ — $$$2750$$$ — $$$3500$$$ — $$$4000$$$.

P.S. If you are interested in working at Pinely, please visit our website: https://pinely.com/, send us an email at hr@pinely.com or fill in the form here

Apply

Congratulations to the winners!

  1. tourist
  2. Radewoosh
  3. QAQAutoMaton
  4. jiangly
  5. Ormlis

Editorial.

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

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

my favourite tester OAleksa

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

Is the cat in Golovanov399 profile coughing?? Or what else it is doing??

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

As a tester I tested the round.

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

As a tester I tested the round.

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

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

irkstepanov orz for coordinating two rounds in a row ...

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

Some of the best problems I have ever seen :)

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

All the best to pinely for not getting down votes this time!

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

During this round, you will have the opportunity to solve 9 problems within a time frame of 3 hours

Why does the contest page shows that it's 2 hours length (?)

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

As a tester, I tested because it clashes with IOI :(.

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

pinely round 1

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

the duration in this blog is 3 hours and the duration in the contest section is 2 hours. MikeMirzayanov

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

So this is only Legendary GM and international GM round.

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

As a blue participant, I hope to stay blue after this round. GL & HF

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

Losing hopes of becoming CM. I wish I knew what I had to do different to achieve this silly milestone. Everyday waking up thinking this contest will make me CM is a curse in itself!

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

Recently the frequency of Codeforces contests is less.

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

As a Pinely Round 1 "competitor" (I say competitor in quotes because it would imply that self destructing and losing 140 points can be considered "competing"), I will be in this contest for redemption.

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

Where's the score distribution??

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

As a tester, hope you will enjoy the problems. It’s been 18 months since the most recent div1 + 2 on a Wednesday

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

As a tester, I hope all of you will enjoy this contest! Also, Pinely Treasure Hunt Contest, which is my first time cooperating with a team and earning knowledge from mind storm & attempts, is also a nice contest, and I recommend it to you all :D

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

3 hours OMG

I can't

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

omg Raksha Bandhan round

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

Hi Codeforces!

It would be very helpful if you can post insights/hints for the problems of this contest on https://starlightps.org. This (Starlight Problem Solving) is a website where people can share and discover key insights/hints for problems (with the help of AI) AND find similar problems (with the help of AI) based on insights they struggled with on one problem. We hope this will help many problem solvers and need data in order for that into happen. (Just keep in mind that you agree to publish the insights under CC by 4.0 license.)

By the way, we are also planning a gift card giveway to people posting insights to a certain number of problems, so stay tuned for that!

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

I want to participate but my sisters will beat me up.

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

Green me pleasēéêè

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

score distribution pleeease

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

I hope this one can reach 1200

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

Keep orange please :)

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

Please let me return to CM (for the fourth time...)

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

Hope to become a master today. TwT

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

As a tester, i hope everyone gets positive deltas

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

Hope to become Specialist today. Finger crossed.

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

As a tester, I'm not a tester.

Any bets on how much rating I'll lose?

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

nice 88005553535 reference

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

Good Contest ever.... Problemset was clear...

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

unbalancedForces

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

speedrunned speedrun

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

Nice contest. I hope pretests for D are good)

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

How to do E?

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

E>FG for sure...

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

    How to do F? Is is again bitsets

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

      use DP: [l,r] is possible iff [l,r'] is possible and XOR[l,r]>=XOR[r+1,r'].

      The constraint equals to XOR[l,r]&Highbit(XOR[l,r'])>0, the following part is trivial.

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

        Thanks but won't it take $$$O(n^{2})$$$ space.

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

          We don't need to store all n^2 states.

          Basically we just care about Highbit(XOR[l,r']) for all possible $$$r'$$$, so we just store the OR sum of them for each $$$l$$$.

          So the memory complexity is $$$O(n)$$$.

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

Could H be solved with segment tree using lazy propagation?

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

another speedforces thank you

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

Was E a directed graph question???

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

Good round. Really liked problems B, C, F, and G.

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

I spent 2 hours trying to get the observation for B. I am so dumb

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

I think A to D is easier than before.

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

I completely don't understand why my solution for problem E is wrong. Simply put, I first do a dp calculate the time , then increase the minimum event by k, one by one. But this approach resulted in a WA,I find this outrageous.

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

Speedrun until "Speedrun"

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

Me in the contest:

First hour: finish A,B C and D

Second and third hour: Stare at E and see my ranks dropping.

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

The contest was really beautiful, and I liked the problems a lot. Definitely one of the best contests I've participated in in the past few months.

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

any hints for D and E?

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

    For D, The dominoes must come in pairs.

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

First time solved G (by guessing) in div1+2 round, and first time got top50 in div1+2 round. I can't wait to see 100+ delta (no FST please).

A: We can record "there are how many online events in total" and "there are how many subcribers are online at most at the same time" during the process, and the first number is the maximum number of subscribers have seen the post, the second number is the minimum.

B: Let q be the inverse function of p, and count there are how many i such that q[i]>q[i+1], we can get the answer. In fact, when we choose x for operation, we let q[x-1]<q[x], and the relations of q[i-1] and q[i] for all i!=x are remained the same. So each operation will decrease #(i: q[i]>q[i+1]) by at most 1.

C: There are n distinct integers in [0, n] (n+1 integers), so there will be exactly one missing number in [0, n]. Let a[0] be this missing number, then each operation will swap a[0] and a[i] for 1<=i<=n, and this will make a[0, n] be cyclic right-shifted (a'[i]=a[i-1] for i>0, a'[0]=a[n]).

D: If there are any row or column with odd cells with domino, there's no solution. Otherwise, we can construct a solution like this: First consider vertical dominos. Because the 1st row contains even cells with domino, and each horizontal (LR) domino has 2 cells in one row, the first row must contain even U-cells (the 1st row can't contain D-cells), and we can color half of them black and half white. Then we colored the 1st row with equal black and white cells, and the D-cells in the 2nd row will also be colored equally (which means 2nd row contains even D-cells). Then because 2nd row must contain even L-cells and R-cells, the 2nd row must contain even U-cells, and we can color them equally again. By induction, we can color all vertical dominos and fill rows equally (Note that vertical dominos will always fill columns equally). Similarly, we can also color horizontal dominos equally.

E: We sort all "start quests" (quests without dependencies) by h[i] and assume we start game by the first start quest (with minimal h[i]). Let dp[i] = the earliest day we can complete quest i (the days are 0-indexed), then the time we complete i-th quest is k*dp[i]+h[i], and the dp formula is dp[j]=max(dp[j], dp[i]+(h[i]>h[j])) for dependency i-->j. Then we need to try to change the quest we start the game. For each start quest, we need to change start time to h[i+1] and change dp[i] from 0 to 1. Of course when we increase dp[i] we need to update dp[j] for all i-->j, but during the whole process, each dp[j] will be increased at most once. So we can update dp[j] by dfs.

F: We solve the problem by check every ranges [i, j] if [i, j] can be remained (we call such ranges valid). First [1, n] is valid. For range [i, j] to be valid, we need a valid range [i, k] where xor_sum[i, j]>=xor_sum[j+1, k], or valid range [k, j] where xor_sum[i, j]>=xor_sum[k, i-1]. If we let high_bit(n) be the highest significant bit of n (example: high_bit(21) = high_bit(0b10101)=0b10000=16), then a >= b is equivalent to (a^b)==0 or (a&high_bit(a^b))>0. The first condition means a==b, and the second means "on the highest bit where a and b differ, a is 1 and b is 0". So [i, j] can be obtained from [i, k] means: there's valid range [i, k] such that xor_sum[i, k]==0, or xor_sum[i, j]&high_bit(xor_sum[i, k])>0. So if we let R_flag[i] = (if there's any valid range [i, k] such that xor_sum[i, k]==0), R_mask[i]=(the bitwise or of highbit(xor_sum[i, k]) such that [i, k] is valid), we can check if [i, j] can be obtained from [i, k] in O(1), and we can check if [i, j] can be obtained from [k, j] by L_flag[j] and L_mask[j] similarly. Thus we can solve the problem in O(n^2).

G: I guessed the answer but don't know how to prove it: build a directed graph with edge i-->a[i], for each connected component, the answer is (prod(deg[u])-sum(deg[u]-1))(prod(deg[v])), where u are nodes on the cycle, v are other nodes.

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

    congrats sir

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

    Sketch of proof for G:

    • A move consists in replacing edges $$$a \rightarrow b$$$ and $$$b \rightarrow c$$$ with $$$a \rightarrow c$$$ and $$$b \rightarrow b$$$.
    • Any node with a self loop becomes inactive for the rest of the process.
    • If the cycle has length $$$1$$$, the formula is valid. For example, you can show that you can always reorder the operations "from the leaves to the root", then it's enough to choose for each node if it's a $$$b$$$ in some operation and with which $$$a$$$. Note that the number of candidate $$$a$$$ (i.e., the indegree) is constant.
    • If you choose $$$a$$$ outside the cycle and $$$b$$$ in the cycle, you get a new cycle of length $$$1$$$ and you can use the formula.
    • If you choose $$$a$$$, $$$b$$$ outside the cycle, you don't affect the cycle.
    • The formula is not valid as it is if you choose both $$$a$$$, $$$b$$$ in the cycle, because of an edge case: if in some moment the cycle has length $$$2$$$ and you choose its nodes as $$$a$$$, $$$b$$$, $$$c$$$, you automatically make $$$2$$$ self loops instead of $$$1$$$.
    • Therefore, you have to exclude all configurations where you make all the self loops in the cycle except one using an $$$a$$$ in the cycle.
  • »
    »
    3 года назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    What's wrong with my e 221169557

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

    Ha, finally understood why my solution for E doesn't TLE. I wasn't able to prove the time limit cause I kept track of the hours taken instead of days. Makes total sense now.

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

How to solve F? Is it checking whether previous block's xor's MSB is set in current block's xor and doing it for n^2 subarrays with bitmasking?

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

There's an $$$O(n\log^2 v)$$$ solution (could be optimized further to $$$O(n\log v)$$$, but I didn't implement it during the contest) for problem F. Unfortunately, I didn't realize that $$$O(n^2)$$$ was enough to pass and wasted too much time on the Polylog solution, which needed much care when implementing :(

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

Is this approach incorrect for E? I do this, and in my brain it feels this should give the correct answer 100%. But I don't get AC.

First, I find the minimum completion day for each node, assuming the roots start at day 1.

Then, I traverse in reverse topological order and try to maximize the completion day of each node, while making sure it doesn't affect it's dependencies.

Now, for each connected component, we have some start point S and endpoint E. We can sort all these by increasing order of start hour, iterate over start hours, and find the answer if we choose to start at this hour on day 0. I print the minimum of these answers.

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

I hope one day I can solve E

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

I really liked F and G although/because I was terribly stuck on both of them! I still feel F is harder than G though. Thanks for the nice round!

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

Can someone explain graph based solution for problem D? Thank You.

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

    dfs for it and keep track for every row and column number of black and white so that when you start a new dfs it would balance this column or row and just keep fliping the color as you dfs from each cell. a check must be made that all rows and columns contain even numbers of half dominos otherwise no solution exist.

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

Consider the following test for E:

1
3 2 12
7 8 0
2 1
1 3

(3 tasks to do at hours 7, 8 and 0; task 1 depends on 2, task 3 depends on 1)

My solution says the optimal order is to first do task 2 (since you literally can't do any other tasks at first) — that will happen at hour 8 of day 1 — then do task 1 (again, you can't do any other task) at hour 7 of day 2 — then finally do task 3 at hour 0 of day 3. Time between first two tasks is 11, and time between second two tasks is 5, for a total of 16.

However, tourist's solution gives the answer 11. What am I missing?

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

It's was my second time i participated,i tried to solve A for 3 hours but i couldn't same happened with me in the first contest ,and now i feel very demotivated , i feel myself very weak, what shall i do? Please help.

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

Third time in row solving c, d and stucking in b so sadd :(

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

Problem D's these days are just....

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

Upto what rank participants are considered for further rounds of pinely ??

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

IS there a way to see a test? For example can you send it to me if I ask nicely?

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

nice name for E. good mid contest motivation

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

Problem B,E,F are really good, especially problem B, which let me stuck for half an hour. Thanks for the nice problem!

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

Thanks for giving a good experience! The problems are interesting , but I haven't solve the B problem. Could someone give me the solution ? Thaks a lot.

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

Can someone explain the idea behind E without dp approach?

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

Can someone explain the idea behind E without DP approach?

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

Is my dp cute?

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

Video tutorial for problems A&B&C in english: https://youtu.be/X08zbEDtaI8

Thought would be useful to the community

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

I hate freaking E problem

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

Was this contest unrated ??

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

Good problems

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

Hi all, it would help if you can post some insights/hints for the problems of this contest on https://starlightps.org. Here's a link to the problems: https://starlightps.org/problems/collection/cf-pinely-2/. This will help us get more data so users can have a platform to:

  • share/discover hints/insights on various problems
  • find similar problems given insights they struggled with.

Check it out if you're interested. Thanks!

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

Felt bad for div 3 lovers who missed yesterday's contest

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

has anyone got a call back from pinely ??

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

Great Contest and Fast Editorial

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

Very good problem! Love from China.