昨天晚上写的,写了一个多小时,9000+B,居然1A了,爽。

题意:玩扑克,比大小。规则如下:

题意很简单,看过赌神的人都知道,每人手中5张排,比牌面大小,牌面由大到小分别是(这里花色无大小),级别从高到低依次为:
1.同花顺:牌面一样,只比较最大的看谁大,一样大则平手
2.四条:四个一样的,看这四个一样的中谁大谁赢
3.葫芦:三条+一对,看三条中谁的牌面大
4.同花:都是同花就按从大到小比较,看谁的更大
5.顺子:都是顺子看最大的谁大,一样则平手
6.三条:三条看三条中谁的牌面大
7.两对: 两对就看谁的对子大,都一样大比单牌
8.一对: 比对子,一样则比单牌
9.单排:按顺序比较大小,大者胜

知道规则了就搞就行了。

代码:

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <algorithm>
  6. using namespace std;
  7. #define N 100007
  8.  
  9. struct node
  10. {
  11. int num,suit;
  12. }a[],b[];
  13. int BigstPair[],SecondPair[],Remain[]; //
  14. int k[][]; //
  15. int m[][]; //
  16.  
  17. int cmp(node ka,node kb)
  18. {
  19. return ka.num < kb.num;
  20. }
  21.  
  22. pair<int,int> solve(node a[],int tag)
  23. {
  24. int i,j;
  25. sort(a,a+,cmp);
  26. int level = ;
  27. int val = ;
  28. int flag = ;
  29. for(i=;i<;i++)
  30. {
  31. if(a[i].suit != a[i-].suit)
  32. break;
  33. }
  34. if(i == )
  35. {
  36. for(j=;j<;j++)
  37. {
  38. if(a[j].num != a[j-].num+)
  39. break;
  40. }
  41. if(j == )
  42. return make_pair(level,a[].num);
  43. }
  44. //
  45. level--;
  46. if((a[].num == a[].num && a[].num == a[].num && a[].num == a[].num)||(a[].num == a[].num && a[].num == a[].num && a[].num == a[].num))
  47. {
  48. if(a[].num == a[].num)
  49. return make_pair(level,a[].num);
  50. else if(a[].num == a[].num)
  51. return make_pair(level,a[].num);
  52. }
  53. //
  54. level--;
  55. if(a[].num == a[].num && a[].num == a[].num && a[].num == a[].num)
  56. return make_pair(level,a[].num);
  57. if(a[].num == a[].num && a[].num == a[].num && a[].num == a[].num)
  58. return make_pair(level,a[].num);
  59. //
  60. level--;
  61. if(a[].suit == a[].suit && a[].suit == a[].suit && a[].suit == a[].suit && a[].suit == a[].suit)
  62. {
  63. k[][tag] = a[].num;
  64. k[][tag] = a[].num;
  65. k[][tag] = a[].num;
  66. k[][tag] = a[].num;
  67. k[][tag] = a[].num;
  68. return make_pair(level,a[].num);
  69. }
  70. //
  71. level--;
  72. for(i=;i<;i++)
  73. {
  74. if(a[i].num != a[i-].num+)
  75. break;
  76. }
  77. if(i == )
  78. return make_pair(level,a[].num);
  79. //
  80. level--;
  81. int cnt = ;
  82. for(i=;i>=;i--)
  83. {
  84. if(a[i].num == a[i+].num)
  85. {
  86. cnt++;
  87. if(cnt >= )
  88. return make_pair(level,a[i].num);
  89. }
  90. else
  91. cnt = ;
  92. }
  93. //
  94. level--;
  95. if(a[].num == a[].num && a[].num == a[].num)
  96. {
  97. BigstPair[tag] = a[].num;
  98. SecondPair[tag] = a[].num;
  99. Remain[tag] = a[].num;
  100. return make_pair(level,BigstPair[tag]);
  101. }
  102. if(a[].num == a[].num && a[].num == a[].num)
  103. {
  104. BigstPair[tag] = a[].num;
  105. SecondPair[tag] = a[].num;
  106. Remain[tag] = a[].num;
  107. return make_pair(level,BigstPair[tag]);
  108. }
  109. if(a[].num == a[].num && a[].num == a[].num)
  110. {
  111. BigstPair[tag] = a[].num;
  112. SecondPair[tag] = a[].num;
  113. Remain[tag] = a[].num;
  114. return make_pair(level,BigstPair[tag]);
  115. }
  116. //
  117. level--;
  118. if(a[].num == a[].num)
  119. {
  120. m[][tag] = a[].num;
  121. m[][tag] = a[].num;
  122. m[][tag] = a[].num;
  123. m[][tag] = a[].num;
  124. return make_pair(level,m[][tag]);
  125. }
  126. if(a[].num == a[].num)
  127. {
  128. m[][tag] = a[].num;
  129. m[][tag] = a[].num;
  130. m[][tag] = a[].num;
  131. m[][tag] = a[].num;
  132. return make_pair(level,m[][tag]);
  133. }
  134. if(a[].num == a[].num)
  135. {
  136. m[][tag] = a[].num;
  137. m[][tag] = a[].num;
  138. m[][tag] = a[].num;
  139. m[][tag] = a[].num;
  140. return make_pair(level,m[][tag]);
  141. }
  142. if(a[].num == a[].num)
  143. {
  144. m[][tag] = a[].num;
  145. m[][tag] = a[].num;
  146. m[][tag] = a[].num;
  147. m[][tag] = a[].num;
  148. return make_pair(level,m[][tag]);
  149. }
  150. //9 High Cards
  151. level--;
  152. k[][tag] = a[].num;
  153. k[][tag] = a[].num;
  154. k[][tag] = a[].num;
  155. k[][tag] = a[].num;
  156. k[][tag] = a[].num;
  157. return make_pair(level,k[][tag]);
  158. }
  159.  
  160. int compare(pair<int,int> ka,pair<int,int> kb)
  161. {
  162. if(ka.first == kb.first)
  163. {
  164. if(ka.first == || ka.first == ) //flush or high card
  165. {
  166. if(k[][] == k[][])
  167. {
  168. if(k[][] == k[][])
  169. {
  170. if(k[][] == k[][])
  171. {
  172. if(k[][] == k[][])
  173. {
  174. if(k[][] == k[][])
  175. return ;
  176. else if(k[][] > k[][])
  177. return ;
  178. else
  179. return -;
  180. }
  181. else if(k[][] > k[][])
  182. return ;
  183. else
  184. return -;
  185. }
  186. else if(k[][] > k[][])
  187. return ;
  188. else
  189. return -;
  190. }
  191. else if(k[][] > k[][])
  192. return ;
  193. else
  194. return -;
  195. }
  196. else if(k[][] > k[][])
  197. return ;
  198. else
  199. return -;
  200. }
  201. else if(ka.first == ) //two pair
  202. {
  203. if(BigstPair[] == BigstPair[])
  204. {
  205. if(SecondPair[] == SecondPair[])
  206. {
  207. if(Remain[] == Remain[])
  208. return ;
  209. else if(Remain[] > Remain[])
  210. return ;
  211. else
  212. return -;
  213. }
  214. else if(SecondPair[] > SecondPair[])
  215. return ;
  216. else
  217. return -;
  218. }
  219. else if(BigstPair[] > BigstPair[])
  220. return ;
  221. else
  222. return -;
  223. }
  224. else if(ka.first == ) //pair
  225. {
  226. if(m[][] == m[][])
  227. {
  228. if(m[][] == m[][])
  229. {
  230. if(m[][] == m[][])
  231. {
  232. if(m[][] == m[][])
  233. return ;
  234. else if(m[][] > m[][])
  235. return ;
  236. else
  237. return -;
  238. }
  239. else if(m[][] > m[][])
  240. return ;
  241. else
  242. return -;
  243. }
  244. else if(m[][] > m[][])
  245. return ;
  246. else
  247. return -;
  248. }
  249. else if(m[][] > m[][])
  250. return ;
  251. else
  252. return -;
  253. }
  254. else
  255. {
  256. if(ka.second == kb.second)
  257. return ;
  258. else if(ka.second > kb.second)
  259. return ;
  260. else
  261. return ;
  262. }
  263. }
  264. else
  265. {
  266. if(ka.first > kb.first)
  267. return ;
  268. else if(ka.first < kb.first)
  269. return -;
  270. }
  271. }
  272.  
  273. int main()
  274. {
  275. int i,j;
  276. char ss[][];
  277. while(scanf("%s",ss[])!=EOF)
  278. {
  279. for(i=;i<;i++)
  280. scanf("%s",ss[i]);
  281. for(i=;i<;i++)
  282. {
  283. char pre = ss[i][];
  284. char back = ss[i][];
  285. if(pre >= '' && pre <= '')
  286. a[i].num = pre-'';
  287. else if(pre == 'T')
  288. a[i].num = ;
  289. else if(pre == 'J')
  290. a[i].num = ;
  291. else if(pre == 'Q')
  292. a[i].num = ;
  293. else if(pre == 'K')
  294. a[i].num = ;
  295. else if(pre == 'A')
  296. a[i].num = ;
  297. // 0:C 1:D 2:H 3:S
  298. if(back == 'C')
  299. a[i].suit = ;
  300. else if(back == 'D')
  301. a[i].suit = ;
  302. else if(back == 'H')
  303. a[i].suit = ;
  304. else
  305. a[i].suit = ;
  306. }
  307. for(i=;i<;i++)
  308. {
  309. char pre = ss[i][];
  310. char back = ss[i][];
  311. if(pre >= '' && pre <= '')
  312. b[i-].num = pre-'';
  313. else if(pre == 'T')
  314. b[i-].num = ;
  315. else if(pre == 'J')
  316. b[i-].num = ;
  317. else if(pre == 'Q')
  318. b[i-].num = ;
  319. else if(pre == 'K')
  320. b[i-].num = ;
  321. else if(pre == 'A')
  322. b[i-].num = ;
  323. // 0:C 1:D 2:H 3:S
  324. if(back == 'C')
  325. b[i-].suit = ;
  326. else if(back == 'D')
  327. b[i-].suit = ;
  328. else if(back == 'H')
  329. b[i-].suit = ;
  330. else
  331. b[i-].suit = ;
  332. }
  333. int res = compare(solve(a,),solve(b,));
  334. if(res > )
  335. puts("Black wins.");
  336. else if(res == )
  337. puts("Tie.");
  338. else
  339. puts("White wins.");
  340. }
  341. return ;
  342. }

