489 - Hangman Judge

All about problems in Volume 4. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Is this a rule of Hangman? ;)

Yesss...
4
44%
Are you Crazy??? :P
5
56%
 
Total votes: 9

jhonny_yang
New poster
Posts: 22
Joined: Fri Jan 17, 2003 8:24 am

confuse 489 with online judge

Post by jhonny_yang » Fri Dec 17, 2004 5:48 pm

Code: Select all

#include <stdio.h> 
#include <string.h>

int main() 
{ 
	int n,i,j,count;
	char target[256],source[256];
	while (scanf("%d\n",&n)==1){
		if (n<0)break;
		gets(target);
		gets(source);

		for (j=0;source[j];j++){
			if(source[j]==' '){
				for (count=j+1;source[count];count++){
					source[count-1]=source[count];
				}
				source[count-1]=0;
				--j;
			}
		}
		for (j=0;target[j];j++){
			if(target[j]==' '){
				for (count=j+1;target[count];count++){
					target[count-1]=target[count];
				}
				target[count-1]=0;
				--j;
			}
		}

		for (i=0;source[i];i++){
			for (j=i+1;source[j];j++){
				if(source[j]==source[i]){
					for (count=j+1;source[count];count++){
						source[count-1]=source[count];
					}
					source[count-1]=0;
					--j;
				}
			}
		}

		count=0;
		for (i=0;source[i];i++){
			for (j=0;target[j];j++){
				if(target[j]==source[i]){
					target[j]=-1;
					count++;
				}
			}
		}
		
		printf("Round %d\n",n);
		if (count==j && i<=7){
			printf("You win.\n");
		}else if (count<j && i<=7){
			printf("You chickened out.\n");			
		}else{
			printf("You lose.\n");
		}
	}
	
	return 0; 
} 
[/code]

User avatar
Ghust_omega
Experienced poster
Posts: 115
Joined: Tue Apr 06, 2004 7:04 pm
Location: Venezuela

Post by Ghust_omega » Fri Dec 24, 2004 6:50 am

Hi !! jhonny_yang this some I/O maybe you can test :
In:

Code: Select all


1
cheese
chese
2
cheese
abcdefg
3
cheese
abcdefgij
4
t
r
1
aaa
bcdbcdbcdbcdefghja
7
aaa
bcdbcdbcdbcdefdta
2
aaa
bcdbcdbcdbcdegt
-1
out:

Code: Select all

Round 1
You win.
Round 2
You chickened out.
Round 3
You lose.
Round 4
You chickened out.
Round 1
You lose.
Round 7
You win.
Round 2
You chickened out.
Hope it helps
Keep posting

InfiniteLOOP
New poster
Posts: 2
Joined: Mon Oct 10, 2005 6:52 pm
Location: Dhaka,Bangladesh

489 Need some critical inputs

Post by InfiniteLOOP » Wed Oct 19, 2005 6:21 pm

NEED some critical inputs for the 489 problem
Programming is LIFE!!
LIFE is programming!!

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Sat Nov 19, 2005 1:46 am

Just select the search option and type 489... You will get some other posts about 489....

You can try...

http://online-judge.uva.es/board/viewto ... hlight=489
Ami ekhono shopno dekhi...
HomePage

pipo
New poster
Posts: 47
Joined: Tue May 11, 2004 6:43 pm
Location: Republic of Korea

[489] need more inputs & outputs

Post by pipo » Fri Jan 06, 2006 2:26 pm

hi...

I tested some inputs and outputs in this forum...

the all answers are correct exactly...

