Hey, Codeforces!** (*^‿^*)
Pinely is here! We are glad to invite you to participate in Pinely Round 5 (Div. 1 + Div. 2) which will start on which will start on Oct/30/2025 19:35 (Moscow time) Note the unusual time of the round.
- You will be given 8 problems and 3 hours to solve them. The round will be rated for everyone.
The problems were authored and prepared by pinely Endagorion ch_egor aleex AndreySergunin budalnik cdkrot gepardo gleb.shnshn Ormlis VArtem along with AmShZ and our special friend Golovanov399
Thanks for all your ideas, remarks, improvements and attention for details (*ˊᗜˋ*)/ᵗᑋᵃᐢᵏ ᵞᵒᵘ*
We would like to express our special thanks:
Endagorion for curating the round on Pinely side and surviving through all storms
Testers team: Broder, jason_sun, efishel, A_G, CatsAreCool, reirugan, yuanruiqi, Wayne_Yan, madlogic, isaf27, weirdflexbutok, SirTechnical! (ノ◕ヮ◕)ノ*:・゚✧
MikeMirzayanov for the great Codeforces and Polygon platform.
And, of course, you for participating (ᵔ◡ᵔ)
Prizes: The top 15 contestants will receive branded Pinely zip hoodies. Each hoodie can be personalized with custom name patches, making every prize truly unique.
To learn more about pinely you can visit our site or you can find our colleagues on CF in pinely organization.
UPD: Score Distribution
500 — 1000 — 1750 — 2250 — 3000 — 3250 — 3750 — 5000
☆ミ(o*・ω・)ノ Editorial is HERE
Congrats to winners! And everyone for participating ♥♥♥
- tourist
- Kevin114514
- Um_nik
- Petr
- jiangly
- Nachia
- ksun48
- hos.lyric
- BurnedChicken
- potato167
- VivaciousAubergine
- yosupo
- conqueror_of_tourist
- 353cerega
- 244mhq