ZOJ 1111 Poker Hands --复杂模拟的更多相关文章

  1. ZOJ 1111 Poker Hands

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1111 A poker hand consists of 5 ca ...

  2. UVALive 3486/zoj 2615 Cells(栈模拟dfs)

    这道题在LA是挂掉了,不过还好,zoj上也有这道题. 题意:好大一颗树,询问父子关系..考虑最坏的情况,30w层,2000w个点,询问100w次,貌似连dfs一遍都会TLE. 安心啦,这肯定是一道正常 ...

  3. ZOJ 3326 An Awful Problem 模拟

    只有在 Month 和 Day 都为素数的时候才能得到糖 那就模拟一遍时间即可. //#pragma comment(linker, "/STACK:16777216") //fo ...

  4. ZOJ 2476 Total Amount 字符串模拟

    - Total Amount Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit ...

  5. zoj 3314 CAPTCHA(纯模拟)

    题目 有些人用深搜写的,当然我这弱弱的,只理解纯模拟... 纯模拟,第一次写了那么长的代码,我自己也是够坚韧不拔的,,,,必须留念啊!!! 注意,G包含C,E包含L,R包含P,(照图说O应该不包含C, ...

  6. ZOJ 2477 Magic Cube 暴力,模拟 难度:0

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1477 用IDA*可能更好,但是既然时间宽裕数据简单,而且记录状态很麻烦,就直接 ...

  7. [ZOJ 3839] Poker Face (递归)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3839 题目大意:画脸..每张脸是上一个脸倒过来加上眼睛.. 注意 ...

  8. [ZOJ 1006] Do the Untwist (模拟实现解密)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6 题目大意:给你加密方式,请你求出解密. 直接逆运算搞,用到同余定理 ...

  9. ZOJ 1057 Undercut(简单模拟)

    Undercut 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=57 题目大意:a card game,two pla ...

随机推荐

  1. Java与线程

    导语 我们知道,new一个thread,调用它的start的方法,就可以创建一个线程,并且启动该线程,然后执行该线程需要执行的业务逻辑, 那么run方法是怎么被执行的呢? Java线程和os线程 os ...

  2. ahjesus ubuntu10.4安装ruby2.1.1

    sudo apt-get install python-software-properties sudo apt-add-repository ppa:brightbox/ruby-ng sudo a ...

  3. [js开源组件开发]js多选日期控件

    js多选日期控件 详情请见:http://www.lovewebgames.com/jsmodule/calendar.html 它的github地址:https://github.com/tianx ...

  4. innerHtml and Jquery.html()

    1. innerHtml是Dom HTML的属性 是只读的,不能写入. 2. JQuery只能调用.html(),它可以加参数,改变原HTML内容. http://api.jquery.com/htm ...

  5. Vue入门演示

    工作中用了很久vue,但是都是我们这边前端经理封装好的组件,想要看到底部的原理还要从层层代码里面剥离出来,逻辑太复杂,还不如自己一点点整理一下,一步一步走下去. github地址:https://gi ...

  6. 【转】提高C#编程水平的50个要点

    1.总是用属性 (Property) 来代替可访问的数据成员2.在 readonly 和 const 之间,优先使用 readonly3.在 as 和 强制类型转换之间,优先使用 as 操作符4.使用 ...

  7. RGui的http代理设置

    办公电脑环境需要http代理访问大网,使用R语言安装包时老是无法连接网络,后来从网上发现解决方法很简单,只需在启动RGui.exe的命令行上加上启动参数就可以了. "C:\Program F ...

  8. 并查集(Disjoint Set)

    在一些有N个元素的集合应用问题中,我们通常是在开始时让每个元素构成一个单元素的集合,然后按一定顺序将属于同一组的元素所在的集合合并,其间要反复查找一个元素在哪个集合中.这一类问题其特点是看似并不复杂, ...

  9. MyBatis入门(六)---mybatis与spring的整合

    一.整合需要 1.1.方法 上一章中的数据 需要spring通过单例方式管理SqlSessionFactory spring和mybatis整合生成代理对象,使用SqlSessionFactory创建 ...

  10. IOS UICollectionView基础+UICollectionViewFlowLayout基础

    UICollectionView在众多控件中也算是比较常用的了,像淘宝在浏览宝贝时采用的就是UICollectionView,对于UICollectionView->UICollectionVi ...