We will hold UNIQUE VISION Programming Contest 2022 Summer (AtCoder Beginner Contest 268).
- Contest URL: https://atcoder.jp/contests/abc268
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20220910T2100&p1=248
- Duration: 100 minutes
- Number of Tasks: 8
- Writer: m_99, leaf1415
- Tester: kyopro_friends, math957963
- Rated range: ~ 1999
The point values will be 100-200-300-400-500-500-600-600.
We are looking forward to your participation!
$$$>3$$$ literally took my $$$5-6$$$ submissions :(
Ended up with some cringe implementation :(
I didn't understand the meaning of problem E all the time !
Problem E can be solved with heuristics.
Let f(x) be the sum of frustrations after x rotations, we can notice that f(x) is non-increasing till some point, and non-decreasing after that point.
I did ternary search which passed all except 2 tests, and added some randomization, which got AC.
Here is my ugly code: https://atcoder.jp/contests/abc268/submissions/34747256
I think F was easier than E.
Exactly True.I can solve the F after getting a glance,however,I can not think of an excellent solution to E at all!!!
That problems where basically all like "avoid off-by-one-errors, then you'll be fine", which felt even for abc a little one dimensional.
There I go...
how to solve c?
Count the no of happy persons if we rotate the array by $$$k$$$. Take the maximum over all values of $$$k$$$.
for dish $$$i$$$:
$$$id[i]$$$ denotes the index of dish $$$i$$$ in the array.
AC Code
how you came up with this great intuition?
Firstly, I tried fixing a dish (say $$$i$$$) for a particular person so that person $$$i$$$ became happy! thereafter I got the logic to count the no of happy persons who become happy if I rotate the array by $$$k$$$.
Can someone tell me what is wrong in my submission for D?
Looks, like my code is not finding solution in some cases, but not sure how it is possible as I am doing all perms + all combination of dashes after it.
Shouldn't the "under" string start being empty? it seems to me you're only considering two underscores and more...
Thanks a lot! I would debug it for a long time :)
How to solve F?
Let $$$x$$$ be the number of 'X' characters in a string and $$$d$$$ be the sum of the digit characters in a string. Then sort in order of decreasing $$$x / d$$$ and compute the answer.
Interesting. Thank you! How do we prove such a claim?
I saw it by considering when it’s advantageous to swap adjacent elements and arrived at the above comparator. I recommend this resource for practicing exchange argument style problems: https://codeforces.me/blog/entry/63533
I proved this with exchange arguments.
Consider two strings that are adjacent in s, let them be $$$s_1$$$ and $$$s_2$$$.
Let the number of
X
in $$$s_1$$$ be $$$d_1$$$, sum of digits in $$$s_1$$$ be $$$x_1$$$. Let the number ofX
in $$$s_2$$$ be $$$d_2$$$, sum of digits in $$$s_2$$$ be $$$x_2$$$.The change in the score when you swap $$$s_1$$$ and $$$s_2$$$ in s will be $$$d_2 x_1 - d_1 x_2$$$.
If this change is positive, we swap $$$s_1$$$ and $$$s_2$$$.
So sort in order of decreasing $$$x/d$$$.
Let there be two strings with index $$$i,j$$$.So lets say placing $$$i$$$ before $$$j$$$ gives us a better answer than placing $$$j$$$ before $$$i$$$ so it means that $$$xi{*}dj$$$ $$$>=$$$ $$$xj{*}di$$$ $$$=>$$$ $$$xi{/}di$$$ $$$>=$$$ $$$xj{/}dj$$$ as $$$x$$$ and $$$d$$$ are non-negative. Therefore placing $$$i$$$ before $$$j$$$ gives a better answer iff $$$xi{/}di$$$ $$$>=$$$ $$$xj{/}dj$$$. We can extend this idea and just sort the strings in order of decreasing $$$x/d$$$ and compute the answer.
Can someone tell me what is wrong with my submission for D?
submission link
Sort the String vector, otherwise next permutation may miss initial lexicographically smaller strings than the first string.
Same as your code, only with sort at line 179
Got it! Thank you so much