### IgorI's blog

By IgorI, history, 5 months ago, translation,

Hello Codeforces!

Now the winter SIS (Summer Informatics School) is taking place, and parallel A+A0 and its teachers have prepared a complete Codeforces Round. You can check previous rounds, prepared by SIS students: Codeforces Round #612, Codeforces Round #530.

Codeforces Round #694 begins on 05.01.2021 17:35 (Московское время). In both redactions, there will be $6$ problems for $2$ hours. The round is rated for both divisions.

Problems are authored and prepared by AliceG, Pakhomovee, MadProgrammer, ArtNext, fastmath, IgorI, Kapt, KhB, Hello_zoka, Karabutsa, Arbuzniy_kekich, Mangooste, pelmenner, Allvik06 under the guidance of meshanya, cdkrot, kokokostya, kraborak, scanhex.

We would like to thank:

We recommend you to read the statements of all problems. Scoring will be announced later.

Good luck!

Scoring distribution is: $500 - 750 - 1000 - 1500 - 2000 - 2500$ in both divisions.

Editorial

System testing is over. Thank you for participating! We hope that you liked our problems!

Congratulations to the winners:

All of them have solved problem E (with neal being the first). Problem F was quite challenging and no one have solved it during the contest.

• +529

 » 5 months ago, # |   +40 Div.1 + Div.2 in the title is confusing, cuz it means combined round
•  » » 5 months ago, # ^ | ← Rev. 6 →   -66 :(
•  » » » 5 months ago, # ^ | ← Rev. 2 →   +29 del
•  » » 5 months ago, # ^ |   0 hello
 » 5 months ago, # |   +60 I like blue! lol
•  » » 5 months ago, # ^ |   +86 MadProgrammer is the impostor .lol
•  » » » 5 months ago, # ^ |   +15 Among us jokes are too last year bro..
•  » » » » 5 months ago, # ^ |   0 Meow thought it would be a good joke so i did it
•  » » 5 months ago, # ^ |   +14 ..Making us confused !! Nope, I can check all and make the scenario fool
•  » » » 5 months ago, # ^ |   +13 more formally : Brute force on the writers :D to check if he's blue or not
 » 5 months ago, # | ← Rev. 2 →   +43 AliceG Топ!
 » 5 months ago, # |   +31 Really like the blue color theme for this winter round!
•  » » 5 months ago, # ^ |   +94 coders from the southern hemisphere :)
 » 5 months ago, # |   +151 winter SIS (Summer Informatics School) Hmmmm, there's something off here
 » 5 months ago, # |   +32 Thank you for another blue round!
 » 5 months ago, # |   +1 At first sight I thought there is a bug ,later realised it's "magic" lol
 » 5 months ago, # | ← Rev. 5 →   -8 Thank you IgorI for preparing div.2 contest.
 » 5 months ago, # |   +3 I am missing monogon.
•  » » 5 months ago, # ^ |   0
•  » » » 5 months ago, # ^ |   0 I mean the name Monogon will be missed and I know his new id.
 » 5 months ago, # |   -10 BLUE
•  » » 5 months ago, # ^ |   -11 BLUE
 » 5 months ago, # | ← Rev. 3 →   +89 Should we change our handle blue in order to participate this contest?
•  » » 5 months ago, # ^ |   +9 Actually a great Idea !
•  » » 5 months ago, # ^ | ← Rev. 2 →   +50 I cannot guarantee that your color will not remain blue forever
•  » » 5 months ago, # ^ |   +73 Nevermind, you will be blue after this round!
•  » » » 5 months ago, # ^ |   0 Hope so
•  » » » 5 months ago, # ^ |   0 I like Blue
 » 5 months ago, # |   +13 Masters of the blue , of course meow will participate .
 » 5 months ago, # |   +34 As a tester, 1-gon commented nothing!!!
•  » » 5 months ago, # ^ |   +4 new year resolution
 » 5 months ago, # |   +41 BLUEFORCES :D
 » 5 months ago, # | ← Rev. 2 →   +253 Meanwhile in the standings..
 » 5 months ago, # |   -74 DIV 3 PROBLEM C VIDEO TUTORIAL LINK https://www.youtube.com/watch?v=7FFzXk-brRU I have tried my best to give you guys proper intuition of this dp problem. Hope you guys will enjoy this video !!!
 » 5 months ago, # |   +98 18 "blue" authors and 1 real blue author, press F
•  » » 5 months ago, # ^ |   +12 1 IMPOSTER AMONG US
 » 5 months ago, # |   +380
•  » » 5 months ago, # ^ |   +72 Some of us didn't author tasks, but helped with problem & the round preparation
 » 5 months ago, # |   +34 It would be fun if testers were blue too.
•  » » 5 months ago, # ^ |   +31 As a tester it's probably first time I feel nice about being Blue. Thanks to auth-orz.
 » 5 months ago, # |   +6 Battle of Blue author
 » 5 months ago, # | ← Rev. 3 →   -10 LOL !! It would be more interesting if Testers would also be Blue !! Would be a nice Combinations.. Participants should also need to change blue for participating LOL !!!
»
5 months ago, # |
-93

cf 693 1st question please help me , on what test case my code fails because I think that my code is right Its humble request thanks in advance

# include <bits/stdc++.h>

using namespace std;

long long count(int n){ long long c=0; while(n%2==0){ n=n/2; c++; } return c; }

