**UPD** note that the score distribution has changed

**UPD2:** LHiC found a bug in the author solution of div1-F. We are working on the situation.

**UPD3:** we found a correct solution for div1-F and both submissions made during the contest pass all the tests against the correct solution. The round remains rated.

Hi, everybody,

Codeforces round 488 for both divisions will take place on Jun/16/2018 19:35 (Moscow time). The round will be 2.5 hours long (which is 30 minutes longer than usual).

The contest is created by NEAR and its friends. NEAR is working on teaching machines to compete in programming competitions. Read our blog post to learn more about the state of the art in the program synthesis today, our vision, and how you can help us bring this vision to reality.

The contest will feature 6 problems for each division, with 4 problems shared across them.

The problems for the contest are from the test rounds hosted on a system JavaBlitz last year. If you participated in any of the JavaBlitz rounds, you shall not participate in this round.

The score distribution in the first division is 500-1000-1000-1500-2250-3000

In the second -- 500-1000-1500-2000-2000-2500

The round is rated for both divisions.

All problems are initially created by myself, Alexander "ItsNear" Skidanov, and by Nikita "neckbosov" Bosov. David "pieguy" Stolp, Alexander "AlexFetisov" Fetisko, Marcelo "MarX" Fornet, Nikolay "KAN" Kalinin and Mikhail "cerealguy" Kever helped tremendously ensuring the high quality of the problems.

As a closing note, we are constantly looking for people to help us label competitive programming data for research. Read more here.

Congratulations to winners!

Div. 1:

Div. 2:

The editorial is published here. Thanks for your participation!

Where is this:"Thanks to MikeMirzayanov for the platform"? :)

In Codeforces Round #485 the authors didn't include that line. We saw what happened:D

P.S. I stoled the joke from C137.

itsNear, please fix it before it's too late.

Actually he thanked no one

Not felling good about it :D

Which one is true ??!!

Probably 2.5 hours.

The announcement is correct, the Contests page will be updated soon.

Thanks for fast correction :)

Wtf,Who the hell is this Near??He oesn't have even a cf handle??

UPD:ITsNear :P

The successor of L :P

Probably envious because he succeeded against Kira and you didn´t, right? xD

L knew all the way that he should die to defeat Kira. He finally did.

So fast problem distribution :)

You wish you so fast during contest :)

Round in feast

The round coincides with Peru-denmark match

Although it's not a very important match but please set the upcoming contests time in such a way that it doesn't coincide with other games

sorry for poor English:)

Nobody cares about Peru-Denmark match ;)

Really true

Come on, man. I may be the only active coder on Codeforces rocking the Danish flag but did you know it is the oldest flag in the world? Give the country some credit!

(I am not mad about the contest time fyi, I got work taking up my schedule anyway)

Wanna watch this match ? Stop coding and start watching :) no one's gonna disturb you I think :)

Hope you spot the references :)

what is this codeforces arena in this video? :) https://www.youtube.com/watch?v=icoAK6yMCjg

Not released yet?

NEAR is the name of an anime.

Who is excited for Russia fifa world cup 2018.

downvote if u r can't wait for it

upd:Messi is better Than cr7

Does nobody have a problem with the fact that apparently problems are recycled from JavaBlitz? For me I guess I can't compete in this round as I believe I did JavaBlitz practice rounds (although they were 1 year ago and at this point I don't have idea). But what about people who looked at problems a year ago but didn't compete, and don't quite remember what JavaBlitz even was. Seems like bad habit to me to post contests to Codeforces with problems, that are visible to anybody, and then reuse problems for contest a year later.

But maybe I misunderstand situation and it is not a issue for some reason.

It is a reasonable concern. However the problems were not visible to anybody, we actually tracked all the problem views on JavaBlitz (only logged in users could see the problems), and the total number of people who

sawat least one problem across the two rounds is 19We sent all of them to Mike, I assume they just won't have an option to register.

