We will hold UNIQUE VISION Programming Contest 2024 Summer (AtCoder Beginner Contest 359).

- Contest URL: https://atcoder.jp/contests/abc359
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20240622T2100&p1=248
- Duration: 100 minutes
- Writer: MMNMM, nok0, ynymxiaolongbao, evima
- Tester: physics0523, kyopro_friends
- Rated range: ~ 1999
- The point values: 100-150-350-450-500-550-600

We are looking forward to your participation!

atcoder is top 8 contributer now!

9th

After many many exams in the school, many many students begin their AtCoder tours again :)

Idk how I passed C after 4 WAs, just did some +/- math. Idea was to move diagonally as much as possible and align the x coordinate or y coordinate with the target node.

Codewhat the fck was C

Idk man, I just figured some +/- math after moving diagonally as much as possible and aligning resultant x or y with target node. After that it was tricky to move in the same direction where I did some guessing.

I felt like leaving the contest .

Is there a simpler solution to G than Small to Large merging? Or did people just manage to implement that approach in like 5 mins @_@

small to large merging is simple ??

It's a classic euler tour + monostack problem.

There are indeed simpler solutions, but small to large merging is also simple enough. It's only about 30 lines and 5 mins or so is enough to implement it (my solution in contest was small to large merging).

Could you roughly explain your approach using small-to-large merging?

can someone please explain the idea behind the 3rd question import math a,b=map(int,input().split()) c,d=map(int,input().split()) t=math.ceil(1.5*abs(b-d))