int main() {

int t;
cin >> t;
while (t-- > 0)
{
int w, h;
long long n;
cin >> w >> h >> n;

string s = "";

if (n == 1)
{
s = "YES";
//continue;
}
else if (w % 2 == 1 && h % 2 == 1)
{
s = "NO";
//continue;
}
else if ((w % 2 == 0 && h % 2 == 1))
{

long long x1 = 2*(count(w));
if (x1 >= n)
{
s = "YES";
}
else
{
s = "NO";
}
//continue;
}
else if ((w % 2 == 1 && h % 2 == 0))
{
long long x2 = 2*(count(h));
if (x2 >= n)
{
s = "YES";
}
else
{
s = "NO";
}
//continue;
}
else
{   long long a1=2*(count(w));
long long a2=2*(count(h));

if (a1*a2 >= n)
{
s = "YES";
}
else
{
s = "NO";
}
//continue;
}
cout << s << endl;
}

return 0;

}

•  » » 5 months ago, # ^ | ← Rev. 2 →   +20 wrong place to ask!
 » 5 months ago, # |   +3 colourful standings
 » 5 months ago, # | ← Rev. 2 →   -9 Hope to be blue color ^^
 » 5 months ago, # |   +38 Is this BLUEFORCES ?
 » 5 months ago, # | ← Rev. 2 →   +11 Really like this 'Authors in Blue' theme!!
 » 5 months ago, # |   +23 much Expertise went into the problems' preparation
 » 5 months ago, # |   +5 I literally freaked out on opening the contest page and seeing this blue brigade in there XD.
 » 5 months ago, # |   0 The face when I saw all the authors are blue.....
 » 5 months ago, # |   +10 I'm glad all the cyans turned blue this year :D
 » 5 months ago, # |   +35 Are you blue so that you can get girlfriend?
 » 5 months ago, # |   +1 What a coordination among problem setters, All blue looking nyc
 » 5 months ago, # |   0 how do I cancel my registration from this contest? Does that really matters??
•  » » 5 months ago, # ^ |   +4 If you do not participate in the contest, it doesn't matter.
 » 5 months ago, # |   +3 Last night I participated in a competition prepared by newbie, and tonight I will participate in a competition where the people who prepare the questions are all export. It is an interesting experience. ^__^
 » 5 months ago, # |   0 Seeing from a literary sense-blue colors all over the announcement symbolize the amount of tears testers and authors have shed while testing and creating the contest, so let us all do our job and participate to appreciate their hard work.
 » 5 months ago, # |   0 Blue , Blue & Blue. This is a bluish round.
 » 5 months ago, # | ← Rev. 2 →   -25 It's not funny in the second time
 » 5 months ago, # |   0 I hope this round will make me the color I am now,but I'm more likely to turn blue...
 » 5 months ago, # |   +8 Hope you guys do your best.
 » 5 months ago, # |   0 Authors are playing "among us".
•  » » 5 months ago, # ^ |   0 And MadProgrammer is the impostor.
 » 5 months ago, # |   -29 As a LGM i love to attend this contest
 » 5 months ago, # |   0 I wish to become blue after this contest!
 » 5 months ago, # |   0 pog
 » 5 months ago, # | ← Rev. 2 →   0 Can we expect a magenta round next year?
 » 5 months ago, # |   +2 Once in a Blue moon contest
 » 5 months ago, # |   +62 i wnt psitive contribution please
•  » » 5 months ago, # ^ |   -13 Then make contribution not begging
 » 5 months ago, # |   0 why all the writers of this round have changed their id colour to blue? too much symmetry and why blue?
•  » » 5 months ago, # ^ |   +3 It's just a continuing joke https://codeforces.com/blog/entry/72809
 » 5 months ago, # |   -38 The comment is hidden because of too negative feedback, click here to view it
 » 5 months ago, # |   +17 Roses are red, Violets are blue.
 » 5 months ago, # |   +3 Well, that looks like new year's BLUE squad
 » 5 months ago, # |   0 Glad to see a blue brigade as problems co-ordinator. Hope to learn something new after this round. :P :))
 » 5 months ago, # |   -6 Last contest I did really terrible so I cheated from my friend to not lose too much rating (I would never gain positive rating change from cheating ) Now I feel really terrible I never cheated before that was just very stupid and I'll never do that again even if I'm going to lose 200 I prefer to stay clean like how I always have been
•  » » 5 months ago, # ^ |   +6 Glad to see u accepted your mistakes.
•  » » 5 months ago, # ^ |   +5 I have not cheated in Codeforces but I guess you feel guilty and undeserving of the rating. Also codeforces is not a school exam, there is no obligation to participate, so cheating seems purposeless. Do well this round!
•  » » 5 months ago, # ^ |   -21 MikeMirzayanov, ban him please
•  » » 5 months ago, # ^ |   +5 you dont need to make public proclamations like this, just do not cheat.
 » 5 months ago, # |   +24
 » 5 months ago, # |   +29 Please update the scoring distribution??? Less than 1hr is left!!!
 » 5 months ago, # |   0 Ready
 » 5 months ago, # |   0 I hope everybody does well this round. I want to turn blue.
 » 5 months ago, # |   +29 Auto comment: topic has been updated by IgorI (previous revision, new revision, compare).
 » 5 months ago, # |   0 Second Contast of 2021 and oh boy i am excited for this one....Good Luck everyone and Bad Luck to the cheaters who try to ruin everything nice int this world. Codewarriorsssssssssssssss
 » 5 months ago, # | ← Rev. 2 →   0 The fact that only one of the 19 writers is actually blue! smh
 » 5 months ago, # |   +12 A bit Queue in the submission
•  » » 5 months ago, # ^ |   0 yes, here also
 » 5 months ago, # |   0 Such a long queue :(
 » 5 months ago, # | ← Rev. 6 →   0 It appears that I didn't register (I forgot to) to contest and can't submit, but the UI apparently forgets to tell me that is the case...P.S. It's ok now
 » 5 months ago, # |   +23 Strange contest!
 » 5 months ago, # |   +5 is there any problem in server because submission taking time
