Submit | All submissions | Best solutions | Back to list |
BOARD - Counting red squares |
Wersja polska | English version |
Twoim zadaniem jest zliczenie wszystkich czerwonych kwadratów z określonego obszaru na następującej nieskończonej tablicy:
Wejście
Wejście składa się z nieokreślonej liczby testów. Każdy z nich zawiera jedną linię z czterema liczbami naturalnymi x1, y1, x2, y2 (wszystkie<1000001). Pierwsze dwie to współrzędne lewego dolnego rogu prostokąta, a dwie ostatnie to współrzędne prawego górnego rogu prostokąta.
Wyjście
Dla każdego testu wypisz ilość czerwonych kwadratów, które podany prostokąt zawiera.
Przykład
Wejście: 0 0 2 2
2 1 4 3
Wyjście:
3
2
Added by: | Piotr Kąkol |
Date: | 2011-07-14 |
Time limit: | 5s-10s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: SCM qobi |
Resource: | Copy of Michael Suchacz's task: DCZPROST |
hide comments
|
||||||
2014-03-11 06:08:37 Hallvard Norheim Bø
@Piotr: this problem is broken, since the image doesn't show (the image source path is using spoj.pl). edit: looks like it is fixed now :) Last edit: 2014-05-19 19:35:09 |
||||||
2012-02-21 10:23:10 Jander
@weltfremd - I suspect we do have different methods. You'll have to pop on to the IRC channel sometime - quite happy to discuss there :-) |
||||||
2012-02-21 05:10:46 weltfremd
This doesn't have to look too messy. There's a rather elegant formula for 0 0 x y. But according to the time your solution needs I think you took a different approach ;) |
||||||
2012-02-19 19:42:19 Jander
@weltfremd - Yes, it looks like I need to do some elimination then. I will admit to not liking that part of my code as it looks messy. |
||||||
2012-02-18 14:41:10 weltfremd
Thank you Jander :) Well, don't scratch to hard, maybe it's all about reading the input. But if there's a power of -1 in your solution, you should eliminate that. That's what saved me another 6 chars (though I had then again to add one char to compensate some strange behaviour of awk 3.1.6 ;)) |
||||||
2012-02-18 10:57:35 Jander
@Weltfremd - very impressed at how short you've managed to get this one. I'm now scratching my head thinking about how I can get the calculations shorter :-) |
||||||
2012-02-15 21:17:31 weltfremd
@Piotr: Hi :) Would you tell me for which input my submission 6509554 fails? I've let it compete my AC solution with random input for quite a while now, but can't find any different behaviour. It's okay, I found out what the problem was on ideone. :) Last edit: 2012-02-17 18:38:39 |
||||||
2011-10-20 09:00:24 Jander
It's only taken me just over three months to work this one out, but I got there in the end :-) Perl seems to do quite well at this one. |
||||||
2011-07-30 22:35:39 Piotr KÄ…kol
@HWK - Again the same trick. ;-) There are not many variables left four of which are necessary. ;-) |
||||||
2011-07-30 20:27:00 HWK
@Piotr: Again one byte. But I guess it's still not the right var. Thus what about 121? ;-) |