Does anyone know any trap in this problem ?
I try just to simulate this solitaire, but I got WA many times. Maybe I miss something in description ?
Maybe some IO ?
Edited:
Sorry, I made another silly mistake in my code. I wrong understood some sentences in description.
Best regards
DM
635 - Clock solitaire
Moderator: Board moderators
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
635 - Clock solitaire
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
don't get it..
I also use simulation, but can't get the sample right.
- what exactly is 52 cycle shifts..
Is it equivalent to placing the first card at the last place and then giving away the cards... and do this 52 times.
My output for the sample is 8 as opposed to 4, by following the above approach..
Some clarification might open up things for me.
Thanks.
- what exactly is 52 cycle shifts..
Is it equivalent to placing the first card at the last place and then giving away the cards... and do this 52 times.
My output for the sample is 8 as opposed to 4, by following the above approach..
Some clarification might open up things for me.
Thanks.
Code: Select all
Got Accepted
Last edited by Jan on Tue Jun 27, 2006 12:11 pm, edited 1 time in total.
Ami ekhono shopno dekhi...
HomePage
HomePage
I am trying to solve this problem, but I don't think I understand the description. I keep geting 0 as an answer to the sample input.
I do the following:
for every cycle ( if ABC were initial cards, then I suppose cycles were ABC, CAB and BCA ), I do the simulation:
In the simulation, I divide the cards into 13 queues and start from the 13. queue. I pick the lowest card and place it in the proper queue. I go through the cards until I pick some card I moved before. I count the number of turned cards. If this number is 52, this is winning configuration.
What am I doing wrong?
I do the following:
for every cycle ( if ABC were initial cards, then I suppose cycles were ABC, CAB and BCA ), I do the simulation:
In the simulation, I divide the cards into 13 queues and start from the 13. queue. I pick the lowest card and place it in the proper queue. I go through the cards until I pick some card I moved before. I count the number of turned cards. If this number is 52, this is winning configuration.
What am I doing wrong?
A sta da radim
Check if you convert characters in the input to numbers correctly.
'A' is considered 11 o'clock, and 'J' is 1 o'clock, although I think it would be more logical otherwise.
Also there is no mention of character 'T' in the problem statement while there is 'T' in the sample input, not "10".
When you deal the cards, put four cards on one o'clock first, then next four cards on two o'clock... and finally the last four cards at the center.
I hope it helps :)
'A' is considered 11 o'clock, and 'J' is 1 o'clock, although I think it would be more logical otherwise.
Also there is no mention of character 'T' in the problem statement while there is 'T' in the sample input, not "10".
When you deal the cards, put four cards on one o'clock first, then next four cards on two o'clock... and finally the last four cards at the center.
I hope it helps :)
-
- Experienced poster
- Posts: 139
- Joined: Wed May 18, 2011 3:04 pm
Re: 635 - Clock solitaire
The statement of problem is not so clear, I spent some time on Internet to figure out the rule of Clock game. The rule in this problem differs from regular rule. you should beware of two points below:
1. When you deal the cards, you should place four card at one clock, then four cards at two clock, and so on, for sample input, the cards at one clock is: 7 J 9 3, the order is from bottom to top, 7 is the bottommost card, 3 is the topmost card.
2. "cyclic shifts" means move the first card to last place of sequence, deal cards and play again to check successful or not untill sequence return to original state.
1. When you deal the cards, you should place four card at one clock, then four cards at two clock, and so on, for sample input, the cards at one clock is: 7 J 9 3, the order is from bottom to top, 7 is the bottommost card, 3 is the topmost card.
2. "cyclic shifts" means move the first card to last place of sequence, deal cards and play again to check successful or not untill sequence return to original state.
metaphysis: http://uhunt.onlinejudge.org/id/95895
My solutions for UVa problems: https://github.com/metaphysis/Code.
My solutions for UVa problems: https://github.com/metaphysis/Code.
-
- Experienced poster
- Posts: 139
- Joined: Wed May 18, 2011 3:04 pm
Re: 635 - Clock solitaire
The test data generator.
Code: Select all
#include <iostream>
#include <algorithm>
#include <ctime>
#include <random>
using namespace std;
int main(int argc, char *argv[])
{
string cards = "7J93JQKA23456789T8QKA23456789TJQKA23456789TJQKA2T456";
for (int i = 1; i <= 100; i++)
{
shuffle (cards.begin(), cards.end(), default_random_engine(time(NULL)));
for (int j = 0; j < cards.length(); j++)
{
if (j > 0)
cout << ' ';
cout << cards[j];
}
cout << '\n';
}
cout << "0\n";
return 0;
}
metaphysis: http://uhunt.onlinejudge.org/id/95895
My solutions for UVa problems: https://github.com/metaphysis/Code.
My solutions for UVa problems: https://github.com/metaphysis/Code.