So the problems are no longer visible on the Internet? What about the people who know them from word of mouth from th 19 who for sure saw them? Particularly those who will ask those directly to tell them what the problems were.

Anyway, practice and fun should be the main reasons so I suppose the issue is kind of mute, but I just couldn't help notice than in CF rounds with "known" problems, there are a lot more accepted submissions, which of course disadvantages those who like me, didn't know the problems in advance.

It's Near for soo long

me to be Expert

Flood of contests Thanks MikeMirzayanov for contests.

to be Expert .. me not you :p

you should thank me for participing

What is the score distribution? and how does it relate to rating?

Those are the maximum scores you can get for each problem (if you solve each in 0:00 time). The score gets decreased as the time goes on, and the final score you get is the sum of the scores of problems you solved (and hacks). It's not directly relevant to your rating, as the rating is affected by your rank in the contest, not the absolute score you got.

not-important

Coderforces round > Peru vs Denmark

result will be ..

Spoiler.. codeforces 1 Vs (you and the match) 0

Wish you all a happy Eid Mubarak from Bangladesh

This contest is nothing but Eid bonus from codeforces for us. :)

Chinese contestants will have to stay up until 3am :(

best of luck for gladiators ..

Brazilians contestants are going to miss half of Brazil vs Switzerland match :(

edit: Actually the Brazil match will be on Sunday. The conflict is in the Peru match

ohh .. no .

i will die

If you had solved one question per comment you post, you would have been LGM by now.

so you

what the joke is ?

Bredor!

Your text to link here...

who will win WORLD CUP ?

you are with ?

i support messi

True that

I think The one who support counter-terrorist will win :P

No its far.

EID MUBARAK. Happy Coding.

6 problems total, 4 shared. So Div 2 C is Div 1 A.

div.1a will be easier than usual i think.

The timing is shifted by 2 hours.

argentina vs iceland going on!!

hopefully have a world cup theme :)

Div.2 D and Div.2 E has the same score. weird

Same thing with Div.1 B and Div.1 C

Maybe their difficulty will be same.

It's same for Div.2 D and Div.2 E, which is Div.1 B and Div.1 C

I feel blind ;_;

ItsNear to the contest start!

Eid Mubarak to all contestants...

Good luck.

CF is working very slow. I'm getting 502 gateway error.

same here :-(

Contest on Eid-Day ^_^

awesome right?

Yeah ^_^

Oh yeah

wtf says in the statement of D, it is impossible to understand

then you should try E, its statement is most ambiguous

I still dont get how D works. Worked a solution based on the explanations. (Though got WA because of weak pretests even though there was 20, but after getting wa, found my mistake)

Anyway still dont know why i did what i did.

Maybe it said, there are random pair of points. Find the common number in the pairs that was given to both of them. If there are more than one common points but those 2 persons can still differentiate those then ans is 0 else -1.

What's the pretest 4 in Div.2 B?

the end is near ..

IMHO, this problems is not about hard interesting ideas, math, algorithms, data structures. It's about clear coding, being very careful, being able to find all cases and being able to test your programm well. It's not bad problems, I just really think it's not codeforces or competitive programming style problems, it should be educational problems for software developers or something.

There was a post a while back about what the best CP sites are, and for me this is why CodeForces is not top. I think this is regularly a problem with CF rounds, just more accentuated in this particular round (at least for Div 2).

Is rate of fall of points for a question reduces? As some contestants got odd number of points which I haven't seen before!

Well, the most boring contest I have ever seen. Left after reading E. Standard ABCE (just coding problems), couldn't understand what D says.

Tfw educational round is more creative than this.

How to solve E ? I think about 2 hours for E :|

Calculate

C_{i}= how many numbers less thanxfrom 1 toi. Now you have to calculate number ofl,rsuch thatC_{r}-C_{l}=kfor eachk. Do it with FFT.well I don't know what is FFT :D I lost about all of my time !

Would a normal fft with just doubles fail due to precision issues?

No

How to solve Div2-D? I didn't even understand it.

Most boring 2.5 hours ever :v

Contest of short consntrains!

How to solve div2 -c ?

what is pretest 4 of div2 C???

Just IF ELSE will DO

First I checked every vertex and the center point of the oblique square, if it is contained in the other square then the answer is YES.

Then I rotated the coordinates axes of 45 degrees ( https://en.wikipedia.org/wiki/Rotation_of_axes ) and did the opposite.

It probably isn't the best way

EDIT: Fuck yes it got accepted

No need to rotate though! Just use a different equation for the rotated square: |x — cx| + |y — cy| <= d/2 where (cx, cy) is the center of the square, and d is the diagonal length.

Yes I know, I couldn't figure the equation. Where did you get it? Because I would have used something with Pythagoras. I don't understand why it works in your way.

Well, just high school math I guess.

Iterate through all integer point in the parallel square, and check if it is in the rotated square (can be done by calculating mahhattan distance to the center of the rotated square).

I tried this and got WA on pretest 10:

Let the square be

ABCD, and we iterate over the pointsPin the other square. CalculateAB×BP,BC×CP,CD×DPandDA×AP;Pis insideABCDiff all of these complex cross products have the same sign, at which point print yes and exit.Swap the squares and do that again. This was all inspired by 29.2 in the PDF in this blog post.

EDIT: Does not work because doesn't account for the case where the squares intersection region does not include any vertices of the squares. Same is true for my other post below :(

Also, calculating the areas of the four triangle formed by a point

Pand the sides ofABCDand comparing this with the area ofABCDshould work.Checking if a point is inside a rectangle/square is a standard problem ( check this https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/ ). Now for all x,y co-ordinates possible from -100 to 100, check if a point lies inside both the squares. If yes, they intersect.

Thanks

My solution:

1) Mark all integer points on the edges of a second square.

2) Iterate through all points inside the first square, check if point is marked.

3) Mark points in the first square and check second square.

