← Back to topics
Topic

[z-sudoku]

tgudlek
What's the catch with 4. and 7. test case?
RobertGerbicz
I would call this problem really crazy. The next 16 peoples on the ranklist who hasn't got perfect score all of them has got WA for 4 and 7 testcase (me too). I have 0 idea, my code is so simple, no trick.
tgudlek
Always printing YES: http://www.z-trening.com/new/www/html/submit.php?subm_stat=1&submit=7100021155
Always printing NO: http://www.z-trening.com/new/www/html/submit.php?subm_stat=1&submit=7100021158

So, the problem is obviously in character occourences:

for( it = chars.begin() ; it != chars.end() ; ++it ){
putchar( *it );
}


where "chars" is

set <char> znakovi;


:S
boris4
something is wrong with 4. and 7. test case
demjan0001
lol how then someone has 100 points on that task ??? LoL
Amtrix
I have the same problem....
RobertGerbicz
"lol how then someone has 100 points on that task ??? LoL"

Or those all of got wrong codes. Reading the discussion forum on the contest I had a feel that the admins hasn't got a valid program. But maybe I'm wrong. It's just really curious that those peoples who has got <=80 points on this problem all of them got WA for 4-th and 7-th input.
adminModerator
¢7943*8£6
*86¢7£934
43£986¢7*
76*8£43¢9
8437¢9*6£
9£¢6*3487
698347£*¢
3*4£6¢798
£¢7*98643


that is input 7
Daniel93
Isn't this Unicode?
demjan0001
so is solution:
YES
¢£*346789
???
boris4
cout << int( ¢ ) << endl;

prints

-101
Daniel93
(the characters can be any ASCII characters with codes in the range 32..255] )
tgudlek
Got all passed now.
Amtrix
Well i got the same result 70...
adminModerator
Here is Robert's outout:

NO
������������������������
�������������$&
(),234>?EGIKNQSTV^_lwy{~
adminModerator
the first characters are "invisible" and are not shown on the screen or in the file, you have to look at the file in hex mode.
Daniel93
@Admin
In the tasks it says it will be ASCII code characters. but this is Unicode. Why don't remove test-cases with Unicode characters?
tgudlek
I mean on training, not on competition.
adminModerator
It is not unicode, it is just rendered as unicode on the forum
Amtrix
@admin:
What's the output for the example above that you gave??
adminModerator
YES
*346789��
adminModerator
or if you wanted rendered in unicode
YES
*346789¢£
adminModerator
input not in unicode
�7943*8�6
*86�7�934
43�986�7*
76*8�43�9
8437�9*6�
9��6*3487
698347�*�
3*4�6�798
��7*98643
RobertGerbicz
"Here is Robert's outout:
NO"

Pasting to cmd my result:
YES
*346789Lc

(It's converted.) It's a little pointless to post characters which ASCI codes are in 128-255, because that is NOT standard, and can be totally different depending on the computer.
adminModerator
true... your output is different on the grader server though..
Amtrix
My output is too:
YES
*346789Lc
adminModerator
input file:
http://z-trening.com/share/sudoku.07.in
sol file:
http://z-trening.com/share/sudoku.07.sol
RobertGerbicz
Now solved. The problem was really silly: if you read it by simple char then 128-255 ascii values coded to the range [-128,-1], so at the sorting of the characters I had a mistake, but other parts of my code was good.
tgudlek
Same here :)
Daniel93
I don't get it. Can somone explain what's wrong in my code. thx.
demjan0001
well i used C++ sort and it's not correct ???
my output is:
cL*346789

on my comp
int(c) = -101 and int(L) = -100
and what is with:
"the characters can be any ASCII characters with codes in the range 32..255]"
???
adminModerator
you have to use unsigned char!
Daniel93
my output says:
YES
*346789Lc
Daniel93
and it doesn't work at all....
tgudlek
Char has 8 bit

for example, space is 00100000

If first bit of char is 1, then char value is negative. Numbers from 128 to 255 have 1 on their eighth bit, so they are negative. Even though some char value is less than zero, it's in fact greater than 128.
Daniel93
thx, I solved it :)
jokermc1
hehee i had also WA on 4 & 7 test case...

but now i have WA on 6th...

