ZOJ 3671 Japanese Mahjong III

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3671

Japanese Mahjong III


Time Limit: 2 Seconds      Memory Limit: 65536 KB



Mahjong is a game of skill, strategy and calculation and involves a certain degree of chance. In this problem, we concentrate on Japanese Mahjong, a variation of mahjong.
For brief, all of the word mahjong mentioned following refer to Japanese Mahjong.

Japanese mahjong is usually played with 136 tiles, which can be organized into several categories:

  • Suited tiles. All suited tiles are of a rank and a suit.There are three suits of tiles, with ranks ranging from one to nine. There are four tiles of each rank and suit combination, thus there are 36 tiles in a suit, and 108 suited tiles in total.

    • The circle suit

    • The bamboo suit

    • The character suit

  • Honor tiles. Honor Tiles are tiles that do not have a rank or suit. They are divided into two categories. There are four types of Wind tiles and three types of Dragon tiles, with four of each type of honor tile. Thus, there are 16 wind tiles and
    12 Dragon tiles for 28 honor tiles.

    • Wind tiles. The Wind tiles consist of four kinds of tile: EastSouthWest, and North.

    • Dragon tiles. The Dragon titles consist of three types of tile: RedGreenWhite.

In this problem, we introduce two abnormal kinds of winning hand different from the normal winning hand, which consist of four melds and one eyes.

  1. Seven Pairs: the hand consists of seven different pairs. No two pairs are the same. For example:
  2. Thirteen Orphans: the hand consists of thirteen kinds of tiles: Circle One, Circle Nine, Bamboo One, Bamboo Nine, Character One, Character Nine, East, South, West, North, Red, Green and White. Only one kind of them are two tiles,
    while the others are all only one tile. For example:

Now, given a hand with 14 tiles, can you answer this hand is which kind of abnormal kind of winning hand?

Input

There are multiple cases. Each case consists of 28 characters in one line, describing 14 tiles. The manner for describing each type of tile is:

  • Two characters stand for one tile.
  • For Suited tiles, the first is a integer ranged from one to nine, the tile‘s rank, and the second is a character: ‘p‘ for the circle suit, ‘s‘ for the bamboo suit, and ‘m‘ for the charactersuit.
  • For Honor tiles, the first is a integer: from one to seven stands for EastSouthWestNorthWhiteGreen, and Red respectively. The second one is always ‘z‘.

We promise that the input is a legal hand, which means there isn‘t another type of tiles described above or there are more than four same tiles.

Output

For each case, if the hand is Seven Pairs, output "Seven Pairs". If the hand is Thirteen Orphans, output "Thirteen Orphans". If the hand is neither Seven Pairs nor Thirteen
Orphans
, output "Neither!".

Sample Input

1z1z2z2z3z3z4z4z5z5z6z6z7z7z
1s9s1m9m1p9p1z2z3z4z5z6z7z7z
1s9s1m9m1p9p1z2z3z4z5z6z7z7p

Sample Output

Seven Pairs
Thirteen Orphans
Neither!

Author: YU, Xiaoyao

Contest: ZOJ Monthly, November 2012

Submit    Status

一道简单的模拟题。我们可以用一个二维数组 a[i][j] 来记录状态。a[0][j] 表示 jp  a[1][j]表示 js, a[2][j] 表示 jm ,a[3][j] 表示 jz 。

#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<cstdlib>
#include<map>
using namespace std;
#define CLR(A) memset(A,0,sizeof(A))
const int MAX=50;
int a[10][10];
char str[MAX];
int main(){
    while(~scanf("%s",str)){
        CLR(a);int len=strlen(str);
        for(int i=0;i<len-1;i++){
            if(str[i+1]=='p') a[0][str[i]-'0']++;
            if(str[i+1]=='s') a[1][str[i]-'0']++;
            if(str[i+1]=='m') a[2][str[i]-'0']++;
            if(str[i+1]=='z') a[3][str[i]-'0']++;
        }
        bool flag=0;
        for(int i=0;i<4;i++){
            for(int j=1;j<10;j++){
                if(a[i][j]&&a[i][j]!=2){
                    flag=1;break;
                }
            }
            if(flag) break;
        }
        if(!flag) cout<<"Seven Pairs"<<endl;
        else{
            if(a[0][1]&&a[0][9]&&a[1][1]&&a[1][9]&&a[2][1]&&a[2][9]&&a[3][1]&&a[3][2]&&a[3][3]&&a[3][4]&&a[3][5]&&a[3][6]&&a[3][7]){
                if(a[0][1]==2||a[0][9]==2||a[1][1]==2||a[1][9]==2||a[2][1]==2||a[2][9]==2||a[3][1]==2||a[3][2]==2||a[3][3]==2||a[3][4]==2||a[3][5]==2||a[3][6]==2||a[3][7]==2){
                    cout<<"Thirteen Orphans"<<endl;
                }
                else cout<<"Neither!"<<endl;
            }
            else cout<<"Neither!"<<endl;
        }
    }
    return 0;
}
时间: 2024-10-14 00:19:06

ZOJ 3671 Japanese Mahjong III的相关文章

ZOJ3671:Japanese Mahjong III

Mahjong is a game of skill, strategy and calculation and involves a certain degree of chance. In this problem, we concentrate on Japanese Mahjong, a variation of mahjong. For brief, all of the word mahjong mentioned following refer to Japanese Mahjon

zoj 3669 Japanese Mahjong I

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3669 题目大意:就是给你一副牌,问你胡牌的方式有几种,并输出方式..... 思路:因为一副牌的数量不多,所以可以直接枚举每一张牌,判断加上这张牌后能否胡牌... code: #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #incl

ZOJ3669:Japanese Mahjong I

Mahjong is a game of skill, strategy and calculation and involves a certain degree of chance. In this problem, we concentrate on Japanese Mahjong, a variation of mahjong. For brief, all of the word mahjong mentioned following refer to Japanese Mahjon

ZOJ 3575 Under Attack III

Under Attack III Time Limit: 7 Seconds      Memory Limit: 65536 KB Due to the successful resist in Under Attack II, the enemy lost most of their bombers and our ground forces are advancing for victory. However, our spy has transmitted a shocking inte

ZOJ Monthly, November 2012

A.ZOJ 3666 Alice and Bob 组合博弈,SG函数应用 #include<vector> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn = 10000 + 100; int SG[maxn]; vector<int> g[maxn]; int mex(int u) { //minimal exc

HDU 4431 Mahjong (麻将、神坑模拟题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4431 题面: Mahjong Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4219    Accepted Submission(s): 842 Problem Description Japanese Mahjong is a fou

HDU-4431 麻将

Japanese Mahjong is a four-player game. The game needs four people to sit around a desk and play with a set of Mahjong tiles. A set of Mahjong tiles contains four copies of the tiles described next: One to nine Man, which we use 1m to 9m to represent

[dp] zoj 3769 Diablo III

题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3769 Diablo III Time Limit: 2 Seconds      Memory Limit: 65536 KB Diablo III is an action role-playing video game. A few days ago, Reaper of Souls (ROS), the new expansion of Diablo I

Zoj 3616 Choir III 【有想法的暴力】【容斥】

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3616 题目大意:给出n, m, b, g (0 < n <= 100, 0 < m <= 2000, 0 < b, g <= m * n)这些数字,下面n行,每一行有2*m个数字,第一个数字表示一个同学对于合唱的贡献,第二个数字表示同学的性别,b和g表示在一个矩形内至少有的男生和女生的数量.求一个矩形使得这个矩形内的对合唱的贡献值最大并