step 3 is not required.

Step 3 is the case when the first square is inside the second one. If you omit it, you will get WA 5.

You marked all the points inside second square, so while you iterate through all points inside first square, you'll find points already marked, since first square completely lies inside second square.

Oh sorry, you are right. I marked points on the edges of a square.

In Div-2C You can also use point in polygon algorithm to check whether any point from any square is inside or on the other square.

for all (x, y) iterate from -100 to 100 and see if any point is found in both square.

Complexity O( 200 * 200)

or u can find minX, maxX, minY, maxY and some if else's.

share a hack data for problem C 1 1 1 1 just for the people who are too rigorous

oh no T_T

It is obvious that we should use FFT to solve div1.E, right? I am so regretful that I don't have FFT code...

Maybe karatsuba works too..?

(Although I failed to code it)

Yeah I think so.

How to solve Div2-D? Thank you.

For each pair of each person, we will find out the list of pairs belonging to the other person, that two pairs only have one common number.

The answer will be:

A digit from 1-9: only when all possible sets of 2 pairs have similar common number.

"0":

Bothplayers can determine the number (since they know their own given pairs, while you lack such informations), but there are different digits that could be the answer (which you cannot decipher, since you lack the aforementioned info)."1": Other cases. Technically, at least one player cannot determine the common number.

The determination can be done by brute force. From a player's pair, iterate through all pairs of the other player. That pair won't cause ambiguity when either no pairs from the other player have exactly one common number with it, or every pair that does returns the same number.

Nice explanation. Thanks!

in problem B ,, who else missed that the answer was the maximum number of coins ?

Me. I was using cumulative sum after sorting. Thankfully pretests were good.

was this a rated contest??

yes.

Today my solution for Div1C was hacked. Then I wanted to know if it was hacked because of what type of error (like wrong answer or TLE). To know this I had to make a dummy wrong submission. Doesnt it make sense to also add what type of mistake the hack exploited(Like WA or TLE or maybe RE). Or is there anyway to know it without a dummy submission??

