1 / 8
Mar 2010

Hello,

I've been trying to solve the problem SQCOUNT. After failing to find any errors I checked the test data (by posting a program returning "1" if the problem occours). I am practically cerain that there are overlaping rooms in the test cases!

No only the problem states: "No two rooms will overlap", but if they do it's hard to say how to treat this kind of case. Should I reduce the number of squares but the number in the overlap? I know that many people have solved this and I guess it will work if You count with the O(n^2) algo, ignoring that the rooms intersect with more than just a side. Still it would be nice if this problem was resolved.

  • created

    Mar '10
  • last reply

    30d
  • 7

    replies

  • 197

    views

  • 6

    users

  • 2

    links

I strongly suspect that you are wrong since people have already been accepted. Use assert instead of returning 1. It will return sigabrt.

A quick test gives me the same conclusion as helper, rooms do appear to overlap. Just pretend they don't.

Sorry, it's evident that I completely missed half of helper's post.

Yes, I know what the problem was and I corrected accordingly, but still there will be users who'll waste time on trying to find bugs in correct problems. I found the test data on ACM site that is probably used in this problem, and I practically have a test generator, so can easily correct it. The problem is that the problem setter seems to be retired and there's no mail, so I don't know who to contact.

4 years later

Masz rację ,pomyłka, ale nadal mysle gdzie popelnilem błąd.

EDIT: Znalazłem błąd!

19 days later

Nie możesz niestety wczytywać w PHP fprintfem liczb oddzielonych spacjami jak w C/C++.
Musisz najpierw wczytać całą linię, a potem ją splitnąć, czyli podzielić na części umieszczając w tablicy. Służy do tego funkcja explode.
Dodałem we wspomnianym przez Ciebie temacie przykład takiego wczytywania.

A czemu wczytują się 2 liczby: "1 2 -100 -100 -100"? Ano tak naprawdę to wczytuje się tylko jedna! Oto jak traktowana jest linia z liczbami rozdzielonymi spacjami:
[bbone=PHP,2091]<?php
$x = "69 http://spoj.com/SHORTEN";
$y = "42 http://spoj.com/CONSTANT";
$z = $x+$y;
echo $z;
?>[/bbone]
Czyli taka linia zostaje skonwertowana do liczby aż do napotkania znaku, który nie jest cyfrą (czyli spacji).
Ale czemu tam jest wtedy ta 2? Ano to nie jest 2 z linii "1 2 3 4 5", tylko jest to następna linia, czyli następny test. smile

10 years later

Admins, it has been over 15 years since this issue was reported, and it still hasn’t been fixed. Please do something about it so folks can stop getting WA.