•  » » 5 months ago, # ^ |   +4 Judging is taking around 5 mins.
 » 5 months ago, # |   -20 Long queue
 » 5 months ago, # |   +29 Has to be new record for difficulty gap between C and D in Div2.
 » 5 months ago, # |   -77 the queue is 30 pages long. It's time for an unrated contest. :))
 » 5 months ago, # | ← Rev. 2 →   -49 I think the long queue is because of the weak sample test.
 » 5 months ago, # |   -145 Queue is too long. The round should be unrated.
 » 5 months ago, # |   +140 lol people are asking to unrate the round just because they perform bad.
 » 5 months ago, # |   -94 Queue way too long. Should be unrated
 » 5 months ago, # |   -71 Its taking too much time for judge....
 » 5 months ago, # |   -26 scrolling through the comments while 3rd problem in queue
 » 5 months ago, # |   +1 Problem C was so easy!!! I should have solve that earlier in this contest! :(
•  » » 5 months ago, # ^ |   +8 This always happens, I debate which one to gamble on and choose the harder one
 » 5 months ago, # |   +2 It would have been really nice if the condition B > 10*C wasn't true. :)
 » 5 months ago, # |   +14 difference between levels of C and D is very much i guess. anyway a good set of problems.thanks for the contest.
 » 5 months ago, # | ← Rev. 2 →   0 Is compilation error supposed to count as a wrong submission????this is my submission log: https://imgur.com/oLZjnCZThis is just my submission compared to someone else's on the leaderboard: https://imgur.com/BJZcjKu (if you look at the third person in the picture, they solved at same time as me, but I got 50 less points).As you can tell, my compilation error cost me -50. Is this supposed to happen?
•  » » 5 months ago, # ^ |   +1 You got -50 because of double "pretest passed", not because of compilation error
•  » » » 5 months ago, # ^ |   0 Is that what is supposed to happen? They're both right, so why is that giving -50
•  » » » » 5 months ago, # ^ |   +1 Because you basically replaced the previous submission which could contain a bug not caught in pretests. So it is the price for replacement.
•  » » » » » 5 months ago, # ^ |   -13 I personally don't think that should be -50 but ok. If it passed pretests but you caught something yourself, that's just a problem of pretests being weak, and therefore not your problem that it passed pretests. Nevertheless, it is whatever I did bad anyways. Thanks for clearing up my confusion
•  » » » » » » 5 months ago, # ^ |   0 After pretest, Codeforces will hold a system test, which will finally decides whether your submission is right or not. The resubmission is the function to avoid FST(Failed System Test), which will cause -50 penalty.
•  » » » » » 5 months ago, # ^ |   0 Does this -50 happen for all cf contests? I just want to know for future reference
•  » » » » » » 5 months ago, # ^ |   0 Yes, as far as I know this is nothing new and is written somewhere in the rules
•  » » » » » » 5 months ago, # ^ |   0 A submission makes the previous AC submission counting like a failed one. This is for all constests, but not in all contests this results in -50 points. For example in educational rounds you get 5 or 10 points penalty.
•  » » 5 months ago, # ^ |   0 You got -50 because of the resubmission
 » 5 months ago, # |   -7 maybe quene is long and maybe it is taking time to judge..but it is not in the position to make this contest unrated !!
 » 5 months ago, # |   0 ** Placeholder for the picture "me after solving ABC" **
 » 5 months ago, # | ← Rev. 3 →   +15 Div2D (Div1B) was amazing!!! The queue was irritating though
•  » » 5 months ago, # ^ |   0 what is the solution/hint, dont we just have to find answer for w=0, 1? what is wrong in that
•  » » » 5 months ago, # ^ |   0 Yes, the answer for all w>=1 will be the same. So you have to look at just 2 cases.
•  » » » » 5 months ago, # ^ |   0 WHat is wrong in this, I stored, for each number, the product of prime factors with odd power taken once in a map. For example, for $4, 12, 3, 6$ we store them as $1, 3, 3, 6$ in map. Now key of $1$ gives already perfect squared, and value of $1$ in map will give single element count which become perfect square in first second. Now odd values in map will remain odd. Even values will get added to perfect squares component
•  » » » » » 5 months ago, # ^ |   +3 You maybe missed ans1=max(ans0,ans1) after calculating the answer for 1. This was the mistake i made and my idea is same as yours
•  » » » » » » 5 months ago, # ^ |   0 actually I mistook the statement of question :-( Each second the following happens: each element ai of the array is replaced by the product of all elements of the array (including itself) For singular elements as 6 is in case of [4,12,3,6] I multiplied it with itself to make it a perfect square after first second (facepalm)
•  » » 5 months ago, # ^ |   0 Can you please elaborate your approach ?
•  » » 5 months ago, # ^ | ← Rev. 2 →   0 HOw to solve B ? seemed easy but the idea did not struck
•  » » 5 months ago, # ^ |   0 How to solve it?
•  » » » 5 months ago, # ^ |   0 Pairs whose parity of powers of prime are same are adjacent
•  » » » » 5 months ago, # ^ | ← Rev. 2 →   0 Okay, thanks.
•  » » 5 months ago, # ^ |   +3 I found it easy and mathy... I solved it by taking square-free part of numbers
•  » » 5 months ago, # ^ | ← Rev. 3 →   0 Could you please tell me why I am getting TLE? Actually I am never sure about how to use unordered_map without losing performance so if you could give me a few tips about that, that would be helpful.Submission: 103458851Variables- equi[x]: the ultimate value of x once all square elements are removed from it. equiCount[x]: a map to count occurrence of x initial: for w = 0, counts the maximum answer for initial setting. after: for w >= 1, counts the maximum answer once different elements are merged
 » 5 months ago, # |   +48 After looking at problem D (Div 2).
 » 5 months ago, # |   0 B was so hard!
•  » » 5 months ago, # ^ |   0 You should analyse the frequence of numbers, then apply math.
 » 5 months ago, # |   0 In Div2D , 2nd test case after 1st second array becomes [36,36,8000,8000,8000,1] .Now why is the answer 3 ?