You can see it in "hacks" page.

It can't be TLE because you must have checked the constraints before submitting.

You could have a bug that causes TLE, and sometimes it's hard to accurately analyze how much time a code takes

and can't be WA because you must have implemented your solution before submitting

savage

damn. For problem D, I thought the first condition was "if you can determine that number, print 1" for some reason. rip. How did I get 10 pretest cases?

I had to read the statement 10 times to understand it. For me it was very confusing.

Omg, same as me.. I kept thinking for 40 minutes until I saw it.

Yeah, same. As always, reading turns out to be the hardest part of problem solving... .-.

What's pretest 8 of D?

I tried to solve D by sorting by descending power-requirement, then doing dp, storing amount of computers with exactly one task currently assigned, and total amount of processors in use. If multiple have the same power-requirement, handle them at once. This has time complexity O(N * N * B), where B is maximum amount of processors a task uses. However, this fails to pretest 8.

Edit:

Participant's output

1289043069

Jury's answer

1289043070

Nice, I somehow managed to misunderstand what it means to round up, I rounded (for example) 0.3 to 0 instead of 1. Quick fix and AC :P

The same mistake :(

I've got WA on Pretest 7 in Problem D(Div. 2). Does anyone know the test?

Why the hell there's

Allcondition in Problem B? I lost time implementing without that condition.p_{i}'s are distinctTo make coding easier?

noooo;(, I never read that, god i spent so much time , i did it for that condition and still got wa on C and D;(

stl map

I also didn't read that line and skipped it because C looked more promising. :(

Same here @asgar, didn't even know all pi's were different until i read your statement. Lost 10+ minutes there, plus the drain on every other question after that :'(

Yeah, coding is easier; sort from small to large powers, then iterate over the knights, each time tossing the previous knights' coins into a priority queue.

Without that condition it's much less clean to add things to the priority queue.

When you read Div2B and all the contest you think you need to choose a subset of k killable elements to maximize the sum less than P[i]... and it turns out you ONLY need to choose the k maximum elements under P[i] :( ... What the hell happened to my brain ?! :'(Solved Div2C and didn't solve the easy peasy Div2B ...

I did the same still got WA;(;(

You must have missed something. I'm sure the above approach will get AC.

The contest of invisible corner cases. Bye-bye rating, hello attention.

You know, I made a

lotof incorrect submissions (five, to be precise), and still got my rating increasing from ~1700 to ~1800. A particularly nice thing about CF is that it values correct submissions a lot, even if they are made after many wrong submissions.My point is that you should try hard to solve as many problems as possible, even if you have already made some wrong submissions, and never

evergive up!Me after figuring out why my solution for B fail pretest 9

I've come here to look the same 'why' up. You inspired me to figure it on my own

UPD: Done. Apparently, I've just misread the statement... I's trying to find out the pair instead of the common number (and second thing, I's printing 1 instead of the number). Yep, gotta be more careful

Silly solution of div2A. 39292471

It's okay. Given that it's "long time no see"

That moment when you realize in problem D you should print the correct number instead of 1......

WTF!!!! I didn't realize that until I read this. FML...

This. In addition to realizing 10 minutes before the contest ends that only the shared number had to be uniquely determined, not necessarily the two pairs. T_T

Got 2 WAs because of this xD

I made 2 wrong submissions due to that :(

@Stonefeang xd

How to solve div2-E?

To make an enemy spaceship destroyed, one of our ships must stand at the middle point between them.

Technically, there are 40000 possible positions. But we're not iterating through all of them (It will guarantee a TLE verdict at large tests).

Let's iterate every ship from the left side, then with each ship iterate every ship from the right side (or you can choose the vice-versa order, doesn't matter).

Denote the left ship's y-coordinate as

y_{1}_{i}, the right ship's y-coordinate asy_{2}_{j}, to destroy both of them one friendly ship must stand at the y-coordinate of (y_{1}_{i}+y_{2}_{j}) / 2 (for simplicity, you might consider only caring about the value (y_{1}_{i}+y_{2}_{j})). Add this pair of enemy ships to the list of possible takedown pair if standing at the aforementioned y-coordinate.Keep only the y-coordinates that if standing there,

at least onepair of enemy ships will be destroyed. From this point, you can simply do a quadratic-time-complexity iteration to find out the answer (since the maximum number of valid coordinates cannot exceedsnm).Total time complexity:

O((nm)^{2}).Update: There are times when there exists exactlyoney-coordinate that if standing there, a positive number of enemy ships will be destroyed (technically, every enemy ship from both sides would be destroyed). You can handle this case exclusively — the answer will always ben+m. Thanks AeonHQ for pointing that out (in his reply below). ;)Actually your solution works at least

O(n^{2}*m^{2}), because you iterate 2 times over all pairs of intersections. And moreover, it will fail on test 1 1 1 1Ouch, you were right about the corner case :<

Thanks...

the answer is 2?

Hey,can a knight in problem B kill a knight with the same power? 3 2 1 2 2 2 2 2 This test i test on my friend and he got ac while i got wa,wtf?

what is the correct answer? 2 4 4 or 2 4 6

The powers are distinct...

All power levels are distinct. That means, your test is invalid.

powers are distinct so there can't be two knights with same power

Power of all the knights are distinct....see the input description please

All powers are distinct

Problem B clearly says "Determine if you

canwith certainty deduce the common number, or if youcandetermine with certainty that both participants know the number but you do not", although you actually have to determine thatnumberif you can, not just determine if you can do this.Coordinators and authors, please, I think it's very important to formulate question correctly, what the hell. Never saw this on CF before.

That's one small thing that I think really made me believe I was supposed to print either -1, 0, or 1. Although I can't complain for not carefully reading the output section, the statement definitely could have been clearer.

I actually never read the output section carefully — I have samples for that. That never failed me before.

Yep, I inferred everything from the samples too. They really covered all three possible scenarios (well, according to the misleading problem statement).

This is maybe the hardest thing to do for an author. I know myself how hard it is to avoid words like that. That being said, of course they should try to watch out for that and it is a bad thing.

My advice is to read the output section anyway and not care much about wording like "you want to find this" in the middle of the statement. Authors often describe the story and only at the end they say what they really want.

I understand that it's hard for the author, I know this myself too and I don't have much complains to him. But there is more than one persons who prepare the contest, they should check things like that. And, yeah, for me it's lessons learned.

It's easy to check if there is a max test for example, or to remember to stress test the intended solution with slower ones. It's harder to watch out for things like this in the statement because it's vague.

Don't agree. They have testers and people who just read their problems and check tests\solution stuff. I'm sure some of them misunderstood statement after reading it, some maybe understood it after a while by themselves, some maybe experienced WA trying to solve it, some maybe understood it after reading authors tests. It's just important to not ignore this, but to tell author: "Your statement is unclear fsr". Maybe I'm wrong because I never prepared CF round by myself, but that's how I see it.

Why are you sure about this? There is some small chance to understand the statement in a wrong way and it's perfectly possible (maybe even likely) that ~5 people that test it understood it correctly.

IMHO Div1E is more about having prewritten FFT code rather than good idea

how to solve div2B?

UPD: Got mistake, used set instead of multiset.

My head started to spin after reading Div2D. What was that! :O

I don't like this round.

E is obviously FFT. B + C = 2000 score, E = 2250. If I have templates, I can solve easy ABC, and E, and get good rank. Unfortunately I don't have it so I wasted a lot of time to write by myself.

I don't like,too. I use int to print ans (void write(int x)),so it failed system test 43. It make me have low rating.I think it's unfair.

Why there aren't large ans in pretests?

I do not agree that having templates make problems B and C easy

I wasted time to solve E. It's quite easy to know get an AC with a FFT templates. I want get the AC. Unfortunately I didn't. I should spend my whole time on ABCD, not only on fft.

Div2B is so difficult for Div2B =(

Swapping div2B and div2C might have been better. div2 C was pretty straightforward given that you know basics of axis rotation. Moreover, B was a bit more Data structure or rather STL intensive.

Who else got WA for DIV2 B on testcase 54?

Instead of set I resubmitted using multiset and it got accepted :'( Just difference of "multi" lead to WA.

When you forget to remove % mod from your FFT implementation :/

80% of the submission of div2 C are Wrong answers !?

When you get AC in E with runtime of 1996ms

when you get tle on test 84 in C

I know that feeling same happened with me

but one thing is clear that such a test would be a corner case !!!

One hell of system testing, Seeing such dynamics in system testing after a long time.

For Div2C the maximum area of the square is 200*200 = 40000

You can try all points from the first square and check if a point is on the second square the "YES".

So many Div2 guys with only 2 problems accepted out of 5 with pretests passed. Pretests sucked this round :(.

The weakest pertests ever...

Systests failed for Div2B because I forgot to add the case for k=0. Could have turned Expert today. Life is not going good.

lol me too

What is so magical about test 78 in Div2-E?

I get it now, corner case as usual

Why does this code give WA on pretest 6 for Div2 B? my solution

Editorial link redirects to this blog itself, please update it itsNear

Recursion

without a base case

without a base case

without a base case

The link for the editorial is not working.

http://codeforces.com/blog/entry/60047

Thanks !

How can this solution pass for div2b as I am iterating over all the powers greater than current power, so looks like N^2 to me.

You break the loop if cnt[it->ss] < k and you increment cnt[it->ss] in each iteration, so you make at most k iterations for each knight. The complexity is

O(n*k), but remember thatk <= 10. That's why you got AC :)My solution for Div.1D failed on test #11 because the answer is not rounded up. I don't see the point of not including such a test in the pretests or even in the samples, it's just about the format!

I felt the aim of it was to solve the problem using longs instead of doubles.Anyways it was also unclear to me, I had to ask a clarification.

Could anyone explain more about the solution of Div2B? (I read the editorial, but still can't grasp the underlying algorithm.) My solution gets TLE for test #52.

Now I think I understand the algorithm that the editorial describes. The central idea is to begin with the weakest knight and iteratively add coins the current knight has, to the list if it has more money than the least element of the list and keep at most K-elements. I used priority_queue for the purpose of keeping K elements.

Maybe the problem is that you sorting the knights on the number of coins. The test 52 can be specific for your algorithm, like this:

k = 1, for each of 100000 knights you are looking to the first knight with less power. And you are going from the very beginning. So it's too long.(near 10^10 / 2).

Thank you for your detailed analysis. In the worst case like ones you pointed out, O(N^2) computation is required. I see.

Div. 2 B has all pretests have the knights' power sorted except test 1.

was not interisting 0..

What was the point and use of this line in D div2?

if there is a pair (1,2), there will be no pair (2,1) within the same set

Tasks like div1B are definitely not my thing, but at least I'm happy that there was no stuff like

"Print -2 if you don't know the number and participants don't know the number, but participants will know the number once you tell them that you don't know the number".Hold your horses. This is an actual problem statement:

a- 3^{ - b}- 3^{ - (b + c + 1)}by a GM. Each player only knows his owna,b,cand that their numbers aren't equal.(The task is to determine all possible values of player 1's number.)

I declared two arrays like this in the WA code : int a[n], b[n];//n was taken as input before

And changing it to this I got AC : int a[n], b[k];

I got AC here : 39321053 but WA here(on system test) : 39293460

Can anyone please tell me the reason behind this error...? thanks!

Because you put k = 7 elements in the array b allocated for n = 3 elements.

( 1 ≤ n , m ≤ 10 ) != ( 1 ≤ n ≤ m ≤ 10)

I got WA on test 37 for Div 1 B and its test data looks like this: Input: 4 7 9 2 4 1 2 3 2 7 6 1 5 4 7 5 6 3 1 5 8 1 1 4 Output: -1 but if the first player get (2,3) and the second player (3,6) then they should know the answer while we don't know the answer, so we should output 0?

you must print -1 if, for any of the first participant pairs, there are two o more distinct pairs of the other guy that share the same repeated element, because the first participant would not know which one is the other guy's pair (remember you should check the same condition for the second participant pairs).

Since there were some people with TLE at E, I decided to share with you a method of writing a good FFT (works even for people who don't even know what FFT is):

Open Codeforces

Find a recent contest in which tourist has participated, 485 (Avito for NTT) fits this criterium.

Copy his namespace

Be happy

Let's practice this method from on so that the problems won't get super-ultra-mega (div 1 E!!!!) complicated because they use FFT.

Nice method, but you shouldn't use foreigh code without author's permission. :)

But, of course, it's some FFT realizations under public domain anyway.

Your text to link here... above is my code for question- Your text to link here...

can someone say what is wrong in it, i was unable to get it?

You have ignored the fact the coins array can have multiple instances of the same element. To be specific,

Lets take the coins array in the test case

`10 8 4 8 4 5 9`

. It goes fine till`10 8 4`

. When the second 8 is inserted,`set.size()`

does not increase greater than`k=2`

, but this 8 is added to`sum`

.ya..got that,..tnks!

Final contenders for major upsets in the 21st century:

`54`

Div2 BHorrible problems :'(

I solved E by using divide and conquer and FFT that is O(nlog^2). FFT solution : http://codeforces.com/contest/993/submission/39324259. And I get TLE by using NTT instead of FFT. NTT solution(TLE) : http://codeforces.com/contest/993/submission/39317762. Can only body explain why there are so much difference between these two solutions?

Your mod is way too big, and obviously you can't do this for time.

I used another smaller MOD. http://codeforces.com/contest/993/submission/39324083 Although it will get WA when the answer is bigger than MOD,but I still got TLE on some cases.

The code is different, you don't have the la * lb <= 10000 part.

And you should know that CF have extraordinarily slow int64 processing speed.

thanks Next time I'll try to avoid using int64

39325991

added part with small

max(la,lb)Wow! thanks for optimize my code!

Someone please explain solution for Div2 C

Read the editorial please

I have a cheater solution for that: because all vertices are integer points, the intersection of our two squares will contain an integer point if it is nonempty. Therefore, we can simply check if any of integer points in (-100,-100)..(100,100) lies inside both squares using areas (P is in ABCD iff S(ABCD) = S(ABP) + S(BCP) + S(CDP) + S(DAP), and an area of triangle can be calculated via Heron's formula).

Take a look at my code if you want to

Hi, thanks for the approach, After considering that there must be a integral point common to both the squares,I tried for each -100<=i<=100 and -100<=j<=100 and checked whether (i,j) is inside both of them by putting the point in the equation of lines of the sides of square, but I am getting WA on test 42. Can you spot the mistake in this approach of checking the existence of common point?

TMHMR, testcase #42 is a corner case when squares intersect at only one corner point. I think that you check if the integer point is

strictlybetween two sides of each square. You should also consider cases when it lies on one of the sides.Yeah I got it, I had done a very silly mistake while calculating correct coordinates bounds. Thanks

My submission http://codeforces.com/contest/994/submission/39327746 is wrong on test case #93 on codeforces, but it is correct when I run it on my PC and on ideone. https://ideone.com/ksKfLZ

Don't use DBL_EPSILON, cause it's 1e-16 and it's used for different things, you probably should google that.

DBL_EPSILON -> (1e-6) get accepted http://codeforces.com/contest/994/submission/39333094.

(Also, don't use long int, it's 32 bit on CF).

Your crafting.oj.uz ratings are updated! (Sorry for the late update, we were waiting until the round was declared rated :p)

Geometryforces Round #488 (Div. 2)