Rock-Paper-Scissors Tournament
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2178 Accepted Submission(s): 693

Problem Description
Rock-Paper-Scissors is game for two players, A and B, who each choose, independently of the other, one of rock, paper, or scissors. A player chosing paper wins over a player chosing rock; a player chosing scissors wins over a player chosing paper; a player chosing rock wins over a player chosing scissors. A player chosing the same thing as the other player neither wins nor loses.
A tournament has been organized in which each of n players plays k rock-scissors-paper games with each of the other players - k games in total. Your job is to compute the win average for each player, defined as w / (w + l) where w is the number of games won, and l is the number of games lost, by the player.

Input
Input consists of several test cases. The first line of input for each case contains 1 ≤ n ≤ 100 1 ≤ k ≤ 100 as defined above. For each game, a line follows containing p1, m1, p2, m2. 1 ≤ p1 ≤ n and 1 ≤ p2 ≤ n are distinct integers identifying two players; m1 and m2 are their respective moves ("rock", "scissors", or "paper"). A line containing 0 follows the last test case.

Output
Output one line each for player 1, player 2, and so on, through player n, giving the player's win average rounded to three decimal places. If the win average is undefined, output "-". Output an empty line between cases.

Sample Input
2 4
1 rock 2 paper
1 scissors 2 paper
1 rock 2 rock
2 rock 1 scissors
2 1
1 rock 2 paper
0

Sample Output
0.333
0.667

0.000
1.000

#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<fstream>
#include<sstream>
#include<iomanip>
#include <sstream>
using namespace std; const int N=; int player[N][]; // player[i][0]: win , player[i][1]: lose. int n,k;
short judge(string a, string b)
{
if(a == b)
{
return ;
}
short result;
if(a == "rock")
{
if(b == "scissors")
{
result = ;
}
else if(b == "paper")
{
result = -;
}
}
else if(a == "scissors")
{
if(b == "rock")
{
result = -;
}
else if(b == "paper")
{
result = ;
}
}
else
{
if(b == "scissors")
{
result = -;
}
else if(b == "rock")
{
result = ;
}
}
return result;
}
int main()
{
short ans;
string sa,sb;
int pa,pb;
bool first = true;
while(cin>>n && n)
{
if(!first)putchar('\n');
if(first)first=false;
memset(player,,sizeof(player));
cin>>k;
while(k--)
{
cin>>pa>>sa>>pb>>sb;
ans = judge(sa,sb);
if(ans)
{
if(ans==)//win
{
player[pa][]++;
player[pb][]++;
}
else//lose
{
player[pb][]++;
player[pa][]++;
}
}
}
for(int i=; i<=n; i++)
{
int total = player[i][]+player[i][];
if(total>)
{
printf("%.3f\n",((float)player[i][])/total);
}
else
{
printf("-\n");
}
}
}
return ;
}

Rock-Paper-Scissors Tournament[HDU1148]的更多相关文章

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

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

  2. SDUT 3568 Rock Paper Scissors 状压统计

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

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

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

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

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

  5. Gym101667 H. Rock Paper Scissors

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

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

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

  7. 题解 CF1426E - Rock, Paper, Scissors

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

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

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

  9. HDU 2164 Rock, Paper, or Scissors?

    http://acm.hdu.edu.cn/showproblem.php?pid=2164 Problem Description Rock, Paper, Scissors is a two pl ...

  10. 1090-Rock, Paper, Scissors

    描述 Rock, Paper, Scissors is a classic hand game for two people. Each participant holds out either a ...

随机推荐

  1. 使用xib需要记得的小问题

    1. 图片 加载 图片上的label 不显示, 最后是因为xib 里位置动了 图片跑到最上层盖住了labe 2. 加载xib 有时候会崩 或加载不出来  先查看xib 是否有多余控件 3. 查看关联 ...

  2. [转]c++ vector 遍历方式

    挺有趣的,转来记录 随着C++11标准的出现,C++标准添加了许多有用的特性,C++代码的写法也有比较多的变化.   vector是经常要使用到的std组件,对于vector的遍历,本文罗列了若干种写 ...

  3. 20145206邹京儒《Java程序设计》第8周学习总结

    20145206 <Java程序设计>第8周学习总结 教材学习内容总结 第十四章 NIO与NIO2 14.1 认识NIO NIO使用频道(Channel)来衔接数据节点,在处理数据时,NI ...

  4. APP测试流程(个人整理)

  5. CI重定向:php(codeigniter)中如何重定向

    Q: 在保存完数据之后需要重定向,防止数据重复提交. 我使用$this->方法名();跳转,发现不能达到重定向的效果(地址栏没变) 请教高手重定向怎么用 A: $this->load-&g ...

  6. jQuery插件:跨浏览器复制jQuery-zclip(转载)

    转载地址:http://www.cnblogs.com/linjiqin/p/3532451.html jQuery-zclip是一个复制内容到剪贴板的jQuery插件,使用它我们不用考虑不同浏览器和 ...

  7. 如何在java中使用别人提供的jar包进行导入,编译,运行

    一步一步往前走, 现在折分! JAR包即为上篇文章的东东. 测试JAVA文件. package com.security; import com.security.AESencrp; /** * 实现 ...

  8. 莫队算法 2038: [2009国家集训队]小Z的袜子(hose)

    链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2038 2038: [2009国家集训队]小Z的袜子(hose) Time Limit: 20 ...

  9. SimpleHashTable

    简单的Hash Table 实现,下次被问到,至少不是从0开始.不过笔试问这个毕竟不多. public struct Item<K, V> { public K Key { get; se ...

  10. 数据结构之图 Part3 – 2 遍历

    BFS using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...