Admin can you help me??
mfolnovic
when I use unsigned char*, I can't input with gets, says:
[code]
z-sudoku.cpp:63: error: invalid conversion from ‘unsigned char*’ to ‘char*’
[/code]
astrix
U shouldn't use gets. It's unsafe...
mfolnovic
well, if there's empty space in line, scanf wouldn't recognize it, right ?
tgudlek
getchar ;)
mfolnovic
hmm, I get WR on 6th test case :S
msantl
I thnik that you made a mistake here:

if( used[i] > 9 ) return false;

what about when every characheter apperas less than 9 times
mfolnovic
then I return true, see two lines lower ...
picsel
Thats wrong, it should be false.
Like this one for example

$%&'()*+,
-./012345
6789:;<=>
?@ABCDEFG
HIJKLMNOP
QRSTUVWXY
Z[\]^_`ab
cdefghijk
lmnopqrst


Result is NO
msantl
No, the task statment says :" Every character has to be used exactly 9 times."

You check only > 9, you have to check !=9 and !=0
picsel
There has to be only 9 different characters, no more, no less
mfolnovic
oh, I see, tnx :)
RobertGerbicz
My AC code is using gets. So it's enough.
jokermc1
ca someone help me pleease :)

i got problems with 6th test case???? :S
tgudlek
Check if more than 9 characters are used.
gigac
First of all, I want to know how to input all the characters.
I use ReadLn and I set the chars. in array.
Also for some examples I have the correct result in my cmd, but here I have none correct. something is wrong oO
Al3kSaNdaR
This is how you input ->



ReadLn( m, n );
For i:=1 To m Do
Begin
For j:=1 To n - 1 Do Read ( Mat [i, j] );
ReadLn( Mat [i, n] );
End;
gigac
should it be
for i:=1 to 9 Do
For j:=1 to 9 Do read(mat[i,j]);

?
cuz It comes to sudoku ?
why inputing m and n

nevermind...I have no correct result :S
picsel

for i:=1 to 9 do
begin
for j:=1 to 9 do
read(mat[i,j]);
readln;
end;
Al3kSaNdaR
I know, it's 1 to 9. I didn't thought that it was sudoku, I just wrote the code for reading regular matrix.



For i:=1 To 9 Do
For j:=1 To 8 Do
Begin
Read(Mat[i,j]);
ReadLn(Mat[i,9]);
End;
gigac
Yeah...I knew that, but why I always get a Wrong result !
Can I see the tests... someone from the admins. What's going wrong ?
Al3kSaNdaR
You need to check if every character in matrix is repeating exactly 9 times! Then you need to check if every row and column has all different elements, and finally check the 3 x 3 squares. :)
picsel
I think your program is not working correctly :)
demjan0001
well this is ur code:

For I:=1 to 9 Do
For j:=1 to 9 Do
Begin
readln(p[i,j]);
addC(p[i,j]);
End;

it should be

For I:=1 to 9 Do
begin
For j:=1 to 9 Do
Begin
read(p[i,j]);
addC(p[i,j]);
End;
readln;
end;


i haven't looked at ur hole code i saw just input and i think it's wrong ...
gigac
Yeah..I am checking for if there are more than 9 characters.If ther are more then 9 used, it should say NO and print all chars sorted.

And I think if the whole puzzle is filled(like this task)
you can check only the rows or only the columns to see if it is corectly or not ?
As I said...my cmd gives a correct result :S :S :S
picsel
Also, you don't need Clrscr. And your input is not correct like demjan said
gigac
My input was correct, but I did it like you say.
I also removed the ClrScr...
I still haven't correct test :S :@ :@ :@
picsel
In your last submission its still
readln(p[i,j]);

gigac
I don't know what is the difference but I corrected and It's still the same :S
gigac
Can I see at least one of the test files ?
picsel
Read only reads one character, and readln reads the whole row. You also need to have one
Readln; after you read 9 characters in a row. Check Demjan's code, it should look like that. If you don't have that readln, you will read invisible (end of line) characters into your matrix, and thats wrong.
gigac
Ooo...this is nice.. only the first one is wrong..
Don't know why.

but I want to say sorry for my disobedience.
:)))))
And now a little talk for the first test :D
the only incorrect :D
picsel
Are you checking columns also?
gigac
No..I'm checking only the rows, but If all the rows are correctly then all the columns are correct too :)
picsel
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj


Rows correct, only 9 different letters used, but columns are wrong :)
gigac
oh crappy :D
Where is my mind this night..
can you delete all these posts :D :D :D
gigac
I fix that and I still can't go through the first test.
I quit.
picsel
I think you'll have to check 3x3 sub-squares also...
gigac
I don't know how...and I give up. (whew)