good luck may you get positive delta
good luck everyone
Pinely Round is back after 15 months!
let's goooo, pinely personalized hoodies! Thank you for everything you do for the CP community :)
:(
Good luck everyone :)
Hot round
Golovanov399 you special fried chicken
nah! special fried meow meow
As a tester, I wish everyone a great time enjoying these interesting problems.
Note the unusual start time?
vary nice
I wish that there is atleast 1 interactive problem!
Nice photo. It reminds me a little of those photos where they find narcotraffickers and the police turn around to avoid exposing their faces. No offense.
Kirky fanboy said calmly: No offense. Stay quiet next time you're online.
All the best everyone !!
Score distribution?
I'm also waiting for that.
Whoever read this comment will be increase rating
good luck everyone (*^‿^*)
Goodluck everyone.
Tips to become permanent speaclist...not just crossing the 1400 ? Please enlighten me.
I want a hoodie too :(
Well, I expected to join this contest as my first one, but the time isn't so friendly for Chinese competitors(I think so).
The time is so late! I can't participate :((
worst contest of my life.
Will this contest be too hard for newbies?
Yes , but do participate
Score distribution?
Any update on score distribution and the presence of an Interactive problem?
There're 2 which will start on on the paragraph 2.
Only 5 hrs remaining,where is the score distribution?
Where are the score distribution?
Score distribution is on the way ( ̄^ ̄)ゞ
This was my first time testing. As a tester, GLHF!
wish it wasn't this late, but hope It's a great round for everyone :)
user:SirTechnical
isn't rendered correctly ig .
It is two hours before contest but we still don't know score distribution.
I took a hiatus from competitive programming and decided to restart this week. I took a look into my contest history and what a surprise — the last contest I participated in was Pinely Round 1! What a coincidence. It must mean positive delta, so let's go.
Monkey's paw curls again. I did get my positive delta, though only in contribution, not in rating. :(
This didn't age well.
I need the score distribution, SIRS !!!
Ta Da!
Score Distribution here 500 — 1000 — 1750 — 2250 — 3000 — 3250 — 3750 — 5000
CDN
My friend Meeple got banned, but i am sure he wasn't cheating. Can he get the reason for being banned?
We've come to the conclusion that he's actually alt of how_to_solve_D_Div2.
ah, okay, thanks for quick respond
The TT_FAN account was banned too, and he did not cheat or use AI. Could you explain this as well?
Wrong answer on pretest 2
Wrong answer on pretest 2
Wrong answer on pretest 2
Wrong answer on pretest 2
Wrong answer on pretest 2
Too many alts in the scoreboard
i dont know that task c is easier than b i cant do b(i just spend 2 hour to task b) =((((
same brain
Implementing B is such a pain in the ass XD
Depends on your idea. Just checking 4 types of paths for every (i, j) works. It's just a recursion
Shit!!!!! should have seen that :)
Staircase can be either diagonal , or anti-diagonal. Lets solve for diagonal first...
Part 1 : There is even simpler approach. if grid[i][j] == '#' then for any Diagonal parallel staircase pattern, (i-j) can have at most 2 distinct value. (handle case of 2*2 square ).
Part 2: Now, how to handle anti-diagonal staircase ? (simply reverse all the strings in the grid,,, anti-diagonal will become diagonal ). Make a call to Part1 function.
I have also seen that, but I missed the fact that is not enough to only check the first "#" :(, because you can hvve something like:
...##...
..#....
I lost 2 hours finding out that break... Problem C was much, much easier. I assume problem D was also easier than B given the same amount of time for it.
You missed one 2x2 box edge case in your drawing. But yeah it was pretty much it. Very very easy once you get the intuition
Here come the downvotes lol. What even was B, C was so much easier. Can someone drop some hints for B?
I think expanding the diagonals on any # will work , i messed up the implementation very hard
The final board is either a 2x2 square or a diagonal line. Count the black squares. If there are no black squares output YES. Pick a black square. Check all 2x2 squares which contain this square. If one of them contains all black black squares, output YES. Check every diagonal going through your chosen black square. There are 4 valid diagonals. If one of them contains all black squares output YES.
Else output NO.
Example of a Diagonal:
This looks so much cleaner than what i was trying to implement .
Time to go back to pupil .
https://mirror.codeforces.com/blog/entry/147716?#comment-1322539[can you please explain this when in question it is mentioned we can change . to # to achieve the following conditions](https://mirror.codeforces.com/blog/entry/147716?#comment-1322539)
Problem B is harder than usual. For me, it's harder than problem D.
What are the ideas for D?
I thought it has to do with connected components. By making an edge between two conflicting indices, we can have several connected components without an odd cycle. But apparently that doesn't work
I tried that only, but it didnt work
I, similarly, got sidetracked by modelling the problem as a graph. What was your logic for CC with odd cycles? If there is any edge then there exists a conflict.
I was thinking along the lines of: minimum how many nodes need to be removed, and all edges to and from those nodes, so that all edges are removed from the graph. I found out that this is called the vertex cover problem and it is NP-hard. So that was a dead end.
Some articles I looked up:
worst contest of my life.
Problem B >>>> Problem C
I don't know if I got lucky with $$$B$$$ or if I've really improved at solving constructives.
Any hints for c?
I guessed that prefer maximum value when points can be earned else just choose minimum value,
also more comfortable in guessing because
pretest = system testyou can make max floor(sum(ai)/X) of products that gives you bonus points. Let this be K. Sort all products, take K most valued.
Can you please tell me what I am doing wrong here 346716142
sum can overflow
Think of how you can increase bonus by using largest prices
We can solve the problem by Greedy Algorithm and Double Pointers.
Consider currently the total cost is $$$S = qX + r$$$, where $$$0 \leq r \lt X$$$, then now we have loyalty score of $$$q$$$.
Getting $$$a_i$$$ bonus points is equivalent to $$$r + a_i \geq X$$$, since our new cost became $$$S = qX + r + a_i = (q+1)X + r'$$$, where $$$0 \leq r' \lt X$$$, $$$r' = r + a_i - X$$$, and that means our loyalty score increases from $$$q$$$ to $$$q+1$$$.
It's better for us to get bonus points when purchasing expensive items. Then we sort the original array at first, initialize $$$l = 1$$$ and $$$r = n$$$. We need to record our current cost $$$cur$$$ in modular $$$X$$$, so at first $$$cur = 0$$$. Every time we do the following process:
The process terminates when $$$l \gt r$$$, that means we have selected all the items. We have calculated the final bonus points in the process, and we can use a vector to record the order we purchase items, finally just print them out is OK.
For each testcase the time complexity is $$$O(n\log n)$$$, which is when we are sorting the array.
Spent ~45min on a wrong-understood problem
B — you can only make staircase like pattern, bit more code than I expect for
B— i am hoping authors have a simpler solution in mind for choosing the problem as BC — greedy guessforces
D — can't solve, please give ideas !!!
I don't even want to upsolve B. Why do you people keep such problems which don't happen even after staring at the screen for hours and hours? My friends advised me against participating in pinely rounds telling that they are trash contests which just test constructives and are good for dropping 200 points. Yeah, I am the fool here.
If you're weak in any topic, you should solve more problems of that topic and get good at it. Not complain aobut it.
after reading the solution of b i feel like a stupid shit because in my mind i was stuck proving things which were untrue. Skill issue from my side.
What were you proving? If you want the intuition for B's solution, then try drawing a grid and coloring the cells. If you start at a cell, and keep coloring the orthogonal cells while following the 3rd condition, you will realize that either you can form a 2x2 square, or a staircase like pattern.
My solution was just to check for these cases. If there are total 4 black cells then check for a 2x2 square. Also, check for all the different staircase patterns possible.
Implementing the staircase check can be tricky, but you can just repeat code if all else fails.
Image
For problem B, check all black cells belong to 1 of 4 these paths
Problem B was B div 2 type but much harder than c, I think problem b worth more score
Big thanks to the organisers for the worst round I’ve ever taken part in.
why my code is skipped? could someone please explain? Does that mean the system thinks I cheated? That's not right... 346728132
If you have multiple submissions for the same problem which passed pretests, only the last one counts, others are skipped.
oh my, thank you. I just wanted to check whether another approach is correct. It's lucky that the time span is not so long, so I won't lose so much score. Definitely won't do that again in the future.
coz you made one more submission later.. only last one counts.
I think in this case cheating is not the reason
Do not resubmit. Especially we don't have hacks for A-D now.
B>>>>C
This does happen when the number of testers are less than that of authors.
I was surprised only 12 testers test this round. In my round we have nearly 40 testers with at least two testers for each level from grey to LGM. If they have more expert testers or below they will not make B so hard and C so easy, at least they will swap B and C.
I feel some good things and bad things in this contest, so please let me share:
overall, the contest is interesting for me, but there is a room for improvement. Thanks for the round!
What a round!! I'm never participating in a Div 1+2 again , it feels like an unbreakable curse.
You made me lose delta in under an hour. The curse is now officially proven.
I think the testers team should have had some people with rating < 1900. That would have given you a better indication of the problems difficulty.
Thanks for the time you put into preparing the problems though!
why my problem A hasn't get into Final test? 346670098
But my score of this problem gone anf the system test is over and it showed me -1 on this question but I truly passed it in the exam you can see my submmisions
What do you mean? It correctly shows "Accepted" in standings.
it turns normal now,i think it may be bugs,sincerenly sorry for the inconvenience
Rage Bait contest !!!
Why is hacking of question C prohibited? I passed the test 346709015, but I later discovered that there were issues with my code, such as
1 4 4 3 3 3 10The answer might be 19, but my output was not that.I don't think so, all permutations of 3 3 3 10 gives an answer of 16
Sorry, I overlooked the restrictions of the question. Nevertheless, I still feel that my code is not quite correct.
Why do you think it's incorrect, even though it passed system tests and you are not able to find a counter test case? FWIW, I stress tested your solution for $$$1 \le n \le 100, 1 \le X \le 1000$$$, with randomly generated arrays and your answer matches that of my own solution.
Thank you for testing my code. In fact, the test cases I provided earlier were actually my own counterexamples, but they were illegal data. My code was also developed without the constraint that $$$a_i \lt = X$$$. I made a mistake in interpreting the constraints of the problem.
great contest! thank you very much. i would say that B is too hard for B. D is such a cool problem! and F is very nice.
I think the contest setters underestimated how hard it is to make the necessary observation.
I didn't see it until I looked at the editorial, and all the while I thought it was DFS(I have a habit of solving problems with DFS when they ain't DFS)
I disliked the round. I think it was poorly prepared, which is hinted by the late anouncement of the score distribution and by the lack of the list of testers.
I had, I believe, my worst performance this round. But I also think that the round was one of the worst I've seen so far in terms of the problem set balance.
I agree. C a lot easier than B. I think problem B is very random for 1400-1700 contestant, with unpleasant implementation
Was the solution of E using this technique planned? Or were the constraints just randomly chosen to be small?
My solution is a bit of an overkill, it runs in $$$O(n \sqrt n)$$$ (or maybe less if the queries are actually in a good order which I didn't manage to see) and calculates prefix sum of $$$C_n^k$$$
Short answer: well, yes (at least my solution works like this)
You actually can save the current value of $$$\Sigma_{k=0}^yC_x^k$$$ where $$$x$$$ is the number of free cells and $$$y$$$ is the max number of ones we can place there. Now let's see that both $$$x$$$, $$$y$$$ change only by one each time (if moving from right to left), thus it's easy to recalc. If $$$A$$$ is the current value — you can increment $$$x$$$ making $$$A := 2 \cdot A - C_x^y$$$ and easily increment / decrement $$$y$$$ when necessary.
Time complexity is $$$O(N)$$$
I also noted that I can maintain the sum but it was easier to do in a Mo style offline, so I just went with it
lol. why are there soooo many submissions for H??
oh no. I thought I coud get positive delta, maybe due to the starting and ending time there are many registered participants didn't participate so my rank is actually a lot lower than it seems to be.
I have wasted 2.5h on problem D, any hints please?
Konig's theorem
Good contest! Thanks
orz 353cerega
Thankyou for the great round, the questions were great. B was actually easy once you figured out the 3 cases. Overall missed specialist by not being able to solve B quick enough and also not being able to solve D, else could’ve got a delta of ~150
Thanks for the great round — I particularly enjoyed problems D and E. For D, I’ve seen a large number of different solutions (and mine is different from all others I’ve seen :)), which really adds to the beauty of the problem.
Just a small proposal (though there might be downsides I haven’t fully considered): would it make sense to somehow group Div. 1 participants in the same rooms for contests where hacks are disabled on the easier problems? I really enjoy the hacking aspect of the contest, and I think most of the people solving any of the harder problems were among the only ones (if not the only ones) to solve anything >= E in their room during the round.
Thanks again!
isn't D dp + binary search. What other ideas are there can you please tell me?
For E, I noticed that once we switch 1->0 or 0->1 we need sum 0 for next k-1 always. But could not code in time.
There are similar plans.
I really hope Codeforces doesn't go in this direction with regards to hacking... In the recent years because of the strong tests, hacking can be mostly ignored, which is a great thing.
My personal feeling on hacking is that it incentivizes bad behavior, such as making your code harder to read or putting in something which looks like a bug in your code which actually isn't. As a contestant, I don't want to have think about these concerns. It's great that everyone can choose to solve the problems in their own style, programming language, etc without having to worry about what others are doing. (Not to mention hacks adding unneeded randomness/unfairness to the results.)
I enjoy CF for the well-prepared and interesting problemsets, and trying to solve those problems quickly. Going back to the days of hacking would cheapen the contest experience which in my opinion is great as it is.
Obfuscation is technically against the rules on Codeforces. The extent of what is considered obfuscation would be subjective, but the rules do state that it is prohibited.
I can't say I disagree with more-or-less any of the points you are making, but my take on this would be a situation (which happens pretty frequently atleast around the rating I am):
I fully agree that it adds some randomness and that it is imperfect, but I still think that there might be some pros of having hacking included.
Legend tourist is back!
Maybe he thought let's get this Rank 1 again :)
Whoever got a negative delta downvote this announcement blog
i think B harder than C
Problem B was the worst I've ever seen.
In problem B 3rd test case
3
.##
.##
...
How does it satisfy: condition 2 & 3
if I make (3,1) to black 3
.##
.##
#..
Then condition 2 :it should be possible to go from any black cell to any other by crossing several vertical or horizontal cell borders while visiting only black cells. You can't go directly through the corner of a cell. Then (2,2) to (3,1) we have to go through corner.
If we make another white cell to black we will violate condition three.
and why would you do that? it says we want to connect all black cells that are present "initially". In this case there is just one component so its fine already. This was a cool pattern observation problem though.
In question it is not mentioned initially and also they mentioned to achieve the following conditions we can change . to # .
Thank you for replying I'm thinking, I was missing something
You can change '.' to '#', but you are not forced to do that. You can also just leave everything as is. In that one example there is no need to change anything, because all 3 conditions are already fulfilled.
If I change . to # it violates condition it violates 2 or if I make another change it will violate 3 as well. Then according to output mentioned
For each test case, print "YES" if it is possible to paint some white cells black to satisfy all the conditions, and "NO" otherwise. __
"some white cells" can also be "no white cells". You can paint no white cells and the conditions are satisfied.
Just a FYI, Axoryn is a cheater. One can easily see from his LeetCode submits that's he's cheating. Go to this link and click on his Q4 video: https://leetcode.com/contest/weekly-contest-473/ranking/?region=global_v2
Problem B was wayyyyy harder than C :/
Does anyone know what testcase 76 in 'test2' is? I'm failing only because of that specific testcase. in the question B
As a tester, I wish everyone a great time enjoying these interesting problems.
Can anyone let me know what is the rating for the problem D
Hello!
I really don’t understand what’s going on — this is the third time I’ve received a notification saying my submission has duplicate content. I want to confirm that I have never copied any code from anywhere before submitting. Maybe I should stop competing on Codeforces because of this.
Hello,
I received plagiarism warnings for problems 2161A and 2161D. I want to clarify that I solved both problems completely on my own and never shared or copied code from anyone. For 2161A, the solution was quite straightforward, so it’s natural that many participants could write very similar code. It’s also possible that I might have used an online IDE during the contest without realizing it could make my code public. I’ll make sure to use only private or offline environments in the future.
Kindly review my case if possible. Thank you for your time and understanding.
Hello. My submission 346706198 for problem 2161D was marked as similar.
I recently read that blog: https://mirror.codeforces.com/blog/entry/105697
Here is written:
"In any bipartite graph, the number of edges in a maximum matching equals the number of vertices in a minimum vertex cover."
I solved the problem using that approach.
The key observation is that we can assume each number as a vertex, and there is an edge (i, j) when i < j and a[i] + 1 = a[j]. Because we put edges between odd and even numbers, it makes graph bipartite, partitioned by parity groups.
The task then reduces to covering all such edges with the minimum number of vertices, which is exactly the Minimum Vertex Cover problem on a bipartite graph. By König’s theorem, the size of the minimum vertex cover equals the size of a maximum matching as mentioned above. So we construct the bipartite graph, find the maximum matching, and the answer follows directly from |matching|.
I can provide handwritten notes if needed. Thank you for your time.
I didn’t copy my code from anywhere; maybe it just happens to coincide.i write code with my own..i have proofe of my logic ..if you want to know..then you can knock me...i happily tell you about my logic
Attention! Your solution 346728172 for the problem 2161B significantly coincides with solutions woony/346697295, nurdaee/346715021, MrWizard_574/346728172. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://mirror.codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.
I don't know why I got this message, I have not cheated nor do I know these guys. Also, they made this round unrated for me. What should I do?
Hello, I received a plagiarism warning for submission [346728714] in problem 2161C. I did not share or copy code from anyone. I only submitted my solution on Codeforces and nowhere else. I implemented it myself after understanding the idea from the editorial. The similarity must be due to both of us following the same approach. Please review — this was my own work. Thank you.[submission:346728714][problem:2161C]
Hello, I received a letter stating that my solution 346697295 for problem 2161B significantly coincides with the solutions of other participants and is included in a group of identical solutions: woony/346697295, Nurdaulet-018-2029/346715021, MrWizard_574/346728172. I wrote the code entirely on my own during the contest, I do not know the other participants mentioned, and I did not use any external sources. The problem was constructive and required checking "stairs" and "squares" because they are the only possible arrangements of black cells, and the implementation involves repetitive code segments due to the nature of building these stair patterns. This logically led to similar implementations among many participants, including myself — hence the similarity in code structure and logic. I did not use any public online IDEs and did not share my code with anyone, so I ask you to reconsider your decision and take into account that the coincidence was unintentional, resulting from a standard solution approach rather than a rules violation.
it give me -65