•  » » 5 months ago, # ^ |   0 {8000,8000,8000} are adjacent to each other :P
•  » » » 5 months ago, # ^ |   0 Are 8000 and 1 not adjacent ? lcm/gcd = 8000/1 = 8000 A Perfect Square
•  » » » » 5 months ago, # ^ |   +18 Nope, 8000 is not a perfect square
•  » » » » » 5 months ago, # ^ |   +8 fuck. literally spent half an hour thinking why the hell is the answer not 4
•  » » » » » » 5 months ago, # ^ |   0 I lost a bit of time there as well — had it been a more obvious non-square-root, time could've been saved. The problem writers didn't (intentionally) give a lot of hints in this round, for any of the problems — most examples were quite basic and it was left for us to figure out the gotchas.
•  » » 5 months ago, # ^ |   0 [8000,8000,8000] — three adjacent elements [1,36,36] — also three
•  » » 5 months ago, # ^ |   0 there are 2 sets- [36, 36, 1] ans [8000, 8000, 8000] maximum size of any set is 3
•  » » 5 months ago, # ^ |   0 8000 = 2^6 * 5^336 = 2^2 * 3^21 = 1 So 8000 is adjacent only to 8000.
 » 5 months ago, # | ← Rev. 2 →   0 How to solve D? I noticed, that the answer will be got either on first or second operation of counting the answer, but after that I got stuck.
•  » » 5 months ago, # ^ |   +5 I was thinking like mapping each element to a number obtained by dividing the largest possible factor as square. Then elements mapped to same element are adjacent, now if the size of group is odd then this group could not be adjacent to any other group in next iterations otherwise such group in next iteration will be merged to other such even number group and group of elements mapped to 1. But not sure as I could not implement it in the time.
•  » » 5 months ago, # ^ |   +10 $a$ is adjancet to $b$ only and only when its power prime divisors have same parity (3 = 2^0 * 3^1, 12 = 2^2 * 3^1 are adjancet).So all you need is factorize every number and count group by parity of prime powers. Then beauty is largest size of group.
•  » » » 5 months ago, # ^ | ← Rev. 2 →   0 So, was it necessary to keep only different prime divisors? And what about the merging of other adjancet groups?UPD. Understood it. Thanks a lot.
•  » » » » 5 months ago, # ^ |   0 Merging will be only for group with even size and once as you posted. Then their product is perfect square. Otherwise group will never be changed.Let's say current group is (3, 12). Their product will be 36 — perfect square. And if group is (3, 12, 27) then their product is 972 = 3^5 * 2^2 (powers have same parity as 3 = 3^1 * 2^0, 12 = 3^1 * 2^2, 27 = 3^3 * 2^0, so it will be in the same group)
•  » » 5 months ago, # ^ | ← Rev. 2 →   0 Represent each number as a product of it's prime factors (but with each power modulo 2).For example: $540 = (2^2)*(3^3)*5$, so it will be represented as $(2^0) * (3^1) * (5^1) = 15.$ Hence each perfect square would be represented by 1.All numbers having the same representation will be adjacent at the $w = 0$ secondAnd at $w = 1$ second only the representation having even counts will actually become perfect squares and thus merge into the representations of 1, and other representations will remain the same. Count the maximum among them
•  » » 5 months ago, # ^ |   +1 *0th or 1st Notice that lcm(x,y)/gcd(x,y) = x * y / gcd(x,y)^2. That means that numbers are adjacent if their product is a square number. If they are square numbers, we don't really care about prime factors that appear even a number of times. So basically, divide numbers into groups, where every number in the group has the same "odd" prime factors. If the group is odd-sized, after the operation its size doesn't change. Otherwise, after the first operation, you can merge two even-numbered groups.
 » 5 months ago, # |   -15 Did anybody face 'Idleness Limit Exceeded' in Div. 2 D for not flushing cout, or was it just me?
•  » » 5 months ago, # ^ |   0 Same when doing practise- -
•  » » 5 months ago, # ^ | ← Rev. 2 →   0 That's pretty weird to me, I got Accepted by changing cin to scanf.[Accepted] Use scanf: code[Idleness limit exceeded on test 3] Use cin with ios::sync_with_stdio(false): code Does anyone know why?I am using int to read long long cause the issue..
•  » » » 5 months ago, # ^ |   0 Yeah, it worked when I changed endl to "\n". Strange.
 » 5 months ago, # |   +17 Div1 C deserved way more points than Div1 D :(
 » 5 months ago, # |   0 How to approach C problem? I didn't understand the samples.
•  » » 5 months ago, # ^ | ← Rev. 5 →   0 Same, I spent a lot of time, thinking what the hell with samples. Idea what we can use another distribution than in samples, like (from the second example) * A present that costs 10 dollars to the first friend. * A present that costs 40 dollars to the second friend. * 10 dollars to the third friend. * 40 dollars to the fourth friend. * 90 dollars to the fifth friend. I solved by two prefix sums (gift prices and sorted costs to pay to friends). And we try to find how many elements with paid friends we can replace with gifted (gifts from start (from cheapest)). Trying to find the edge of the minimum total price. It's kinda difficult to explain. 103452905 Possibly it is not the most obvious solution.
•  » » » 5 months ago, # ^ |   0 Thanks, Dude!
•  » » 5 months ago, # ^ |   0 sort the 1st array in decreasing order ..then iterate every element for every elem i,take min(ith elem,arr[i]th elem)
 » 5 months ago, # |   +3 The difficulty difference between div 2 C and D was way too much :(
•  » » 5 months ago, # ^ |   -11 Nope IN fact I solved D first then A/B/C
•  » » 5 months ago, # ^ |   -11 And I got D but not C :)
 » 5 months ago, # | ← Rev. 3 →   +5 Weak test cases of C 103437395 (should be WA , but AC)103459710 (This is correct)UPD : My mistake sorry :( , but still i m not able to figure out why both are correct
