10443 - Rock, Scissors, Paper

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

Moderator: Board moderators

Postby lonelyone » Sun Mar 06, 2005 9:04 am

Ryan Pai wrote:For each string you're only allocating c characters. You need one more for the null terminator.

You also don't free the memory you malloc, so there's a leak.

I'd suggest using a static two dimensional array insead.


Thank you, you are a nice guy :D
but could you explain this problem for me...
i can't realize it completely...
and my code got wrong answer again... :cry:
lonelyone
Learning poster
 
Posts: 65
Joined: Sat Feb 19, 2005 6:53 pm

Postby lonelyone » Tue Mar 08, 2005 7:47 am

Code: Select all
INPUT
1 10 4
SRPSRPPRSR

OUTPUT
RPPPPPPPPP


RPPPPPPPPP is right..
but my output is RPPPPPPPRR
WHY....??
Could someone explain it in detail..
lonelyone
Learning poster
 
Posts: 65
Joined: Sat Feb 19, 2005 6:53 pm

Postby lonelyone » Wed Mar 09, 2005 9:54 pm

lonelyone wrote:
Code: Select all
INPUT
1 10 4
SRPSRPPRSR

OUTPUT
RPPPPPPPPP


RPPPPPPPPP is right..
but my output is RPPPPPPPRR
WHY....??
Could someone explain it in detail..


Ok!!
i got a.c.

thank anyone who take a view in this article..
lonelyone
Learning poster
 
Posts: 65
Joined: Sat Feb 19, 2005 6:53 pm

10443

Postby IRA » Sat Jan 28, 2006 3:49 pm

3 4 2
RSPR
SPRS
PRSP

Who can tell me the data how to change in first day and second day?
Thanks in advance
IRA
Learning poster
 
Posts: 82
Joined: Sat Jan 07, 2006 6:52 am

Postby neno_uci » Sat Jan 28, 2006 6:36 pm

After day #1:
Code: Select all
RRSP
RSPR
SPRS


After day #2:
Code: Select all
RRRS
RRSP
RSPR


good luck..., Yandry.
neno_uci
Experienced poster
 
Posts: 104
Joined: Sat Jan 17, 2004 12:26 pm
Location: Cuba

Postby IRA » Sat Jan 28, 2006 7:24 pm

neno_uci wrote:After day #1:
Code: Select all
RRSP
RSPR
SPRS


After day #2:
Code: Select all
RRRS
RRSP
RSPR


good luck..., Yandry.


How to change the data become the first day?
I can't think about it.
IRA
Learning poster
 
Posts: 82
Joined: Sat Jan 07, 2006 6:52 am

Postby IRA » Wed Feb 01, 2006 10:52 am

neno_uci wrote:After day #1:
Code: Select all
RRSP
RSPR
SPRS


After day #2:
Code: Select all
RRRS
RRSP
RSPR


good luck..., Yandry.


How to change the data become the first day?
I can't think about it.
IRA
Learning poster
 
Posts: 82
Joined: Sat Jan 07, 2006 6:52 am

10443,wa ples help!!!!

Postby turcse143 » Thu Feb 07, 2008 9:57 pm

this is sample input output whats problem ples give any logic
intput:
6
0 0 3

1 1 3
R
1 10 4
SRPSRPPRSR
10 1 4
R
S
P
P
S
R
R
S
P
P
3 4 3
PRSP
RSPR
SPRS
5 5 5
RRRSP
RSRSP
RRRRP
SRRRP
RPPRP

output:


R

RPPPPPPPPP

R
R
R
R
R
R
R
R
R
R

PPPP
PPPR
PPRS

RRRRR
RRRRR
PPPPP
PPPPP
PPPPP

Press any key to continue
whats problem???
''I want to be most laziest person in the world''
turcse143
Learning poster
 
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Postby turcse143 » Sat Feb 09, 2008 9:35 am

i have problem in the output
here:
RRRRR
RRRRR
PPPPP
PPPPP
PPPPP

by using dufferent logic i got accept
...use double array
...check every possible ocurrence
''I want to be most laziest person in the world''
turcse143
Learning poster
 
Posts: 81
Joined: Wed May 09, 2007 9:59 pm
Location: (CSE,DU) Dhaka,Bangladesh

Re: 10443 - Rock, Scissors, Paper

Postby stcheung » Tue Jan 13, 2009 8:40 am

This problem is one of the most straightforward ones I have seen, so if you are struggling then you are probably doing something wrong. In that case see if the following hints help:

(1) As someone mentioned before, it's probably easier to figure out how a given cell will change based on its neighboring cells than to figure out the opposite. More explicitly, if the current cell is Scissors, it will be a Rock only if one of its neighbors is a Rock.

(2) Like many other problems, if you are storing data for a r-by-c grid, you might want to define char [r+2][c+2] instead of char [r][c] and store the data in the middle so that you don't have to do all the boundary checking. I find this quite helpful, especially for all those problems involving chessboards.

(3) Really can't think of any other tip. Just make sure you output a blank line BETWEEN cases.
stcheung
Experienced poster
 
Posts: 114
Joined: Mon Nov 18, 2002 6:48 am

Previous

Return to Volume CIV

Who is online

Users browsing this forum: No registered users and 1 guest