http://acm.hdu.edu.cn/showproblem.php?pid=2164

Problem Description
Rock, Paper, Scissors is a two player game, where each player simultaneously chooses one of the three items after counting to three. The game typically lasts a pre-determined number of rounds. The player who wins the most rounds wins the game. Given the number of rounds the players will compete, it is your job to determine which player wins after those rounds have been played.

The rules for what item wins are as follows:

?Rock always beats Scissors (Rock crushes Scissors)
?Scissors always beat Paper (Scissors cut Paper)
?Paper always beats Rock (Paper covers Rock) 

 
Input
The first value in the input file will be an integer t (0 < t < 1000) representing the number of test cases in the input file. Following this, on a case by case basis, will be an integer n (0 < n < 100) specifying the number of rounds of Rock, Paper, Scissors played. Next will be n lines, each with either a capital R, P, or S, followed by a space, followed by a capital R, P, or S, followed by a newline. The first letter is Player 1抯 choice; the second letter is Player 2抯 choice.

 
Output
For each test case, report the name of the player (Player 1 or Player 2) that wins the game, followed by a newline. If the game ends up in a tie, print TIE.
 
Sample Input
3
2
R P
S R
3
P P
R S
S R
1
P R
 
Sample Output
Player 2
TIE
Player 1
 
代码:

#include <bits/stdc++.h>
using namespace std; char p1[1111], p2[1111]; int cmp(char a, char b) { if(a == 'S') {
if(b == 'P') return 2;
if(b == 'R') return 1;
} if(a == 'R') {
if(b == 'S') return 2;
if(b == 'P') return 1;
} if(a == 'P') {
if(b == 'R') return 2;
if(b == 'S') return 1;
}
} int main() {
int T;
scanf("%d", &T);
while(T --) {
int x;
scanf("%d", &x);
int cnt = 0, ans = 0;
getchar();
for(int i = 1; i <= x; i ++) {
scanf("%c %c", &p1[i], &p2[i]);
getchar();
if(cmp(p1[i], p2[i]) == 2)
cnt ++;
else if(cmp(p1[i], p2[i]) == 1)
ans ++;
} if(cnt > ans)
printf("Player 1\n");
else if(cnt == ans)
printf("TIE\n");
else
printf("Player 2\n");
}
return 0;
}

  

 

HDU 2164 Rock, Paper, or Scissors?的更多相关文章

  1. HDOJ(HDU) 2164 Rock, Paper, or Scissors?

    Problem Description Rock, Paper, Scissors is a two player game, where each player simultaneously cho ...

  2. HDU 2164(模拟)

    Rock, Paper, or Scissors? Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Jav ...

  3. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  4. SDUT 3568 Rock Paper Scissors 状压统计

    就是改成把一个字符串改成三进制状压,然后分成前5位,后5位统计, 然后直接统计 f[i][j][k]代表,后5局状压为k的,前5局比和j状态比输了5局的有多少个人 复杂度是O(T*30000*25*m ...

  5. FFT(Rock Paper Scissors Gym - 101667H)

    题目链接:https://vjudge.net/problem/Gym-101667H 题目大意:首先给你两个字符串,R代表石头,P代表布,S代表剪刀,第一个字符串代表第一个人每一次出的类型,第二个字 ...

  6. Gym - 101667H - Rock Paper Scissors FFT 求区间相同个数

    Gym - 101667H:https://vjudge.net/problem/Gym-101667H 参考:https://blog.csdn.net/weixin_37517391/articl ...

  7. Gym101667 H. Rock Paper Scissors

    将第二个字符串改成能赢对方时对方的字符并倒序后,字符串匹配就是卷积的过程. 那么就枚举字符做三次卷积即可. #include <bits/stdc++.h> struct Complex ...

  8. 【题解】CF1426E Rock, Paper, Scissors

    题目戳我 \(\text{Solution:}\) 考虑第二问,赢的局数最小,即输和平的局数最多. 考虑网络流,\(1,2,3\)表示\(Alice\)选择的三种可能性,\(4,5,6\)同理. 它们 ...

  9. 题解 CF1426E - Rock, Paper, Scissors

    一眼题. 第一问很简单吧,就是每个 \(\tt Alice\) 能赢的都尽量让他赢. 第二问很简单吧,就是让 \(\tt Alice\) 输的或平局的尽量多,于是跑个网络最大流.\(1 - 3\) 的 ...

随机推荐

  1. 批处理之 for /f 中的delims和tokens

    0x00 前言 今天在对windows进行提权之前的系统信息收集的时候,需要使用到一条批处理语句把特定部分的内容从一个txt的文本当中提取出来:该条语句是如下: for /f "tokens ...

  2. style.attr,currentStyle,getComputedStyle获取元素css

    老朋友object.style.attr 平常我们都是使用object.style.attr的方式来获取元素的属性, 但是这种方法具有很大的局限性——只能获取内联样式, 而下面的两种方法可以获取到元素 ...

  3. 转:c# Linq 的分页[转]

    转:http://www.cnblogs.com/leleroyn/archive/2008/05/14/1196811.html 很多学习Linq的朋友肯定有自己所不同的方法,考虑这个问题我所想到的 ...

  4. JQuery补充——获取与设置表单值

    //写jQuery代码时注意前面一定要记得加$(function(){});,在文档加载完成后进行代码的编写 使用jQuery的表单对象属性来选择被选中的项::checked,详见文档选择器部分 根据 ...

  5. 3Dchart理解

    想在Flex Chart中为图例设置3D效果,近几天查找了些资料,动手做了个DEMO供大家参考!   DEMO演示地址http://xingjunli.webs.com/flash/flexChart ...

  6. 2016-2017-2 《Java程序设计》课程总结 - 20155214

    2016-2017-2 <Java程序设计>课程总结 - 20155214 目录 一.每周学习总结及实验报告链接汇总 二.代码托管 给出statistic.sh的运行结果,说明本学期的代码 ...

  7. Android开发——LinearLayout和RelativeLayout的性能对比

    0. 前言 我们都知道新建一个Android项目自动生成的Xml布局文件的根节点默认是RelativeLayout,这不是IDE默认设置,而是由android-sdk\tools\templates\ ...

  8. 【Todo】找出共同好友 & Spark & Hadoop面试题

    找了这篇文章看了一下面试题<Spark 和hadoop的一些面试题(准备)> http://blog.csdn.net/qiezikuaichuan/article/details/515 ...

  9. Java SE教程

    第0讲 开山篇 读前介绍:本文中如下文本格式是超链接,可以点击跳转 >>超链接<< 我的学习目标:基础要坚如磐石   代码要十份规范   笔记要认真详实 一.java内容介绍 ...

  10. Intellij IDEA 2017 通过scala工程运行wordcount

    首先是安装scala插件,可以通过idea内置的自动安装方式进行,也可以手动下载可用的插件包之后再通过idea导入. scala插件安装完成之后,新建scala项目,右侧使用默认的sbt 点击Next ...