•  » » 5 months ago, # ^ |   0 the gifts are sorted in ascending order so it doesn't matter
•  » » 5 months ago, # ^ |   0 its correct, i mean first link answer is not wrong.
•  » » » 5 months ago, # ^ |   0 No you are wrong :)111 21 1 1 1 2 2 2 2 2 3 3 32 4The first solution gives 28, while the correct answer is 27 which given by the second solution
•  » » » » 5 months ago, # ^ |   0 oh yeah if (j < m && j < a[i]-1) should be there i guess
•  » » » » » 5 months ago, # ^ |   0 I realized after 45 min , and then got -250 points from my current marks :(
•  » » » » 5 months ago, # ^ |   -8 ki should be 1 or 2 only.
•  » » 5 months ago, # ^ |   0 this is the verdict before system tests
•  » » 5 months ago, # ^ |   -8 n = 11 but in your test case you have taken 12 elements.
 » 5 months ago, # |   0 (After Contest) How to solve Div2 C? Silly me couldn't solve it even after an hour of thinking.
 » 5 months ago, # | ← Rev. 2 →   0 In problem D , I thought answer will be same in each query and adjacent property will be transitive .Got WA on test 2 , maybe i missed something .I stored frequency of a[i]/(j*j) if a[i] is divisible by j*j .Maximum frequency will be answer .could someone tell whats wrong in approach or solution
 » 5 months ago, # | ← Rev. 2 →   0 nvm, got it
•  » » 5 months ago, # ^ |   +6 The answer is the same for w = 1 to 1e18.
•  » » 5 months ago, # ^ |   +1 Yep
 » 5 months ago, # |   +8 Div2 D was tough but it is really awesome problem I guess.
•  » » 5 months ago, # ^ |   0 Agree
 » 5 months ago, # | ← Rev. 3 →   0 1) I think Div2D can be solved using Prime Factorization. (Correct me if I am wrong). time complexity will be around O(N*sqrt(Amax)). 2) I think you will get maximum possible answer in second 1. so we have to calculate answer for second 0 and 1.I don't know what I missed but, failed pretest 2.
•  » » 5 months ago, # ^ |   +1 You miscalculated answer for second 1, you include even component size ones as well as ones which are perfect squares already, and also take maximum with odd frequency ones also.
•  » » » 5 months ago, # ^ |   0 I think I messed up calculation for element with value 1.
•  » » 5 months ago, # ^ |   +2 I don't think that complexity passes, I got TLE. Might just be me being an idiot though.
•  » » » 5 months ago, # ^ |   +3 No. I agree with you. I was just brainstorming.
 » 5 months ago, # |   0 The problems were really interesting but I think the problem statement of Div.2 B could have been better. It took me 30 min alone to fully understand the statement correctly.
 » 5 months ago, # |   +44 I passed sample of E in 10 seconds after the match, f**k the long queue!!!
 » 5 months ago, # | ← Rev. 2 →   +3 The problems were nice but the queue was awfully long:(
 » 5 months ago, # |   +141 Oh in problem F I didn't consider the case when two rectangles form a cross, ready to FST, so sad :(But, how could this pass pretests..?
 » 5 months ago, # |   -8 the requirements for the solution for Div1D/Div2F don't have any sense!
 » 5 months ago, # |   0 How to Solve Div2 D?
 » 5 months ago, # | ← Rev. 3 →   +52 Cheaters everywhere!
•  » » 5 months ago, # ^ |   +20 Waiting for the obligatory mass cheating blog.
•  » » 5 months ago, # ^ | ← Rev. 2 →   +1 we dont give a f*ck, why are u posting this? spoils the mood tbh.
•  » » 5 months ago, # ^ |   +20 We know about this chat and all cheaters will be banned
•  » » 5 months ago, # ^ |   0 Lol they blocked me after I told them 2-3 eye-opening lines XD
 » 5 months ago, # |   +15 There was long queue throughout this contest we had to wait for 2 minutes to get to know whether our code passed pretests or not . My last submission although passed pretests but there is negligible chance of it passing the final test because it took 1965ms where maximum time allowed was 2000ms. I think I could have modified it easily if I had got 5 more minutes which got lost due to this queue . The Coordinators should have Increased the time by 15 min to compensate for the long queue. Anyways keeping aside the result This was a great contest. A,B,C were good . D was quite Tricky
 » 5 months ago, # |   +3 Interesting problems!Thanks to everyone who contributed!But testing was weak. :(
 » 5 months ago, # |   0 Hi! Is it possible to hack codes?
 » 5 months ago, # | ← Rev. 2 →   -30 I highly suspect the data of DIV 2 C is wrong, that is, in pretest three, the ci's are not ranked from the smallest to largest. Anyone share the same idea?
