HDU 2164(模拟)

Rock, Paper, or Scissors?

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2927    Accepted Submission(s): 1873

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 <iostream>
#include<cstdio>
using namespace std;

int main()
{
    int t;
    int n;
    char c1,c2;
    int s1,s2;
    scanf("%d",&t);
    while(t--)
    {
        s1=s2=0;//!!注意初始化位置
        scanf("%d",&n);
        getchar();//
        while(n--)
        {
            scanf("%c %c",&c1,&c2);
            getchar();//
            if(c1==c2) continue;
            else if(c1==‘R‘&&c2==‘S‘||c1==‘S‘&&c2==‘P‘||c1==‘P‘&&c2==‘R‘)
            {
                s1++;
            }
            else
                s2++;
        }
            if(s1==s2) printf("TIE\n");
            else if(s1>s2)  printf("Player 1\n");
            else  printf("Player 2\n");
    }
    return 0;
}

  

时间: 2024-12-22 20:05:29

HDU 2164(模拟)的相关文章

HDU 4930 模拟

Fighting the Landlords Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 266    Accepted Submission(s): 87 Problem Description Fighting the Landlords is a card game which has been a heat for yea

HDU 2164 Rock, Paper, or Scissors?

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 o

hdu 1022 模拟栈

其实就是模拟一下栈啦. 1 #include <iostream> 2 using namespace std; 3 4 const int N = 10; 5 char o1[N]; 6 char o2[N]; 7 char s[N]; 8 int ans[N * 2]; 9 10 int main () 11 { 12 int n; 13 while ( cin >> n ) 14 { 15 cin >> o1 >> o2; 16 int top = 0

hdu 4054 模拟 练习十六进制输出

http://acm.hdu.edu.cn/showproblem.php?pid=4054 貌似一般区域赛都会有一道水题 这道题PE了一次  因为输出每个数其实是两个位 如果用空格补齐的话  应该用两个空格 我用了一个空格,,, 学到: 1.%x  十六进制输出  可以输出整型,字符型等等 2.%02x  保证两位 而且会输出先导0的两位 //#pragma comment(linker, "/STACK:102400000,102400000") #include <cstd

hdu 5246(模拟)

题解:直接模拟 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; const int N = 10005; long long n, m, k; long long s[N]; int main() { int t, cas = 1; scanf("%d", &t); while (t--) { scanf("%lld%l

hdu 5386 模拟

想明白以后会发现其实就是模拟... 因为每次只能给一整行或者一整列赋值,所以目标矩阵一开始一定有一行或者一列上数字都是相同的,然后找到对应的操作,把那一行或者那一列标记为访问过.然后新的矩阵也一定能找到一行或者一列数字都相同,再找到相应的操作,标记那一行或者那一列,依次类推,然后没有用到的操作随便找个顺序就好了.其实初始矩阵并没有什么用...... 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio>

HDU 5071 模拟

考察英语的题 - -# 按条件模拟,一遍就行了,每个聊天对象有其价值U,数组模拟队列过程即可,若存在Top标记,则和Top标记的人聊天,否则和队列的第一个人聊天 mark记录队尾,top记录Top操作,data[i].p记录U,data[i].x记录chat数,data[i].y记录该人是否被删除 Add U:在 队尾插入价值为U的人,需要特判U人已经存在 Close U::在整个队列中查找价值为U的人,将其删除,需要特判该人不存在 Chat x:当前聊天页面的人chat+=x,特判当前队列没有

HDU 2860 (模拟+并查集)

Regroup Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1057    Accepted Submission(s): 297 Problem Description When ALPC42 got to a panzer brigade, He was asked to build software to help them r

hdu 5373 模拟

简单模拟题,可以利用一下能被11整除的数的特点:奇数位的数字和与偶数位的数字和之差能被11整除. 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 using namespace std; 6 7 const int N = 1000000; 8 int s[N]; 9 int mid[N]; 10 11 int main () 12 {