if t<=abs(a-c) and t!=0: print(int(abs(a-c) -1.5*abs(b-d))//2 + abs(b-d)+1) else: a=abs(b-d) print(a) please explain me why my code is incorrect please

you can try to move the initial and the end points to adjacent ones (where (x + y) mod 2 = 0) such that each one is still in its tile and then draft some examples

thanks

My solution for problem-D is to store last K characters as state. AC

Same here, I used a bitset and converted it using to_ulong

nice mate. I used bits instead of using strings. Submission

this solution is really good.

Great contest. D was a really good problem, wish I would've solved E a bit quicker though. Also, How to do C?

Idea is to move diagonally as much as possible and then align target with the resultant x or y coordinate. Tricky part was to move in the same direction in x. In y its just that difference of y coordinates as height of tiles are 1.

how can we get atcoder contest testcase at which our solution got failed...

Anybody who found C,D tougher than E,F or just me?

Solved ABDEFG. So strange.

And G is the easy version of CF1725E.

Can you explain the complexity of your E solution?

Anyone can give hints on how to solve D?.

My approach to count all the possibilities such there is atleast 1 subarray of K length that is a palindrome and then the subtract that from 2^q and get the answer, but I couldn't calculate it properly(due to overcounting).

bitmask dp

Damn bro!! Pease explain a bit further, what will you store using bitmasking? and time complexity of your solution

in mask I will store values of last $$$K$$$ question marks

$$$O(2^K * N * K)$$$

i think for each index we only need last k-1 elements and check if they are forming palindrome or not

https://atcoder.jp/contests/abc359/submissions/54847829

same thing

thanks

Let $$$dp[i][m]$$$ (for $$$k - 1 \leq i \lt n$$$) represent the number of ways of constructing a good prefix of the first $$$i$$$ characters ending with mask $$$m$$$.

For $$$i = k - 1$$$, this is fairly direct, check all $$$2^k$$$ possible masks and see if they work (are possible and don't contain any palindromes). If they do, set $$$dp[k - 1][m] = 1$$$, otherwise set it to $$$0$$$.

Now notice that the masks for position $$$i$$$ and $$$i - 1$$$ share $$$k - 1$$$ characters. So for any $$$i \geq k$$$, we can check each of the $$$2^k$$$ masks again. If a mask $$$m$$$ is valid, we simply calculate $$$dp[i][m] = dp[i - 1][m'] + dp[i - 1][m' + 1]$$$ where $$$m'$$$ is $$$m$$$ with its highest ($$$(k - 1)$$$-th) bit disabled.

thanks a lot

I think problem B's statement could have been made a lot easier to understand.

My code failed for last three testcases in C.Can someone point out where the mistake lies?

Codeanswer for

should be 3 and not 2.

But -1 is invalid input

"Can anyone explain C, please? I should have at least tried d, as I've spent so much time with C, actually, not so much time but significant time. I'm feeling bad about it now."

D is good.

I used small to large in G. But I can't understand what's wrong in my solution. mp[v][c] contains two numbers: the number of vertices of color

`c`

in`v`

's subtree and the total length of paths to them.CodeUPD: submission

UPD2: I found issue, AC

If C has a million haters I'm one of them. If C has a hundred haters I'm one of them. If C has one hater it's me. If C has zero haters I have died. If the world is against C I am with the world, if the world is for C I am against the world.

D E easier than C

The whole contest was easier

Tbh C was cute problem. I didn't like it either, but it's really simple and solution is pretty concise. I feel like CP turned into mindlessly rewriting same algos over and over, especially on AtCoder ABC. Problems like this humiliate you in a good way.

I was helllbent on solving C, finally did and missed on other problems D,E,...

I don't particularly enjoy writing math casework

I also don't like problems like this one. But since ABC is supposed to be educational, I try to make use of such problems. For example, I've learned the following lessons (in this particular order):

Skip nasty non-standard grid problems whenever it's possible. Especially if there are problems with more points to get.

Try to find out "simple observation" (as they will call it in editorial for sure) before considering shit tons of edge cases.

Test your solution like crazy. After the first WA, write stress test immediately, don't wait for luck.

Solving more and more similar problems make your more resistant and prepared to them.

Competitive programming is 100% pain.

Last point is real

If C has n haters ($$$ 3 \le n $$$) I'm one of them. If C has two haters that's you and me. If C has one hater I have AFOed. If the world is for C, I'm with you.

E was stack and $$$\text{O(N)}$$$ ? (Asking cuz constraints had 2e5)

CodeSo typical problem G. Maybe it will be better to swap some orders of the problem.

Could you guys just STOP making "greedy in grid" problems such as C plz? :(

how can we get atcoder contest testcase at which our solution got failed...

https://www.luogu.com.cn/problem/P7840

this is the original problem of F?

Why ABC usually has an original problem?

My code which get AC in AT also get AC in LG!

But I suppose it wasn't on purpose, as there weren't many easy ideas:(

But I think ABC is a good way to let us find the same problem so that get AC.

so that get AC is wrong in grammar,you should modify it to be "so that you can get AC on the original problem."

Yes,you are right.

This problem is same as F!

C was exactly same as https://mirror.codeforces.com/contest/1421/problem/D. Just consider the right point of tiles (moving between left and right didn't encounter any cost), and those right points forms the hexagon.

It can be solved via linear algebra, no need to go into greedy

Problem F has appeared here previously : https://www.luogu.com.cn/problem/P7840

However, Luogu is a website that currently mainly used in China. So I think it is a coincidence. I only point out for notice.

Here is the translation by Copilot:

The total running time of the server network is given by the expression:

The goal is to minimize this value.

I think so.

I wonder who finds this original problem?

Didn't Atcoder check for if there have been the same problem？？？

This problem from Luogu same as today's G.

And this problem is from the year 2021.

It is a Chinese website and it only support Chinese... It is extremely difficult to check EVERY CP website and search whether there is a same problem. So It can be only coincidence. BTW it didn't cause any significant effect, because it is just an ABC contest.

They do nothing wrong. Try not to be too aggressive.

Is it hard to check weight? Inexplicably! Only a fool thinks so. The questions are exactly the same, and luogu is a great site for brushing up on questions, and the bottom line as a question writer is to not come up with exactly the same questions. Even though the questions are in Chinese, can't you learn Chinese? You can't read Chinese, can you? And ziyistudy is stating facts and you're defending a shit group of question writers. I think you are very wrong.

Translated with www.DeepL.com/Translator (free version)

I don't think the testers can find this problem. It's from China.

However, the impact is not significant, as even Chinese people find it difficult to detect.

find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect. find it easy to detect.

Why inclusive-exclusive algorithm doesn't work in problem D?

I'm stupid... How dare me apply inclusive-exclusive algorithm for n-k elements!!!! I thought n-k<=10....

Top 10 contribution!

I wonder how to prove that greedy algorithm is correct for problem F. Would anyone like to share your ideas? Thanks a lot.

I see some solutions using

Small to Largetechnique, so I'd like to share 5 problems (in increasing order of difficulty) for someone who is not familiar with this topic and want to learn it.Plain Small to LargeSmall to Large + Advanced DPFor problems from BOJ, either use Google Translate or add the problem to Vjudge and use the inbuilt translator option.

In conclusion,

C : https://mirror.codeforces.com/contest/1421/problem/D

D : https://onlinejudge.org/external/16/p1633.pdf

F : https://www.luogu.com.cn/problem/P7840

G : https://www.luogu.com.cn/problem/P4103

what can I say

Can anyone explain Problem G ?