•  » » 5 months ago, # ^ |   0 They are in ascending order, please read the question carefully
•  » » » 5 months ago, # ^ |   -21 Yeah they should be, but I doubt in pretest 3 they are not
•  » » » » 5 months ago, # ^ |   0 Hmm...I got all the pretests passed, did your code failed for 3?
•  » » » » » 5 months ago, # ^ |   -25 Yeah, and I compared it with the passed code, and our code are different if and only if the costs are not sorted
•  » » » » » » 5 months ago, # ^ |   +48 Can you show both codes?I will give you 20 euros if what you say is exactly true.
•  » » » » » » » 5 months ago, # ^ |   -6 This is the passed code #include using i64 = long long; using u64 = unsigned long long; using u32 = unsigned; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; std::cin >> t; while (t--) { int n, m; std::cin >> n >> m; std::vector k(n); for (int i = 0; i < n; i++) { std::cin >> k[i]; k[i]--; } std::vector c(m); for (int i = 0; i < m; i++) { std::cin >> c[i]; } std::sort(k.begin(), k.end()); i64 ans = 0; for (int i = n - 1; i >= 0; i--) { ans += c[std::min(k[i], n - 1 - i)]; } std::cout << ans << "\n"; } return 0; } And this is my code #include using namespace std; typedef long long LL; int main(){ int tt; cin >> tt; while(tt --){ int n, m; cin >> n >> m; vector a(n); vector b(m); for (int i = 0; i < n ; i++){ cin >> a[i]; a[i] --; } for (int i = 0; i < m; i ++){ cin >> b[i]; } sort(a.begin(), a.end(), greater()); int curr = 0; LL res = 0; for (int i = 0; i < n ; i ++){ res += min(b[i], b[a[i]]); } cout << res << endl; } } I guess I can't get this 20 euro but I would also be grateful if you could point out my error :)
•  » » » » » » » » 5 months ago, # ^ | ← Rev. 2 →   +10 In the last for loop you are using b[i] which is wrong because i < n
•  » » » » » » » » 5 months ago, # ^ |   +5 vector b(m); //... for (int i = 0; i < n ; i ++){ res += min(b[i], b[a[i]]); } Some out of bounds lies here...
•  » » » » 5 months ago, # ^ |   +81 If you are saying things like "test data is wrong" without even seeing the test, you better have a very good reason. It is far more likely that you did something wrong. Especially since a ton of people have solved it.
•  » » » » » 5 months ago, # ^ |   +11 The kid is wrong btw. I added assert(is_sorted(all(b))); and no RE. BTW, the array b is the array c in the problem. https://codeforces.com/contest/1471/submission/103468499
 » 5 months ago, # | ← Rev. 3 →   +5 In Div2C, Totally missed that the cost array was sorted. Made a segment tree ;_; . (Link 103478099)
•  » » 5 months ago, # ^ |   0 me too, but i knew that since its div2c , theres no way the answer is a segment tree, so i kept reading the question again and again, and sent a question(Answer was "read the problem statment").The statement should have made it more clear, at least in writing.wasted too much time ;(
 » 5 months ago, # |   0 Can anyone explain 1st question?
•  » » 5 months ago, # ^ |   0 B was a bit more complex than C :(
 » 5 months ago, # |   +5 A- pretests passed(3)..... WA on test 4 :))))) and my day is spoiled.
 » 5 months ago, # |   0 ??? why pretest A was too weak so many contestants was hacked
•  » » 5 months ago, # ^ | ← Rev. 3 →   +12 someone probably leaked the wrong solution whoever did that, u have my respect!!!
•  » » » 5 months ago, # ^ |   0 Not really. Many failed due to precision error of floating point ceil func in C++. Seems quite natural to me.
•  » » 5 months ago, # ^ |   +70 Not getting hacked is not a universal human right or something.
•  » » 5 months ago, # ^ |   0 Due to integer over flow my code failed for AI realized after contest finishedI have to change int max_bty,min_bty to long long int max_bty,min_bty Silly mistake But i wonder how integer overflow occurs even constrains says sum of all elements won't exceed 10⁵
•  » » » 5 months ago, # ^ |   0 If you read the question carefully, it says the sum of the values of "n" don't exceed 10^5. It doesn't place any restriction on the values of array itself. It is only on the number of elements in the testcase. Due to this, you can have a testcase which has 10^5 elements, each of which are 10^9 which easily overflows in your case. I hope it clears up things for you.
•  » » » 5 months ago, # ^ |   0 I could solve only B in the contest. Got wrong answers when I submitted A and C. Just tried A and C with replacing int by long long and both got accepted.
 » 5 months ago, # |   0 Thanks for an interesting problem set. Wish there was a little extra time due to problems with the queue.
 » 5 months ago, # |   0 what happen Problem A's TC 4
 » 5 months ago, # |   +12 I learned ceil for integers by a hard way today.
•  » » 5 months ago, # ^ |   0 What is the issue with ceil?
 » 5 months ago, # | ← Rev. 2 →   0 Why is my solution for D still showing pretest passed instead of in queue?
•  » » 5 months ago, # ^ |   0 Because it passed the system tests :)
•  » » » 5 months ago, # ^ |   0 Emmm... I didn't get points for that problem.
•  » » » » 5 months ago, # ^ |   0 wait what.. I guess it didn't even get into the queue for system tests yet.
 » 5 months ago, # |   +3 How can we have all that queue without even increasing the time of the contest?!!!!!!
 » 5 months ago, # |   0 Thought the blue color was the theme of this contest, turns out it s absolutely red! RIP c++ contestants on problemA div2 xDxD
