2014
03-16

# Flipper

Little Bobby Roberts (son of Big Bob, of Problem G) plays this solitaire memory game called Flipper. He starts with n cards, numbered 1 through n, and lays them out in a row with the cards in order left-to-right. (Card 1 is on the far left; card n is on the far right.) Some cards are face up and some are face down. Bobby then performs n – 1 flips ― either right flips or left flips. In a right flip he takes the pile to the far right and flips it over onto the card to its immediate left. For example, if the rightmost pile has cards A, B, C (from top to bottom) and card D is to the immediate left, then flipping the pile over onto card D would result in a pile of 4 cards: C, B, A, D (from top to bottom). A left flip is analogous.

The very last flip performed will result in one pile of cards ― some face up, some face down. For example, suppose Bobby deals out 5 cards (numbered 1 through 5) with cards 1 through 3 initially face up and cards 4 and 5 initially face down. If Bobby performs 2 right flips, then 2 left flips, the pile will be (from top to bottom) a face down 2, a face up 1, a face up 4, a face down 5, and a face up 3.

Now Bobby is very sharp and you can ask him what card is in any position and he can tell you!!! You will write a program that matches Bobby’s amazing feat.

Each test case will consist of 4 lines. The first line will be a positive integer n (2 ≤ n ≤ 100) which is the number of cards laid out. The second line will be a string of n characters. A character U indicates the corresponding card is dealt face up and a character D indicates the card is face down. The third line is a string of n – 1 characters indicating the order of the flips Bobby performs. Each character is either R, indicating a right flip, or L, indicating a left flip. The fourth line is of the form m q1 q2 . . . qm, where m is a positive integer and 1 ≤ qin. Each qi is a query on a position of a card in the pile (1 being the top card, n being the bottom card). A line containing 0 indicates end of input.

Each test case will consist of 4 lines. The first line will be a positive integer n (2 ≤ n ≤ 100) which is the number of cards laid out. The second line will be a string of n characters. A character U indicates the corresponding card is dealt face up and a character D indicates the card is face down. The third line is a string of n – 1 characters indicating the order of the flips Bobby performs. Each character is either R, indicating a right flip, or L, indicating a left flip. The fourth line is of the form m q1 q2 . . . qm, where m is a positive integer and 1 ≤ qin. Each qi is a query on a position of a card in the pile (1 being the top card, n being the bottom card). A line containing 0 indicates end of input.

5
UUUDD
RRLL
5 1 2 3 4 5
10
UUDDUUDDUU
LLLRRRLRL
4 3 7 6 1
0

Pile 1
Card 1 is a face down 2.
Card 2 is a face up 1.
Card 3 is a face up 4.
Card 4 is a face down 5.
Card 5 is a face up 3.
Pile 2
Card 3 is a face down 1.
Card 7 is a face down 9.
Card 6 is a face up 7.
Card 1 is a face down 5.

#include<stdio.h>
#include<stack>
#include<string.h>
using namespace std;
stack<int> s[105];         //每张牌看成一个栈
int main()
{
int n,m,num=1,i,j,a[105],k;
char str[105];
int ok[105];               //标记每张牌的状态
while(scanf("%d",&n)!=EOF)
{
if(n==0)
break;
scanf("%s",str);
for(i=0;i<n;i++)
{
if(str[i]=='U')
ok[i]=1;
else
ok[i]=0;
}

int l=0,r=n-1;
for(i=0;i<n;i++)
s[i].push(i);
scanf("%s",str);
for(i=0;i<n-1;i++)
{
if(str[i]=='L')
{
l++;
for(j=0;j<l;j++)
ok[j]=1-ok[j];
while(!s[l-1].empty())
{
s[l].push(s[l-1].top());
s[l-1].pop();
}
}
else
{
r--;
for(j=n-1;j>r;j--)
ok[j]=1-ok[j];
while(!s[r+1].empty())
{
s[r].push(s[r+1].top());
s[r+1].pop();
}
}
}
for(i=0;i<n;i++)
{
a[i]=s[l].top();
s[l].pop();
}
printf("Pile %d\n",num++);
scanf("%d",&m);
while(m--)
{
scanf("%d",&k);
printf("Card %d is a face ",k);
k--;
printf(ok[a[k]]?"up ":"down ");
printf("%d.\n",a[k]+1);
}
}
return 0;
}

