← Back to topics
Topic

[z-sudoku]

t
tgudlek
What's the catch with 4. and 7. test case?
R
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.
t
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
b
boris4
something is wrong with 4. and 7. test case
d
demjan0001
lol how then someone has 100 points on that task ??? LoL
A
Amtrix
I have the same problem....
R
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.
a
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
D
Daniel93
Isn't this Unicode?
d
demjan0001
so is solution:
YES
¢£*346789
???
b
boris4
cout << int( ¢ ) << endl;

prints

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

NO
������������������������
�������������$&
(),234>?EGIKNQSTV^_lwy{~
a
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.
D
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?
t
tgudlek
I mean on training, not on competition.
a
adminModerator
It is not unicode, it is just rendered as unicode on the forum
A
Amtrix
@admin:
What's the output for the example above that you gave??
a
adminModerator
YES
*346789��
a
adminModerator
or if you wanted rendered in unicode
YES
*346789¢£
a
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
R
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.
a
adminModerator
true... your output is different on the grader server though..
A
Amtrix
My output is too:
YES
*346789Lc
a
adminModerator
input file:
http://z-trening.com/share/sudoku.07.in
sol file:
http://z-trening.com/share/sudoku.07.sol
R
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.
D
Daniel93
I don't get it. Can somone explain what's wrong in my code. thx.
d
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]"
???
a
adminModerator
you have to use unsigned char!
D
Daniel93
my output says:
YES
*346789Lc
D
Daniel93
and it doesn't work at all....
t
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.
D
Daniel93
thx, I solved it :)
j
jokermc1
hehee i had also WA on 4 & 7 test case...

but now i have WA on 6th...

Admin can you help me??
m
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]
a
astrix
U shouldn't use gets. It's unsafe...
m
mfolnovic
well, if there's empty space in line, scanf wouldn't recognize it, right ?
m
mfolnovic
hmm, I get WR on 6th test case :S
m
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
m
mfolnovic
then I return true, see two lines lower ...
p
picsel
Thats wrong, it should be false.
Like this one for example

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


Result is NO
m
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
p
picsel
There has to be only 9 different characters, no more, no less
R
RobertGerbicz
My AC code is using gets. So it's enough.
j
jokermc1
ca someone help me pleease :)

i got problems with 6th test case???? :S
t
tgudlek
Check if more than 9 characters are used.
g
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
A
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;
g
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
p
picsel

for i:=1 to 9 do
begin
for j:=1 to 9 do
read(mat[i,j]);
readln;
end;
A
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;
g
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 ?
A
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. :)
p
picsel
I think your program is not working correctly :)
d
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 ...
g
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
p
picsel
Also, you don't need Clrscr. And your input is not correct like demjan said
g
gigac
My input was correct, but I did it like you say.
I also removed the ClrScr...
I still haven't correct test :S :@ :@ :@
p
picsel
In your last submission its still
readln(p[i,j]);

g
gigac
I don't know what is the difference but I corrected and It's still the same :S
g
gigac
Can I see at least one of the test files ?
p
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.
g
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
p
picsel
Are you checking columns also?
g
gigac
No..I'm checking only the rows, but If all the rows are correctly then all the columns are correct too :)
p
picsel
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj
abcdefghj


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