•  » » 5 months ago, # ^ |   0 why what happened?
•  » » » 5 months ago, # ^ |   0 take a look on status! lot of cpp submissions failed system tests on problem A.. mine included xD..I guess it has something to do with the function ceil.
•  » » » » 5 months ago, # ^ |   +63 I think I have never used ceil. Don't use ceil, in fact try to not use floats unless absolutely necessary. You can do most things with integers, for example (p + q - 1) / q calculates $\left \lceil \frac{p}{q} \right \rceil$.
•  » » » » » 5 months ago, # ^ |   +1 coool thankies
•  » » » » » 5 months ago, # ^ |   0 To find the a/b rounded up to the nearest integer, can't we use  if(a%b==0) ans=a/b; else ans=(a/b)+1;  ?
•  » » » » » » 5 months ago, # ^ |   +6 I assume you can use many things to do that.
•  » » » » » » » 5 months ago, # ^ |   0 Oh never mind, I thought my solution failed due to that but the reason was something else.
•  » » » » » » 5 months ago, # ^ |   0 Your conditional statement is the same as (a+1)/b + 1 which also equals the (p+q+1)/q. Not sure if one is faster than the other. I'm generally more scared of overflow, so I use mine ... but I'm not red, so do whatever.
•  » » » » 5 months ago, # ^ |   +2 Pffff.... I always thought that this is one of first things you learn in c++ contests:1) Beware of overflow;2) Beware of UB (overflow is one of case of UB but sometimes it is not and it is too common problem);3) Beware of using floating-point functions where it's not necessary.
•  » » » » » 5 months ago, # ^ |   0 I guess I learned it the hard way... But still I learned it xD
•  » » » » 5 months ago, # ^ | ← Rev. 2 →   0 It's actually because of 1e+10 output format if you don't cast the result to integerQuite annoying.
•  » » 5 months ago, # ^ |   0 Why are you blaming c++?
•  » » 5 months ago, # ^ |   0 BUT WHYYY?????????????????????????System Failed Error.when everything works perfectly!Also, this C++ code uses Ceil and also acceptedhttps://codeforces.com/contest/1471/submission/103394434
•  » » » 5 months ago, # ^ |   0 You failed because you output 1e+10 (see your submission)In passed ceil result was cast to integer type. But I think maybe this is still hackable due to floating point operations. This is rule — never use them :)
•  » » 5 months ago, # ^ |   0 You can typecast it to double and then use 'ceil', eg: b = ceil((double)y/x);
 » 5 months ago, # |   +122 Thanks for strong pretests in B.I used int on w then it passed pretests.
•  » » 5 months ago, # ^ |   +3 I did the same and it failed pretests :o
•  » » » 5 months ago, # ^ |   +10 I think he is talking about div1B.
•  » » » » 5 months ago, # ^ |   +3 I was also talking about div1B lol
 » 5 months ago, # |   +95 I've just realized that div1C is a perfect task to do while(1) when you run out of queries.
 » 5 months ago, # |   +11 Fastforces
 » 5 months ago, # |   +32 My simplest solution to Div.1C :Randomly choose an index and check if its value is not k. When we find such index, break.If value is more than k, keep going left else keep going right till we find k.Is it hackable ?
 » 5 months ago, # | ← Rev. 3 →   -58 Why you guys did weak pretests to Div.1 D, not funny
•  » » 5 months ago, # ^ | ← Rev. 2 →   -60 Also thank you for very stong pretests on problem C, now I will lose all my rating, worst prepared contest ever
 » 5 months ago, # |   0 VIDEO TUTORIAL FOR DIVISION 2 PROBLEM B AND C Link of problem B :https://www.youtube.com/watch?v=e7N8N1GlSOc Link of problem C : https://www.youtube.com/watch?v=rj1A1N7yVkM HOPE YOU GUYS WILL ENJOY THE VIDEO !!!
 » 5 months ago, # |   +92 When you are about to get +230, but you don't believe your solution on D so you did 100 random iterations of the greedy (just 1 iteration passes) and then it exceeds the time limit in system tests
 » 5 months ago, # |   +106 In div1C when I was stressing the solution of one guy from my room, he had like $\frac{1}{10}$ chance to ask too many queries and it passed o.O
 » 5 months ago, # |   0 Why Problem A of Div 2 throws SYSTEM FAILED ERROR in my and many many other submissions?It's throwing WA in TEST 4. BUT WHY??????
•  » » 5 months ago, # ^ |   0 cout<<(ll)ceil((sum * 1.0) / x)<<" "<
•  » » 5 months ago, # ^ |   +1 Typecast your answer int INT, ceil function returns double, which has a floating point precision of 10 digits, so any number greater than that is represented in exponential form.
 » 5 months ago, # |   +18 Hi, my submission 103400375 didn't enter the main test queue due to some reason. Please check it and rectify MikeMirzayanov. Thanks to the user old_school for pointing this out!
•  » » 5 months ago, # ^ |   +1 Got accepted now. Thanks!
 » 5 months ago, # |   0 Good job!
 » 5 months ago, # |   +15 Thanks for LOTS OF STRONG pretests.The Problem. C，we can only read 2 integers，and there are only 6 pretests? for(int i=1;i<=501;++i)ask(1); if(n<=980){ static int b[10066]; for(int i=1;i<=n;++i)b[i]=ask(i); for(int i=1;i<=n;++i)if(b[i]==k&&b[(i==1?n:i-1)]
•  » » 5 months ago, # ^ |   -12 Not that strong pretests are good for hacking, but just 6 weak pretests went too far
•  » » 5 months ago, # ^ |   0 Queue would have been very long if there were more pretest. Could have made round unrated. It was prefect amount of pretests for maximum participation. But the pretests in itself could have been stronger. Like adding test cases could have solved this problem.
•  » » 5 months ago, # ^ |   -22 No way, 6 weak pretests is just too bad
 » 5 months ago, # |   +90 why systest on E so slow :(
•  » » 5 months ago, # ^ |   +21 Wrote 41 minutes ago and it's still running...
•  » » » 5 months ago, # ^ |   +6 Finally finished
 » 5 months ago, # |   +4 Best of the best)
 » 5 months ago, # |   +10 Got fst for 2 problems... I think today's pretests are kind of weak.
 » 5 months ago, # |   0 Since I got WA on problem A, do anyone know a fast way to write ceil(ll a/ll b) on large integers?