1. Pingback: best vibrator for couples

2. Pingback: طراحی سایت توسط پویا وب

3. Pingback: 8 oz tkd uniform

4. Pingback: sex kit

5. Pingback: نصب دوربین های مدار بسته

6. Pingback: long dildo

7. Pingback: over shoes

8. Pingback: خرید اپل ایدی

9. Pingback: Magnet tape

10. Pingback: gay lubricants

11. Pingback: کفسابی

12. Pingback: مشاوره با وکیل

13. Pingback: bi curious women

14. Pingback: strap-on

15. Pingback: mini wand massager

16. Pingback: kvass

17. Pingback: penile toy

18. Pingback: Waterproof Vibrator

19. Pingback: Karate master black trim gi

20. Pingback: driving tips

22. Pingback: Mikemaid.com

23. Pingback: مقالات دوربین مدار بسته

24. Pingback: Anal toys

26. Pingback: massage oil

27. Pingback: Butt plugs

28. Pingback: Dildo

29. Pingback: billing

30. Pingback: bunny rabbit

31. Pingback: gay toys

33. Pingback: porn watch

34. Pingback: php ecommerce

35. Pingback: hipoteca

36. Pingback: Safest forex brokers

37. Pingback: intuit serial keys

38. Pingback: Miami

40. Pingback: Out Of Town 66

42. Pingback: port charges

43. Pingback: ノロウイルス

44. Pingback: inspekce jerabu

45. Pingback: Bars Of Death,No DJ

46. Pingback: http://www.getappid.ir

47. Pingback: emergency room glendale

48. Pingback: best sex lube

49. Pingback: prostate stimulation

50. Pingback: ترمیم مو بیماران

51. Pingback: bullet vibrator review

52. Pingback: vibrator

53. Pingback: adam and eve sex toys

54. Pingback: bullet vibrator

55. Pingback: 7 inch vibrator

56. Pingback: پویاویلا

57. Pingback: adam and eve sex toy shop

58. Pingback: خريد اپل ايدي امريكا

59. Pingback: اجاره ویلا چالوس

60. Pingback: anal sex

61. Pingback: skin feel dildo

63. Pingback: خرید اپل ایدی انلاین

64. Pingback: magnetic label tape

65. Pingback: temporary floor protection

66. Pingback: تردمیل خانگی

67. Pingback: polythene rolls

68. Pingback: pallet wrap

69. Pingback: wand vibrator

70. Pingback: deepthroat

71. Pingback: warning signs of infidelity

72. Pingback: best ben wa balls

73. Pingback: erotic

74. Pingback: erotic

75. Pingback: bondage gear

76. Pingback: php web programming

77. Pingback: خرید اپل ایدی

78. Pingback: sex toys for gay

79. Pingback: oral mints

80. Pingback: vibrator

81. Pingback: the bullet sex toy

82. Pingback: small cap stocks

83. Pingback: vpn خرید برای گوشی

84. Pingback: Kids boxing bag starter kit

85. Pingback: samuraiTV

86. Pingback: lgbt sex toys

87. Pingback: sex lubricants

88. Pingback: sexy lingerie

89. Pingback: ترمیم مو

90. Pingback: طراحی سایت

91. Pingback: Minihaziko

92. Pingback: tratamento de Alcoolismo

94. Pingback: penis sleeve

96. Pingback: Supply Chain

97. Pingback: momentum stocks

98. Pingback: Best Ben Wa Balls

99. Pingback: Penis pump

100. Pingback: Male Sex Toy

101. Pingback: sex gel

102. Pingback: lifelike vibrator

103. Pingback: Female G Spot

105. Pingback: icicles

106. Pingback: magic wand vibrator

107. Pingback: Sex toys in public prank

108. Pingback: first anal vibrator

109. Pingback: pc apps for windows 8

110. Pingback: probiotic sauerkraut kvass

111. Pingback: app for pc

114. Pingback: sex toys for beginners

115. Pingback: sexy lingerie

116. Pingback: rubber ducky vibrator

117. Pingback: sex dildos

118. Pingback: Erotic Toys for men

120. Pingback: A\u0026E beginner's power pump

121. Pingback: Price Comparison

122. Pingback: Vibrating Penis Ring