but!! I got WA :(

the code is below....


Code: Select all

deleted after Accepted

pipo
New poster
Posts: 47
Joined: Tue May 11, 2004 6:43 pm
Location: Republic of Korea

Post by pipo » Wed Jan 11, 2006 3:35 pm

I'm sorry ..

I had a silly mistake... :(

once, I was incorrect in printing the output string...

anyway, thanks for reading...

good luck!!

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko » Tue Apr 04, 2006 6:53 am

alu_mathics' result for the second case is wrong (it is obvious - you try only 3 unique letters before you guess the whole word)

Darko

dipaly
New poster
Posts: 20
Joined: Tue Sep 19, 2006 6:18 pm
Location: bangladesh
Contact:

its not clear

Post by dipaly » Tue May 01, 2007 9:15 am

i can't understand wht does it mean...

Code: Select all

Each unique wrong guess only counts against the contestant once.

can any one explain to me plzzzzzzzzz..

1.. wht s mean by unique wrong guess ?
2. how can we count this unique wrong guess ?

:oops: i am realy weak in english :cry: :cry:
everything is so hard to me

gates1
New poster
Posts: 7
Joined: Tue May 01, 2007 2:11 pm

Post by gates1 » Fri May 04, 2007 8:44 am

i got WA can anybody help me plzzzzz

Code: Select all

var a:array[1..100000] of byte;
b:array[1..100000] of integer;
i,e,h,k,l,p:integer;
s,g,s1:string;
begin
repeat
readln(e);
if e>0 then begin
inc(h);
b[h]:=e;
        readln(s);
        readln(g);
        l:=0;
        p:=0;
        s1:='';
        for i:=1 to length(g) do begin
        k:=0;
                while pos(g[i],s)>0 do begin
                inc(k);
                s[pos(g[i],s)]:='+';
                end;
                if k>0 then inc(p,k);
        if k=0 then if pos(g[i],s1)=0 then begin inc(l); s1:=s1+g[i]; end;
        end;
        if l>6 then a[e]:=0;
        if (l<7) and (p=length(s)) then a[e]:=1;
        if (l<7) and (p<length(s)) then a[e]:=2;
        end;
until e=-1;
for i:=1 to h do begin
writeln('Round ',b[i]);
if a[i]=0 then writeln('You lose.');
if a[i]=1 then writeln('You win.');
if a[i]=2 then writeln('You chickened out.');
end;
readln;
end.

soddy
New poster
Posts: 23
Joined: Tue May 29, 2007 1:39 am

WA!!!

Post by soddy » Mon Jun 11, 2007 8:07 am

i also have the same doubt...if multiple correct guesses r made then how shld they b delt....although i hv tried both options, including a stroke and otherwise, still i get WA...
here is the code

Code: Select all

Removed after AC
plz smone help...

User avatar
Fuad Hassan EWU
New poster
Posts: 38
Joined: Tue Jul 17, 2007 3:21 pm
Location: East West University

getting WA

Post by Fuad Hassan EWU » Mon Sep 10, 2007 6:52 pm

I tried all the critical inputs those are posted so far. all works right. but i getting WA. plz help me out....... :oops:

Code: Select all

#include<iostream>
using namespace std;
int main()
{

  cout<<"Deleted after AC";
  return 0;
} 
Last edited by Fuad Hassan EWU on Thu Sep 13, 2007 5:42 pm, edited 2 times in total.
Eagle er moto daana meley urbo

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Mon Sep 10, 2007 11:01 pm

Try the cases...

Input:

Code: Select all

167
axyq
eprxibexxyf
171
nho
tonpyzwotkg
-1
Output:

Code: Select all

Round 167
You chickened out.
Round 171
You lose.
Hope these help.
Last edited by Jan on Thu Sep 13, 2007 1:46 am, edited 1 time in total.
Ami ekhono shopno dekhi...
HomePage

User avatar
Fuad Hassan EWU
New poster
Posts: 38
Joined: Tue Jul 17, 2007 3:21 pm
Location: East West University

Post by Fuad Hassan EWU » Wed Sep 12, 2007 4:55 pm

bt jan vai according to your input output it needs 6 unique wrong guesses. bt as far i understand from the problem it needs 7 unique wrong guesses to lose a game. Plz correct my understanding.
Eagle er moto daana meley urbo

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Thu Sep 13, 2007 1:45 am

Yes. You are right. Sorry for posting wrong set. My previous code wasnt fully correct. However I have corrected my code now. And listed some cases. Hope those help.
Ami ekhono shopno dekhi...
HomePage

User avatar
Fuad Hassan EWU
New poster
Posts: 38
Joined: Tue Jul 17, 2007 3:21 pm
Location: East West University

Post by Fuad Hassan EWU » Thu Sep 13, 2007 5:36 pm

Thanks jan vai, it really worked for me. what a silly mistake i have done. i considered unique wrong guesses bt did not considered unique right guesses :roll:
Eagle er moto daana meley urbo

Post Reply

Return to “Volume 4 (400-499)”