•  » » 5 months ago, # ^ | ← Rev. 2 →   +1 a / b + !!(a % b); a / b — round downa % b — remainder!!(a % b) — cast a % b to bool (0 if a % b == 0, 1 otherwise)So full expression is $\lfloor a / b \rfloor + (1 \ if\ a\ mod\ b \neq 0, 0\ otherwise) = \lceil a / b \rceil$
•  » » 5 months ago, # ^ |   +37 Use (a + b - 1) / b instead of ceil function
•  » » 5 months ago, # ^ |   +1 ceil(a/b)=floor((a+b-1)/b)
•  » » » 5 months ago, # ^ |   0 Don't forget to typecast (long long) in front of floor function. I learned it the hard way.
•  » » » » 5 months ago, # ^ |   0 There is no need to typecast as it is a simple division without using function floor.
•  » » » » » 5 months ago, # ^ | ← Rev. 2 →   0 But you have written a floor in your formula. I was replying to that. I know that it can be done with simple division. I got FST in Q1 because I wrote floor unnecessarily. That's why I pointed out. Nothing much!
•  » » 5 months ago, # ^ |   +1 (long long)ceil((double)a / b)
 » 5 months ago, # |   0 Bleed Blue!
 » 5 months ago, # |   0 I feel like I am higher in the rankings than I should be, even though I had 3 failed submissions on problem D. Is there a reason for this?
 » 5 months ago, # |   +33 I feel sad for what happened to rainboy
•  » » 5 months ago, # ^ |   +8 He is not alone)
 » 5 months ago, # |   0 Darn I got 2 TLEs on Div 2C before I used the input optimization (ios_base...). Even my O(N) solution failed because of that. They really just had to make it N=3*10^5.
•  » » 5 months ago, # ^ |   +6 My O(nlogn) solution works without optimizations)
•  » » » 5 months ago, # ^ |   0 Idk what I did wrong then. Here's my submission that was O(NlogN): https://codeforces.com/contest/1471/submission/103439026
•  » » » » 5 months ago, # ^ |   +1
•  » » » » » 5 months ago, # ^ |   0 Thank you.
 » 5 months ago, # |   0 I spent a few minutes debugging div2e and solved it after the game. But I couldn't finish it in the game, even though my idea was right. What a sad story. .
 » 5 months ago, # |   0 1471A - Странный массив 103405431 103466071 I used a simple (int) to convert a fraction to integer. How I even got an negetive value ? Is it fault of server ? cause removing (int) gives correct ans and int is virtually just converting or typecasting fraction to integer.wrong answer 13th numbers differ — expected: '3333333334', found: '-961633962'This should not be there . Please correct me if I am wrong. [user:300iq][user:IgorI]
•  » » 5 months ago, # ^ |   0 I think you have overflow
•  » » » 5 months ago, # ^ |   0 here: mi = (int)(mi/x)+1;
•  » » » » 5 months ago, # ^ |   0 I don't thing that is the case since ma is also int .... and values are almost equal plus many people used int when declaring the variable .I suspect system's fault.
 » 5 months ago, # |   +134 To not keep you waiting, the ratings updated preliminarily. In a few hours, I will remove cheaters and update the ratings again!
•  » » 5 months ago, # ^ |   -6 Thanks MikeMirzayanov !
 » 5 months ago, # |   0 Damn! Never knew using float instead of double could be this costly. In problem A, my code (103399047) failed test case 4 (wrong answer 9th numbers differ — expected: '11', found: '10'). I thought long long divisions could be handled by float. Does the same happen with anyone else ?
•  » » 5 months ago, # ^ |   +13 In general, it's better to avoid using float or double when it's not necessary. It's way safer to just make your own simple ceildiv function.
•  » » 5 months ago, # ^ |   0 float is type which store at most 9 decimal digit precisely. So not all 64bit numbers could be hold.And yes, in status you can see that you are way not alone
•  » » 5 months ago, # ^ |   +5 always do (a+b-1)/b for the ceil of a/b
 » 5 months ago, # |   +27 I found problem F very unclear. Is like the first condition contradicts the third: All passages between two houses will be closed, if there are no teachers in both of them. it means that if an edge doesn't have both vertices with a teacher, the edge is closed?but the third condition says: does it means that the open edges are the ones with at least one teacher? Was the intention that open edges are the ones with at least one teacher in one of its vertices?
•  » » 5 months ago, # ^ |   0 open edges are the ones with exactly one teacher in one of its vertices. I agree though, it was unclear for me as well. Had to read 4-5 times.
•  » » 5 months ago, # ^ |   +7 yeah the statement could have been worded better.took me a lot of time to understand what they meant.
•  » » 5 months ago, # ^ |   +10 I asked for clarification of the third condition, then I get: Read the problem statement the explanation for the first condition without any word about the third, even not say "it explanation for what." No comments So I can only get what it means when I successfully guess what it means.
 » 5 months ago, # | ← Rev. 2 →   -38 it was a bad contest.
•  » » 5 months ago, # ^ |   +1 It was good learning
 » 5 months ago, # |   0 In Div1B , I am getting WA on TC 44 , but its working on online and local compiler correctly. Can someone please help me with what is the error. Thanks!
•  » » 5 months ago, # ^ |   0 w can overflow int
•  » » » 5 months ago, # ^ |   0 my int is defined as long long , so that isn't the reason I think
•  » » » » 5 months ago, # ^ |   +9  for(auto &x : m) { if(x.ff==1) continue; if(x.ss%2==0) { m[1]+=x.ss; v.pb(x.ff); } } Too bad idea change container white iterating over it with range-based loop.
•  » » » » » 5 months ago, # ^ |   0 Thank you so much , but can you tell me why this happens ?
•  » » » » » » 5 months ago, # ^ | ← Rev. 2 →   +8 You there have unordered map.What happens when inserts new element (index access can do this)? There is checking if there is need of rehashing (map size is gonna be greater than $m.max\_load\_factor() * m.bucket\_count()$ ). If rehashing is needed then all buckets are cleared hence all iterators are invalidated now.So in your cycle body $x$ is reference to value lies under iterator which is currently not valid anymore. And before next iteration there is try to increment invalid iterator which implies UB.Why it is only WA#44? Because UB is almost never predicted;) But maybe at most small tests there was perfect square in test data and there is no invalidation and with others rehashing is no needed.