123. Pingback: Penis Pump Review

124. Pingback: best g-spot vibrator

125. Pingback: Blowjob Sex Toy

126. Pingback: RavingsbyRae

127. Pingback: adam and eve sex toy

128. Pingback: jbeatz

129. Pingback: clit vibrator

130. Pingback: massager

131. Pingback: gay male toys

132. Pingback: sex toys

133. Pingback: Fuel injector

134. Pingback: خرید دوربین مدار بسته

136. Pingback: www.spu.ac.th

137. Pingback: Bond cleaning services

138. Pingback: sex lube

140. Pingback: adam and eve sex toys

141. Pingback: Best Sex Lube

142. Pingback: Bondage Restraint

143. Pingback: Masturbator

144. Pingback: Dolphin Vibrator

145. Pingback: Clit Cream

146. Pingback: Personal Massager

147. Pingback: Butterfly Vibrator

148. Pingback: Magic Massager

149. Pingback: adam and eve sex toy

150. Pingback: adam and eve vibrators

151. Pingback: where to buy waterproof vibrator

152. Pingback: interior design Singapore

154. Pingback: bandiera Italia

155. Pingback: rental cleaning Melbourne

156. Pingback: g-spot vibrator slim vibrator

157. Pingback: rabbit vibe

158. Pingback: Scented Candles,

159. Pingback: dildo

160. Pingback: anal toy

161. Pingback: butt plug

162. Pingback: first butt plug

163. Pingback: sex toys for gay men

164. Pingback: Central district seattl

165. Pingback: Easy recipes for vegetarians

166. Pingback: Bond back cleaning reviews

167. Pingback: g spot stimulator

168. Pingback: penis pumps

169. Pingback: label besi

171. Pingback: leather cleaning

172. Pingback: real feel penis

175. Pingback: being in the army

176. Pingback: glass g spot vibrator

177. Pingback: Taoist Real Sex Talk

178. Pingback: I Love News Paper

179. Pingback: a&e true feel

180. Pingback: best butt plug

181. Pingback: the sylvers

183. Pingback: most powerful vibrator

184. Pingback: vibrator for beginners

185. Pingback: Venture Point Network

186. Pingback: website developers

187. Pingback: rampant vibrator

188. Pingback: CNC Machining Cover tube

189. Pingback: high count sheets

190. Pingback: silicone containers

191. Pingback: online scr game

192. Pingback: basement renovation in Atlanta

193. Pingback: nippl sex toys

195. Pingback: triple rabbit vibrator

196. Pingback: realistic vibrating dildo

197. Pingback: womens vibrator

198. Pingback: realistic dong vibrator

199. Pingback: vibrating dildo

200. Pingback: free web hosting

201. Pingback: Accessories

203. Pingback: clínica de reabilitação

204. Pingback: coffee’s best kona

205. Pingback: RMUTT

206. Pingback: coffee’s best kona

207. Pingback: realistic dildo

208. Pingback: ean codes

209. Pingback: boogie board rental near me

210. Pingback: sex toy bullet

211. Pingback: ride sex toys

213. Pingback: sex toy review

214. Pingback: sex toys cleaner

215. Pingback: butterfly sex toys

216. Pingback: cheap cock rings

217. Pingback: g spot vibe

218. Pingback: work at home jobs 2018

219. Pingback: vintage collectibles

220. Pingback: chinese antiquities

221. Pingback: trička

222. Pingback: sihir

223. Pingback: lefkoşa kirakık ev fiyatları

224. Pingback: murphy bed

225. Pingback: robert

226. Pingback: Internet Marketing

227. Pingback: barcode kaufen

228. Pingback: email database australia

229. Pingback: Panoz

230. Pingback: Pain Relief Oil

231. Pingback: Double Sided Dildo

232. Pingback: how to make money from home

233. Pingback: adam and eve sex toy shop

236. Pingback: kona 100%

237. Pingback: email processing jobs

238. Pingback: cock rings

239. Pingback: Air Jordan 12 Low Cool Grey For Sale

240. Pingback: women are aware

241. Pingback: men

242. Pingback: recovery clinic

243. Pingback: 50% of on Empty capsules!

244. Pingback: gspot toy

245. Pingback: Law enforcement black duty boots

246. Pingback: Purchase Beer Online