We will hold Toyota Programming Contest 2024#12(AtCoder Beginner Contest 384).
- Contest URL: https://atcoder.jp/contests/abc384
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20241214T2100&p1=248
- Duration: 100 minutes
- Writer: MMNMM, sounansya, physics0523
- Tester: Nyaan, math957963
- Rated range: ~ 1999
- The point values: 100-200-300-400-450-500-575
We are looking forward to your participation!
i am just a chill guy who participates in every atcoder contest
WE GOT MORE UPVOTED COMMENT THAN BLOG BEFORE GTA VI
How to do F :( ?
Anyone, How to do F??
i think we can use trie
WTF MAN 1 TESTCASE WRONG ANSWER ??? Please help
Might be overflow issue, I also faced this 1 test case WA
While checking , you have done (x*a[0]), x can go upto 1e9 and a[0] upto 1e12, this will overflow
Thanks man! Fixed it now.
So disheartening when shit like this happens :(
$$$\mathcal O(n^2)$$$ solution passed problem G lol. 60727006.
Can someone explain why the two pointers method doesn't work for task D?
My code
does it handle the case when needed_value = prefix[i] + suffix[j]?
no. I missed it thanks
you missed the above case indeed, I edited your code and got AC AC code
Did anyone solve F using FFT ??
can someone suggest any testcase for which this code fails?
60750107
Code I change a bit in your code,its gets ac. i am lazy to generate testcase.
Hi all,
Problem :
E
Kindly assists, I was unable to figure out why the code is not passing the
if (s[nx][ny] < now/r)
condition in the first test case. Furthermore, after reviewing the editorial I made changes in theif
condition asif(s[nx][ny] < (now+r-1)/r)
doesn't seems to pass the below test case:Here is the code:
Thanks in advance.
Can anyone explain solution to problem F its a nice problem
Initialize ans to sum of sums without applying function (ans = (n+1)*sum(a)). Then for about the first 27 powers of 2, let p be the current power of 2. Get the sum s of all the sums that are multiple of p. Remove s/p from ans.
This works because for example if a sum s is divisible by 16 but not by 32 you get s-s/2-s/4-s/8-s/16 = s/16.
You'll need a dictionary/map indexed by a[i]%p to keep data about number of elems and their sums for each modulo. You also need to distinguish the case when the modulo of the sum elements that equal 0 (mod p) are equal (like (0,0), (2,2) for p=4) or unequal ((1,3) for p=4) because their contribution is computed differently.
https://atcoder.jp/contests/abc384/submissions/60784930
sorry but i didn't get it can you elaborate on intution and logic
For each sum (s = a[i]+a[j]) you need to add s/p to the answer where p is the largest power of 2 that divides s. This is the problem statement. The idea is to compute s1 the sum of all those s, then s2 the sum of the s divisible by 2, then s4 the sum of the s divisible by 4, s8, s16, s32 and so on for a large enough power of 2.
The answer is s1-s2/2-s4/4-s8/8-s16/16... (26 terms is enough).
Edit: It works because the contribution of say a sum s divisible by 16 but not 32 is going to be s-s/2-s/4-s/8-s/16 = s/16 which is what we need (that s won't appear in terms higher than s16).
How to E??
i think it is BFS
i tried both bfs and dfs it passed 56 cases out of 65
can any one find runtime bug in my code please it helpful for me.. problem E: https://atcoder.jp/contests/abc384/submissions/60778905
I found the data for question D to be weak, for example, in the example below, the answer should be yes, but in some code the answer is no, and AC is obtained
3 7 1 7 2
So in that case, does atcoder rerun the submissions on newly added test cases?
Here's a problem https://atcoder.jp/contests/abc381/submissions/60100542
After the contest, somebody pointed out that people who have submitted brute force got an AC but brute force should have given TLE. So, you see at the bottom after contest test cases added and when submitting any brute force solution, only those fail. I don't if the solutions were re-judged after these test cases.
If this is the case, I think it is possible to add new test cases, but it will not be judged that the answer is wrong for the code submitted at the time of the competition
Why it is failing E problem
ok problems are good and I respect physics0523 a lot as he was my co-ordinator in TheForces round 26.That's why I won't be over expressive but honestly statement writing wasn't good , statements weren't made clear.In problem $$$E$$$ it really wasn't good especially the part of newly adjacent cells, like no where in the statement it was mentioned old adjacent cells persist , I had to understand by reading sample explanation, but why??The main idea of what the problem wants should be in statement not in sample explanation right?
Ok, I just read the samples of E right now after reading your comment cause I normally don't go to samples. That makes the problem so much easier, I thought we lose adjacency to previous adjacent cells. Maybe I don't understand what slime means.
My solution for E is giving WA even though I'm performing BFS with int64 everywhere, and its always the last 2 out of the 65 test cases. my submission:60833551
I wrote a solution using plain BFS, with taking the smallest neighbour and breaking if the smallest neighbour is larger than the criteria. I got WA many times, then read editorial and people's suggestions here and saw that overflow might be happening. I used 128 int type as well, but still getting WA. Is the issue with my logic?
Would be grateful if somebody can help with this one. I am trying to get it AC for the past 1 hr.
Your
set<ppi>
must beset<pair<long long, pair<int, int>>
to store the value.Yeah I have done it with ll itself. Just asking chat gpt to clean code and make it readable, that caused this int issue. My actual submission had
actual solution: https://atcoder.jp/contests/abc384/submissions/60781738
That's strange because I only changed that line in your posted code and got AC. Maybe something else is different from your original code lol.
ohh. if that's the case then i will look into it more. But thanks for taking the effort really.
I got the issue. In my first submission of using double for division and not using any 128 int, I had used
instead of
y<m
Chatgpt fixed it but even after asking it multiple times, it didn't point it out. Thanks for your help really.
Finally easier G.
why rating is not updated?
I had a nice solution for
Problem D
, simply run aloop from 0 to 2n
, taking the sum of array elements and check if theremainder = (s%(totalsum))
occurs in this course, Implementation: https://pastebin.com/nYJd9DEGBecause, we basically wanna see if any combination of elements taken from beginning & from the back sum up to the remainder.
I think we have the same idea but different implementations.
I changed the equation to: some_suffix_sum + whole_array * some_multiple + some_prefix_sum.
Consider the array as [1, 2, 3]:
Case 1: If S = sum(arr), the answer is "Yes."
Case 2: If S < sum(arr), I used a sliding window to find this, as all elements are positive.But this case will also be handled in the case 3.
Case 3: If S > sum(arr), for example, S = 10, then the answer would be [3, 1, 2, 3, 1]. Here, I took some_prefix_sum = 1. Now, our sequence is [1]. We still need 9 to reach S. We can repeat the array to cover this 9. This can be found by calculating 9 / 6 = 1 (where 6 is the total sum of the array). So, the sequence becomes [1, 2, 3, 1].
Now, I still need 10 — 7 = 3. To check if this 3 can be formed as a suffix, we can calculate total_sum — current_remaining.
For example, here, current_remaining = 3, and total_sum = 6. We check if 6 — 3 = 3 matches any prefix of the array. If it does, there is an answer.
my code:https://atcoder.jp/contests/abc384/submissions/60772223
Can anyone share their idea for F
Can anyone explain why this is giving TLE for problem F?
Submission
just change map to unordered_map AC
There's also a funny solution for problem F:
Our goal is to find a sum $$$ T = \sum_{i=1}^N \sum_{j=i}^N \frac{A_i + A_j}{2^{k_{ij}}} $$$, where $$$ k_{ij} $$$ is largest s.t. $$$ 2^{k_{ij}} $$$ divides $$$ A_i + A_j $$$.
Let's firstly calculate sum $$$S = \sum_{i=1}^N \sum_{j=i}^N \sum_{t=0}^{k_{ij}} \frac{A_i + A_j}{2^{t}} $$$ (can be done in $$$O(n \ log(C))$$$, where $$$ C = 2 * max(A_1, ..., A_N)$$$).
Now, let's fix pair $$$(i,j)$$$. It's occurence into $$$S$$$ would be:
$$$ \sum_{t=0}^{k_{ij}} \frac{A_i + A_j}{2^{t}} = (A_i + A_j) * ( \sum_{t=0}^{k_{ij}} 2^{-t} ) = (A_i + A_j) * (\frac{\sum_{t=0}^{k_{ij}} 2^{t} }{2^{k_{ij}}} ) = (A_i + A_j) * ( \frac{2^{k_{ij}+1} - 1}{2^{k_{ij}}} ) = (A_i + A_j) * ( 2 - \frac{1}{2^{k_{ij}}} ) $$$.
Thus, $$$S = \sum_{i=1}^N \sum_{j=i}^N \sum_{t=0}^{k_{ij}} \frac{A_i + A_j}{2^{t}} = \sum_{i=1}^N \sum_{j=i}^N (A_i + A_j) * ( 2 - \frac{1}{2^{k_{ij}}} ) = ( \sum_{i=1}^N \sum_{j=i}^N 2 * (A_i + A_j) ) - T = 2 * ( \sum_{i=1}^N A_i * (N + 1) ) - T $$$.
Thus, $$$ T = 2 * ( \sum_{i=1}^N A_i * (N + 1) ) - S $$$. Total complexity — $$$O(n \ log(C))$$$. My solution: 60808479.
Can anyone help me please, my solution for E is giving wrong even though I'm performing BFS with int64 everywhere, and its always the last 2 out of the 65 test cases 60833551