Attention! Attention! Attention! Don't miss this opportunity!
Codeforces Round 961 (Div. 2) will be held on Jul/23/2024 17:35 (Moscow time)!
Problems for this round were prepared by a team of Neapolis University Pafos (yes, you've seen its logo in Educational Round announcements) students: Vitaly503, goncharovmike, ikrpprppp.
You will be given 5 problems some of which will be divided into two subtasks and 2 hours to solve them.
Important disclaimer! Some problems of this round were also used in CPFED x JetBrains Training Camp 2024. NUP Contest in Kazakhstan this June. If you've participated in this camp or seen the problems from there, please do not participate in this round.
We would like to thank:
Akulyat for coordinating the round and frequent pinging;
pashka for valuable discussions and the idea of one of the problems;
MikeMirzayanov for the all-powerful Codeforces and Polygon platforms;
Our testers denk, artem3605, physics0523, BurnedChicken, oursaco, AdityaTakkar, shade34, md_nihal, Vamperox, Binary_Thinker, Dominater069, -2.71, Yugandhar_Master, Banis, dazlersan1, MaxLevitsky, larush, aufannn, thenymphsofdelphi, turmax, ishaandas1, vahtang, GrandFruit, okwedook, Vladithur;
Participants of the onsite version of this contest in Kazakhstan who also made this round better: AmirMakaM, kaztayev, MnTm, shenfe1, mispertion20, dondurma, N29, Relice, k1ngash, Alihan_8, Otalp, Tima19, kanye_east, adiyer, BallBreaker, I_Love_Diar_Narumov, Tangirkul, Issa, fft97, Aiperiii, Bichpaket, Baytoro, kylych03, Wansur, Chalishkan;
And participants of the Codeforces Round 961 (Div. 2) (i.e. you)!
Not-so-important not-so-disclaimer. If you're interested in getting a Bachelor's degree in computer science in the indefinite future, you might want to take a look at Computer Science and Artificial Intelligence program in our university administered by JetBrains.
UPD. Scoring distribution: $$$500 + (1000+500) + 1750 + 2250 + (2500 + 1500)$$$
UPD2. Congratulations to the winners:
Div 2:
Div 1 + Div 2:
UPD3. Editorial.
Hope I get positive delta ;(
As a tester, I wish good luck to participants!
Thanks!
nice cat
We got catman before GTA 6
As a tester, I will be missing the chance to participate in this amazing contest(( I hope everyone enjoys the problem set.
Amazing Contest how????????????
As a tester again, I tested today.
What happened with wxbqwq ? Why he became an unrated perticipant?
As a tester , The problems are worth solving !
As a Participant, I would be able to confirm this fact after contest:)
Stop lying
As a tester, I wish good luck to every participant!
can a newbie solve first two problems???
Bro first 3 questions are mostly about intuition and logic.
and the other three??
lmao
you've already done 10 contests, you should know
hopefully I'll Solve First two problems
Hopefully :)!!
and I solved First two Problems ....
As a tester, I hope you perform well this round. Good luck!
.
As a tester, contest is amazing
What is the point of using existing problems?
Problems are only used for a specific small group of people who can be considered as testers.Also this contest is not publicly available
As a participant, i shall wake up on time
u awake ?
thanks
As a tester, the problems were really nice 👍
Thank you
cat
♡♡♡
As a tester
ChatGPT solved 0 problems in this contest too.
Chatgpt solved B1 and I just copied and pasted it. Why do you lie?
well i guess, we found a legendary
cheaterprompterBesides that finding such things doesn’t help you and is a waste of time and effort, I also just copied and pasted the problem statement. So, nothing is legendary but a weak and liar tester
I am sorry if that comment offended you(it was just a joke). But if you used ChatGPT during the contest for B1 , i think you are at loss(if not, Awesome!!). Apart from that i wish you good luck on your journey to CM. All the best!!
It’s fine . It’s not important what i did. The important is to put more effort in preparing contests and testing and to come up with original problems in order to avoid problems that generative AIs can simply solve. Thank you and good luck to you too.
As a tester, this is my first contest as a tester, I wish luck for participants!
As a participant, please give me positive delta!
score distribution?
As a participant ikrpprppp 's hair is majestic!
As a tester, I feel problems are interesting and worth solving. I wish good luck to all the participants.
As not a tester, I hope I get +3 delta
Quick update, I got my +3 delta and became expert
as not a tester hoping to get color change today
Me too.
all the best hope u reach CM today
Hope you can reach pupil!Good luck:)
;)
congrats :D
thanks :)
Maybe I'll take a step back to take a longer leap in div 3.
Very excited for this round!
As a tester again, I tested few days ago, hope you find this round interesting:)
Hoping to become specialist in this round:)
It's interesting to see a cat studying for a CS degree.
Какая разбалловка?
orz
pic goes hard
Scoring distribution when??
As a tester, I tested the round!
All the best, problem is nice which I solved.
As a normal user, i wish i can be CM
well, i changed my color after this contest
As an *out of competition participant, I want to AK a Div. 2 round for the first time.
scoring distribution when?
cute cat
What are the score distributions?
As a tester, I invited to test after the end of previous round.
same
Downvotes on the tester's comment? I don't recognize codeforces.
potato
Score distribution??
Is cat an official problem setter?
Interesting scoring distributuion
Indeed it is 5 problems.=)
Please give some easy and good questions :)
Doubt solved :) Thanks for the help
Two Problems with some slight modification, Second one will be tougher than the first one
Thanks for your answer :-)
how can one have idea about the rating of problem from the score ? any idea
Well if you have given the contest.
Now you know, We don't have one XD
There are two subtasks for the given problem. If it is marked as (a+b), a points for the easier variation, and b additional points if you solve the harder variation.
Thanks for the reply :)
excited!!
Is he a tester?
Hoping to become Pupil this round. I feel like today is the day.
It can be today grandma
Catforces incoming
So will this contest be rated?
Subtasks for Div.2 B? Let's see...
Worst DIV 2
Sentence is not clear :(
I am sorry but the statement of problem D is so badly written.
They could have just said that you need to cut the string into substrings with <=k length instead of all that word bs...
I disagree, transforming the statement is also a part of the problem solving process, however the problem could have been worded much more nicely...
Rare occurrence when I lost any remaining will to solve problems in a contest
See you again never
bad B2!
wth is B2
Problem D is just a copycat of this problem: https://acmp.ru/index.asp?main=task&id_task=884
Simply copy pasted my old code and got AC in 10 mins, dislike for testers.
https://codeforces.net/contest/1883/problem/E
Problem C is on codeforces too lol
They're way different! That div3 E problem is much more easier
In C if $$$a_i$$$ is turned into $$$\text{log}$$$ $$$a_i$$$, it's the same problem as 1883E - Look Back.
I applied the same algo, but for me it is giving WA on TC 5. 272165398. Can anyone tell where my code goes wrong?
It overflows. The worst case scenario is that you multiply by 2 every time which clearly overflow.
That's probably why I thought that I've seen the problem somewhere else during the contest.
Please don't FST, please don't FST
why even make problem like C?
slowing down use of double for TL really make problem little bit fancy?
Questions B2 and C are a hot mess, but I’m crossing my fingers for a positive delta.
MathForces
I don't think, D was mathforces. I couldn't solve it though.
These are some beautiful problems <3 I especially loved D and E
Can you please explain D ? ( since there isn't editorial yet. )
What I tried...
Last letter must be taken.
If there is a letter, that repeats 'k' times consecutively, that letter also MUST BE TAKEN.
Then on the remaining letters, I applied binary search. ( if we can do string split with
k
letters, then we can surely do withk+1
letters )But doing this binary search and bitmasking got me TLE on 8th pretest.
Come back to expert soon.
Is D somehow using bitsets over dp? Did not get any idea!
Brute force all bitmasks of letters, if I had 1 more minute I would've AC.
Can you please explain
I have yet to verify the veracity of my solution. Let's say you select some subset of letters to be the cases, let's call them "allowed" letters. Now to verify if that selection is valid, we can iterate over the string and if the current character is "allowed", we can just continue, but if it's not "allowed", it's distance to the next allowed letter must be less than $$$k$$$. The time complexity of this is $$$O(2^{c} \cdot n)$$$. This is too slow, so we have to optimize this by precalculation. We can precalculate for each letter in each mask the maximum distance to the next "allowed" letter.
My idea is that each character has a set of masks, each mask represnting some set of characters after the character in some index by distance of k. Now when we brute force some mask we have to make sure that all characters in the mask don't have any mask that doesn't have common bits with the mask. To make sure of that we make dp sos for each character and then we just have to make sure that no sumbask of the complement of the mask is there in this char sorry im just explaining in a bad way
let d[i] = 2^(s[i] — 'A').(index from 1 to n)
For each subarray whose length is k in d,
let v = sum or of all elements in that subarray.
We will have V = {v(1), v(2),..,v(n-k+1)}. (all sum or of each subarray)
We will try all bitmask of letters. The value mask is satisfied if
min(mask & v(1), mask & v(2),.., mask & v(n — k + 1)) > 0
mask & d[n] > 0
So we can use dp sos to find the answer in O(2^n.n)
I have implemented same... but I guess that will give TLE. You can also remove one letter from this bitmask, ( last letter, which must be taken ) . May be the way I implemented could be slow.
LOL
RESOLVED
Nah, man... I don't know how to feel about it. I solved B2 still 6000 in the standing XD.
and C is ####
How did you solve it?
Maps. I stored no of occurences as Value and Just use the same code as used for B1
Used a similar approach but still got WA in B2.
I looked at your code and now I get it, it was quite stupid of me to not solve that problem.
You could have submitted the B1 first with a less-optimized solution as it has a higher score.
True, I tried to solve both of them together. And with how low the points was for B2. After solving I should have just moved to C sed :(
I think B2 has a binary search solution (just turn B1's brute force into binary search)
I solved both using maps. I hope they pass System Tests
272157143 here check my solution does that using simple linear traversal
Yes it has one. Its a little nasty but I like it. Spent one hour during contest on it, but implementation had so many tricky "details" that I kept hacking my code with a half hearted belief instead of giving actual thought to it.
Solution is as follows. Basically we want to spend as much as money as possible because each spent coin = 1 extra petal in the bouquet. So, we can say our goal is to maximize the cost function.
We will use binary search to find out maximal achievable cost supposing that we have chosen flowers of $$$k$$$ and $$$(k-1)$$$ petals. Let $$$cost(a,b)$$$ be the cost function where $$$a$$$ is the number of $$$k$$$-flowers chosen (k-petals one) and $$$b$$$ is the number of $$$(k-1)-$$$ flowers.
Then, we have $$$cost(a,b) = a\cdot k + b \cdot (k-1) = (a + b) \cdot k - b$$$
We notice that $$$k$$$ is a constant and the function is monotonic in $$$(a+b)$$$,i.e, the "sum". The "sum" lies in the range $$$[0, cnt(k) + cnt(k-1)]$$$.
However, the issue is to satisfy constraint $$$cost(a,b) <= m$$$. Here, we use nasty math tricks.
For a chosen midval of sum $$$(a+b)$$$ in Binary search, we don't know what a or b actually is. But, $$$cost(a,b) <= m$$$ gives us that $$$b >= sum \cdot k - m$$$. That is to say $$$b_{min} = sum \cdot k - m$$$ is known and required to respect the constraint.
What's left now is to find maximum value of $$$cost(a,b)$$$ given that $$$sum = (a + b)$$$ has be chosen and $$$b$$$ should be atleast $$$b_min$$$. We, can do this greedily/mathily. The term $$$((a+b) * k)$$$ is already fixed at this point. Only the second term $$$(-b)$$$ is variable. We want to keep it as small as we can while still respecting $$$b_{min}$$$ criteria and also ensure a valid $$$(a+b)$$$ pair is actually possible for whatever $$$b$$$ we choose.
So, we have the key: $$$a_{actual} = sum - b_{actual}$$$. AND $$$b_{actual} >= b_{min}$$$.
Set $$$b_{actual} = b_{min}$$$ and check if corresponding $$$a_{actual} \in [0,cnt(k)]$$$. If yes, hurray.
If not, then it must be because the found $$$a_{actual} > cnt(k)$$$.
What is the next best thing we can do ? Keep $$$a_{actual}$$$ as big as we can or $$$b_{actual}$$$ small.
So, now set $$$a_{actual} = cnt(k)$$$ and $$$b_{actual} = sum - a_{actual}$$$. This is the best we can do.
Now, recheck the following two conditions one last time $$$a_{actual} \in [0, cnt(k)]$$$ AND $$$b_{actual} \in [b_{min}, cnt(k-1)]$$$.
If both, conditions are valid then are $$$sum$$$ is valid. And we can do the Binary search thingy.
If sum is not valid we claim that this $$$(a+b)$$$ pair just doesn't cannot exist (think about it we have checked both boundary conditions already and it failed for both).
Not so pretty code, only look at the
bins()
function: 272214802only solved 2 and very slow, there goes my rating. Sad
math skill issue, have to git gud next time
IS B1 is of Dynamic programming and if yes how 9k people manage to solve dp question ......leaving garden of green back to concrete layer of grey
I used binary search with prefixes.
it was sliding window
It's not DP, just brute force.
I solve it using sliding window + Sorting
no, it's not. linear algorithm
Not sure if you can do it with dp, but you can brute force it. So that explains the 9k submissions.
It was actually a two pointer task. It does have similiarities to knapsack dp, but the constraints are too strict for that.
worst contest last time
D was an amazing problem
My idea for problem D came from here: 1767E - Algebra Flash. Fortunately, I remembered it just in time
found out the bug for c was that i put < instead of <= when there were 5 seconds left of the contest
If the contest had 5 more minutes, I might have solved problem D. What a pity!
Similar Approach for B2 anyone?
update : Got AC. I was missing an edge case when n = 1. 272176756
horrible to read
sneed
B2 with 500 pts is just not worthy doing... To many cases make it not beautiful.(in my algo) And C is mostly a Elementary mathematics prob.
Agreed, I wasted 30 minutes on it and what I got was ~250 points.
score distribution in codeforces is always a joke
True Very True
Cause of it didn't get much time for C (Well that's just my skill issue)
literally the worst, worst problems I've ever seen
please don't ever make contest again.
so true
Can someone please tell difference in fmin() and min() , almost was knocked out by B2 pretest 3
Literally finished B2 2 mins after contest is over. Figured out that we only need to look at previous flower only after a long time :(
Can someone Please tell me where did I go wrong for problem B1, I am unable to find the case or understand what did i do wrong in my implementation, Thank you
Submission : 272170306
Update: Initialized the answer to max initially which was wrong
can someone please tell me what am I missing? what is wrong with my following submission?
https://codeforces.net/contest/1995/submission/272169593
to problem B1 (https://codeforces.net/contest/1995/problem/B1) I could only pass my pretest 1 and wrong answer after that.
thank you
I couldn't understand your solution completely, but I think you are simply returning the maximum value in the array in case there are no consecutive numbers, this is wrong since this maximum number also has to be <= m. I don't think you are checking for this, even after correcting this mistake your logic might not work since the solution seems to be wrong.
I don't like math :(
Is there something else in C apart from prev*(log(arr[i-1])/log(arr[i])? gave me a tle
include <bits/stdc++.h>
using namespace std; typedef long long ll;
bool cp(double a, ll x, double b, ll y) { double log_a = log(a); double log_b = log(b); double left = x * log_a; double right = y * log_b;
} int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr);
}
Can someone explain the squaring problem?
Is C combinatorial? Like counting unique values of difference where an inversions exist then the answer will be m*(m+1)/2?
Bruh what XD It's not
Guessing problems don't work no more :(
Has anyone tried simulated annealing in E?
I read A wrong... Sat there for a while trying to understand it before moving to B1... Turns out I should have started with C... Which was by far much easier to understand. Unfortunately. I sat around and did nothing most of this contest.
why wxbqwq is banned
It seems that it's your alt account.
@MikeMirzayanov Don’t think that because you are an administrator, you can slander people, and don’t think that you can’t do it so you can slander others. You have no evidence! ! ! You don't even have a reasonable excuse that one person can only have one account. Codeforces means that the administrator has the highest power. If you think wxbqwq is weak, you can deduct points from him, or even ban his account. However, the eyes of the masses are sharp! ! ! !
If you ban him, you will let all codeforces users around the world know that Codeforces administrators are corrupt! ! !
Codeforces will be infamous! ! ! ! !
show show way
Didn't enjoy this contest at all. Problems B1 and B2 took all my time. It's easy to see that an O(n log n) solution exists but I didn't succeed in implementing it.
For problem D.Why my solution written by Python TLE10 ?my code
my humble request to problem setters , plz add the definition of diagonal in first problem, take me a long time that we have to consider diagonals in one direction only
well they have mentioned (i+j) thing.
Although it would be good if we had a figure
but brother, do you think the value of (i+j) is the same in the other types of diagonals? think.
The definition provided in the problem is perfect.
A diagonal is the set of cells for which the value i + j is the same
That's literally the definition. I know maybe you mean something like
top-right to bottom-left diagonals
but if you take a long time to figure out it's one direction only then it's your problem tbh...I don't think they should be redefining existing terms because there's potential to make it confusing. If you say diagonals consider it both ways else use some other term.
B was pretty bad imho. Why did B2 have so less points? It was much harder than B1
is there any chance of points getting increased. Has it ever happened before??
how to solve D?
I have this idea about question D,but I'm not sure about its correctness:
The original problem has become a duplicate overwrite problem based on the "ok" array in the code, which we can solve with Dancing Links.
any optimizations for this submission , i m getting TLE
submission 272171232
Shouldn't B2 have more points than B1?? 500 for B2 and 1000 for B1. It might be very less incentive for people who invested their time in coming up with general solution for B2 than just doing easy way in B1
that means B2 values 1500 points.
But coming up with an efficient algorithm was just 33.33% rewarding while brute force is 66.66% rewarding. I mean, at least 50-50 distribution makes sense.
Also, the max score of not just one but both B1 and B2 decreases with time while someone is implementing for B2.
anyone, how to solve b1 ?
You could use a sliding window. Suppose when the right bound is $$$i$$$ we can choose any left bound within range $$$[j,i]$$$. Then we only need to ensure that
Also we should maximize the number, therefore just update $$$j$$$ for each $$$i$$$ and choose $$$j$$$ as left bound.
Same idea, and i managed to implement it :)
After thinking more carefully, I was dumb to resubmit B1 as I thought it was wrong. My rank was downed like 700 after doing that.
anyone approach for B2?
You need to check lone flower types and two flower types with petals of form $$$(a, a+1)$$$. Let $$$x = a$$$, $$$y = a + 1$$$ and $$$c_1 = count(x)$$$, $$$c_2 = count(y)$$$.
Then you need max value of $$$ax + by$$$ such that $$$ax + by \leq m, x \leq c_1, y \leq c_2$$$. With some math, you can do this in $$$O(1)$$$.
If $$$ac_1 + bc_2 \leq m$$$ then answer is simply $$$ac_1 + bc_2$$$.
Otherwise, we must subtract as many $$$x$$$ as we can from $$$m$$$. Then in remaining $$$m$$$, subtract as many $$$y$$$ as we can. Now we see if we can convert from $$$x$$$ to $$$y$$$ to get closer to the answer. Since $$$y = x + 1$$$, we need to figure out how much $$$1$$$'s we can add to reach the remaining $$$m$$$.
thank you!
read this bansalarpan4
bro , i m stuck on B1 , can someone help what is wrong with this submission , i m getting TLE 272174109
man same logic is used here
Yeah exactly, still I m getting TLE Thats the problem
no,im mean an logic for this ax+by≤m is done in O(1) where you used a Linear Time Approach thats the reason for TLE or Please refer Shayaan's Video for this,he also used similar approach as you did for ax+by≤m some what a logN approach.
I think the problems are nice!
please unrate this round
why?
my solution to problem C which clearly should be executed in O(nlogn) but receive TLE verdict, it must be the case codeforces server experience severe DDOS attack or similar which slowing down my solution during execution lead TLE.
You have a mistake though: if you return -1 mid-array, you still need to read the remaining numbers to go to the next test case.
Always check your code before blame.
please unrate this round
Your handle is nice :)
please unrate this round
why?
Damn. I tried passing the problem C with simple long double arithmetic after going to log(a_i), and it failed (for numerical precision, I guess) on some test. A tiny modification to use log2 log2 a_i right away -- and the solution passes. Oh well :)
Can you explain why this change fixes your code? I did similar idea and just happened to use log2l but why does using logl not work, shouldn't it all be the same since were just using change of base idea, any base should work no?
Edit: I changed my code to use logl and it worked.
It should be all the same if the precision permits, yes. But if in the log2 case I need to square a number, say, 100 times, it still means that I deal with the numbers like log2(ai)*2^100. If I go to log log though, it just leads to log2(log2(ai)) + 100. So I have much much less numerical precision bs.
That makes sense thanks, guess it was just lucky that I got it AC even with logl. Probably should have tried to do it without doubles anyway.
Can you explain why log10l(log10l(x)) does not work but logl(logl(x)) works? Also, shouldn't 2^100 overflow?
log10l(log10l(x)): https://codeforces.net/contest/1995/submission/272196817
logl(logl(x)):https://codeforces.net/contest/1995/submission/272196697
What? I tried log2(log2(a)) and it didn’t work :(
I got WA with log first, then AC with log2. And after contest I tried again with log and EPS, that also worked.
You can take a look at my submissions.
I got WA with log2(log2(a_i)) in CPP — 17. After Contest I submitted same code in CPP — 20 and It passed.
thank you for giving me such a special experience of eating s**t.
Thanks to this hack, 272142115 , dozens of cheater failed system test! Even caught an expert cheater NavneetKumar123 =)
How can you say he is a cheater
He failed system test like any other guys who added a non-sense
1<<13
in their codes. So why they added this into their codes? Because they just copy paste the delibrately leaked code without thinking. Even they convert it into other languages using ChatGPT, ChatGPT won't erase the1<<13
:DFor problem B, I used sorting + sliding window and from the discussion it seems to be the correct approach but I got WA.
Submission link
Screencast with commentary
speedran A B1 and spent the whole contest trying to fix my implementation for B2 just to get 150 points :(
I think it could have had a higher score, considering that it's more difficult than A and B
Strange score distribution... B1 shoule be 500 and B2 deserves 1000.
My Submission for C (In PyPy) : https://codeforces.net/contest/1995/submission/272154355 It seems to be working fine on first 5 tests but seems to be giving RUN_TIME error on 6th test case (Logic seems fine to me since it passed first 5 test cases)
Can someone help ?
you get "OverflowError: int too large to convert to float" for this test case:
basically your numbers are getting too big
Hello.
this was my first contest , I got one question accepted still am unrated how ?? can somebody help
Wait
best round for me!
Very humorous round.
I spend almost 1 hour to solve B2 but failed, then I came to C hoping to solve it. But I got WA on #5 because of precision. I thought that my solution is wrong so I continued work on it to find another solution but failed.
Also, I've heard that some participants discussing about the duplicated problems. So I think this is a very humorous round.
Hope that I won't participate in the round like this and this round will unrated.
Yes I did not like this round either and I only solved A and B1 after submitting WA on C. But this does not justify the round to be unrated sometimes you have to take a hit. And the fact that others realized a problem looks same as some other problem comes to their practice which is also a pivotal factor when it comes to performing well in contests.
No Bangladeshi given contest today :(
Because the net connection was off from the government office
Down with all brutal leaders all over the world
Thanks for the round. I finally became blue. C was kinda cool
Guys, pls release the editorial!!
My post contest discussion stream for AB1B2C
Can anyone have a look at this solution for B. Fails test case — 3
}
is this one b1 or b2? I can try fixing it if u want
it is for B1 thanks for checking out!
ok, i will do it in 10 minutes when I return home. Hope it's ok for u
I got it bro, thanks though!
}
good job, feel a little sorry for being a bit late =)
B2 is a piece of shit!C<<B2
I think B2 is too hard on it's greedy :(
eager to see editorials
Can someone tell me how to hack a solution?
Good div2! This is my first time to solve 4 problems without tutorial! Although 2 was after system testing :)
My approach for problem C.
Let $$$c_i$$$ be the number of actions for $$$i$$$-th element. Then we want to make the following condition to hold:
Initially we have $$$c_1 = 0$$$. We look at each pair of indices $$$(i, i + 1)$$$ for every $$$i = 1, 2, \dots, n - 1$$$ sequentially, and determine the minimum $$$c_{i+1}$$$.
For the $$$i$$$-th pair $$$(i, i + 1)$$$, the inequality we need to satisfy is:
We can manually handle the cases where $$$a_i = 1$$$ or $$$a_{i+1} = 1$$$ individually. So let's assume $$$a_i > 1$$$ and $$$a_{i + 1} > 1$$$. If we take log of the above inequality expression:
If we again take log of base 2:
Because $$$c_{i+1}$$$ is a non-negative integer and we want to get minimum $$$c_{i+1}$$$, we get:
which is directly computable.
I was worried about precision but seems like this works fine.
I had the same approach as well :)
I had same solution. I was surprised it passed, because if $$$\frac{\ln a_i}{\ln a_{i+1}} = 2^x$$$ and it gets calculated slightly too large, then it might be rounded up.
Not sure if there is a hack that can break this solution.
I was curious about this and tried to bruteforce all the combinations of $$$a, b$$$ ($$$1 \le a, b \le 10^6$$$) where $$$\displaystyle \frac{\ln a}{\ln b}$$$ is an integer and
ceil(log(a) / log(b))
produces a wrong result. Actually there are some bad cases, but none of them are a power of 2.(Note: I used Python to find these results. Also, in my solution, it's possible to replace $$$\ln$$$ with log with other base, like $$$\log_2$$$, and if you do so, you'll have a different set of bad cases.)
So I was just lucky that I didn't get caught, and I actually should have subtracted an epsilon before applying the ceil function.
can you find error in my code. I had done the same thing but changed this log2(log(a[i-1])/log(a[i])) with log2(log(a[i-1))-log2(log(a[i])).
272229285
My guess (without reading your code) is that log2(a) — log2(b) was incorrectly rounded up due to precision.
For B1, my code in contest got WA but when i resubmitted the same code after contest, it got AC.
I cannot understand why it is happening and have made a post about it.
Please clear my doubts.
Blog link
Edit -> Understood my mistake, please ignore the above comment
can anyone help me please debug why am i getting wrong ans on pretest 4 102nd test case i have provided my code what am i doing is checking for element less than 1 if present and element greater than 1 if present and doing calculations. please help anyone!!! Thank you.
The definition of a diagonal in problem $$$\text{A}$$$ is incorrect.
How?
Problem C I solved using dp.
static PrintWriter out = new PrintWriter(System.out); static FastReader s = new FastReader();
rainboy orz
Can someone help me with debugging this submission: https://codeforces.net/contest/1995/submission/272209517
The failing testcase is giving correct answer locally.
Check if a[i-1]==1 then 0 operations for a[i] else if a[i-1]!=1 and a[i]=1 then return -1
Otherwise continue calculating with that formula
for example see
int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr);
}
Thanks for your inputs. Actually the code was correct. It was missing in floating points. Changed to C++20 (GCC 13-64) from C++17 (GCC 7-32), it worked.
Refer https://codeforces.net/contest/1995/submission/272213609 and https://codeforces.net/contest/1995/submission/272213321
can someone help me why iam getting WA in test 1951 ? mu sub: 272212018
Your code is fails on this case:
SOSdp.....
problems were good..
why does the below code TLE for D?
Seems like B1's tests were too weak against naive quadratic approaches and simple mistakes...
Not only did I hack various $$$\mathcal{O}(n^2)$$$ solutions in 4 different ways (not counting an
unordered_map
hack), but also this hack was meant to be against TLs but it's just causing so many runtime errors within a short time, even a day after the contest.I have also noticed that problems B1 and B2 were certainly harder than normally for Div2 rounds. Also, problem C is very specific. Actually, for me problem D looks easier than both B2 and C.
the cat look sooo cute
Ques 1995B1 was easily solvable with the help of chatgpt's initial suggested code with some minute changes used the same code for solving the problem and its an open source for coders to consult, so it not a violation of rules
Hello I have recently attended contest div 2 hosted by you. However this is first time my solution has been flagged for B2. I did not share my code with anyone during the contest, nor did I use any public or shared platforms. My development process was entirely local, and I have always adhered to the contest rules. I have written my code using sublime text editor. I have attached screenshots of my previous approach which i was thinking. I would like to request you to see that approach and the approach that i have submitted you will see a lot of similarity in code and will get to know my thinking process on how i approached the solution
My First approach Part 1 -: https://drive.google.com/file/d/1kdNOj823bkaOoTDYQgNWV0Q9wKVVbJMg/view?usp=sharing
Part 2 -: https://drive.google.com/file/d/1zo6zaNNjXbYbRB7AiIzzbdQLoXevoaUA/view?usp=sharing
My Second Approach https://drive.google.com/file/d/1zjdolNAiufLnNPz7NDy-Y1MPEgQ8ss_f/view?usp=sharing
And then eventually i figure out the way on how to remove x — 1 petal flower cost value to buy more x petal flower and then i posted the solution
My only mistake was to use ChatGpt to rephrase the solution as i used a lot of if/else statement and was running short of time
Please consider my solution
I am being accused of cheating for no reason at all in this contest, what happened with problem B is that i had a time limit exceed on my first submission , i tried to ask chatgpt for ideas to make it faster and more optimal to the time limit , and i dont know how and since when chatgpt is considered cheating, what i got as a notification is that i copied someone else solution, but i think what happened is we both used the same tool.
**Solutions and test generators can only use source code completely written by you, with the following two exceptions:
1 — the code was written and published/distributed before the start of the round.
2 — the code is generated using tools that were written and published/distributed before the start of the round.** this is what the rules stated , the tool i used were written and published before the start of the round, i hope if you guys can change the rules if thats considered cheating (using chatgpt), and i hope my solutions get unskipped because i was following the rules and i have no intentions of cheating in comp programming or doing such things.
this is the response due to unintentail leakage of my code. here the explaination: The maxPetals function leverages a popular algorithmic technique often seen in competitive programming: the sliding window approach combined with sorting. This method is effective for problems that require finding the longest or largest subarray meeting specific constraints, like maximizing the number of petals without exceeding a given cost. The function sorts the array first, making it easier to manage constraints such as the difference between the largest and smallest values in the current window. By incrementally building and adjusting this subarray, the function ensures it remains valid, a strategy that's both efficient and straightforward.
This approach is familiar to many competitive programmers because it is frequently taught in textbooks, online courses, and tutorials. The sliding window technique is a well-known solution for a variety of optimization problems, and its efficiency makes it a go-to method.
Sorry I have use Chat GTP to clear TLE and summited same code. I summited it and many people would have done same so i apologies for this and promises not to do it again.
"Hello sir[user:MikeMirzayanov], since nobody is addressing my petition to check on my submmited codes nor answering why i got flagged as a cheater, i will then send this message and hope you can answer me. Sorry for the inconvenients but i am really mad about this situation.
Problem B1;
Since it is the same exact problem without any twists i just used my already AC solution, it is not my fault that the problemsetters did not want to place any kind of twist to the problem nor i care, if the problem was that and i did not copy it from anybody in the contest i am 100% sure that can't be counted as cheating, so please remove the skipped flag since this makes me look like a shady contestant, but i have never cheated in any CF nor any contest in my life... Thanks to the best site ever, CodeForces, From Kiavash
Hey, sorry but pls check my submitsion for 1995C - Squaring. I didn't share my code or post it on any websites but I received talk that say my code coincident with khoaa659 :<
btw sorry if bad english
Why my bro? Don't cheat :(.