ACM题目

落花闲子 2013-08-03 03:26:51
Description
Today JZ and gugu play Mahjong. but after a moment, they feel bored. So, they want to know given the 13 tiles have, does there exist any tiles that can form a winning state with the 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;

One to nine Sou, which we use 1s to 9s to represent;

One to nine Pin, which we use 1p to 9p to represent;

Character tiles, which are:Ton, Nan, Sei, Pei, Haku, Hatsu, Chun, which we use 1c to 7c to represent.
A winning state means a set of 14 tiles that normally contains a pair of same tiles (which we call "eyes") and four melds. A meld is formed by either three same tiles(1m, 1m, 1m or 2c, 2c, 2c for example) or three continuous non-character tiles(1m, 2m, 3m or 5s, 6s, 7s for example).
However, there are two special winning states that are different with the description above, which are:
"Chii Toitsu", which means 7 different pairs of tiles;
"Kokushi Muso", which means a set of tiles that contains all these tiles: 1m, 9m, 1p, 9p, 1s, 9s and all 7 character tiles. And the rest tile should also be one of the 13 tiles above.
And the game starts with four players receiving 13 tiles. In each round every player must draw one tile from the deck one by one. If he reaches a winning state with these 14 tiles, he can say "Tsu Mo" and win the game. Otherwise he should discard one of his 14 tiles. And if the tile he throws out can form a winning state with the 13 tiles of any other player, the player can say "Ron" and win the game.
Input
The input data begins with a integer T(1≤T≤20000). Next are T cases, each of which contains 13 tiles. The description of every tile is as above.
Output
For each cases, if there actually exists some tiles that can form a winning state with the 13 tiles given, print the number first and then print all those tiles in order as the description order of tiles above. Otherwise print a line "Nooten"(without quotation marks).
Sample Input
2
1s 2s 3s 2c 2c 2c 2p 3p 5m 6m 7m 1p 1p
1p 1p 2p 3p 4s 5s 6s 7c 7c 3s 3s 2m 2m
Sample Output
2 1p 4p
Nooten
...全文
275 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
nice_cxf 2013-08-09
  • 打赏
  • 举报
回复
简单翻译一下: 打麻将会么?不会就不要往下看了 字对应1c to 7c 万对应1m to 9c 饼对应1p to 9c 条对应1t to 9c 不许13不靠,可以胡七对胡13么 给1手牌,输出听什么牌或不听
zhctj159 2013-08-09
  • 打赏
  • 举报
回复
试图去读懂题意,后来我放弃了、、、更不会去看下面冗长的代码了
赵4老师 2013-08-09
  • 打赏
  • 举报
回复
崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处。 判断是否越界访问,可以在数组的最后一个元素之后对应的地址处设置数据读写断点。如果该地址对应其它变量干扰判断,可将数组多声明一个元素,并设置数据读写断点在该多出元素对应的地址上。
赵4老师 2013-08-09
  • 打赏
  • 举报
回复
引用 1 楼 zhctj159 的回复:
英语不好,翻译一下呗
http://translate.google.cn/?hl=zh-cn&tab=wT#
描述
 今天JZ和呱呱打麻将的。但是片刻后,他们觉得无聊。因此,他们想知道的13张牌,不存在任何瓷砖与瓷砖,可以形成一个成功的状态。
 麻将牌一组包含四个副本的瓷砖,下面介绍:

 一到九人,我们用1米至900万代表;

 一到九叟,我们用1s到9来表示;

 一到九针,我们用1便士到九段代表;

 字符砖,它们分别是:吨,南,SEI,裴,哈库,荣升,春,我们用1C 7C代表。
 获奖的状态是指一组14张牌,通常包含一对相同的牌(我们称之为“眼睛”)和四个融合。无论是三个相同的牌(1M,1M,1M或2C,2C,2C例如)或连续三的非字符砖(1M,2M,3M或例如5S,6S,7S)是由个人的MELD。
 但是,也有两个特别奖的状态与以上描述不同,它们是:
 “绮Toitsu”的,这意味着7对不同的瓷砖;
 “梦窗国师”,这意味着一组的瓷砖,包含所有这些瓷砖:1米,9米,1P,九段,1S,9S所有7个字符瓷砖的。和其余瓷砖也应在上述13张牌之一。
 而本场比赛开始接收13张牌的四名球员。在每一轮,每个球员都必须从甲板上一画一瓦一。如果他达到一个成功的状态,这14张牌,他可以说“津市莫”,赢得了比赛。否则,他应该放弃他的14张牌之一。任何其他球员的13张牌,如果他抛出的瓷砖可以形成一个成功的状态,玩家可以说“罗恩”,赢得了比赛。
 输入
 输入的数据开始的一个整数T(1≤T≤20000)。接下来是T的情况下,每个都包含13张牌。每瓦的描述如上。
 产量
 对于每一种情况下,如果确实存在一些瓷砖13张牌,可以形成一个成功的状态,首先打印的数量,然后打印了所有的瓷砖在瓷砖上面的描述顺序。否则打印线的“Nooten”(不带引号)。
 采样输入
 2
 1秒2秒3秒2C 2C 2C 2P 3P 5米月67米1P 1P
 1P 1P 2P 3P 4S 5S 6S 7C 7C 3S 3S 3219米2米
 样本输出
 2 1P 4P
 Nooten撤消修改Alpha
此翻译比原来的更好?是,提交翻译感谢您提交的内容。
Miáoshù
  Jīntiān JZ hé guāguā dǎ májiàng de. Dànshì piànkè hòu, tāmen jué dé wúliáo. Yīncǐ, tāmen xiǎng zhīdào de 13 zhāng pái, bù cúnzài rènhé cízhuān yǔ cízhuān, kěyǐ xíngchéng yīgè chénggōng de zhuàngtài.
  Májiàng pái yī zǔ bāohán sì gè fùběn de cízhuān, xiàmiàn jièshào:

  Yī dào jiǔ rén, wǒmen yòng 1 mǐ zhì 900 wàn dàibiǎo;

  Yī dào jiǔ sǒu, wǒmen yòng 1s dào 9 lái biǎoshì;

  Yī dào jiǔ zhēn, wǒmen yòng 1 biànshì dào jiǔduàn dàibiǎo;

  Zìfú zhuān, tāmen fēnbié shì: Dūn, nán,SEI, péi, hā kù, róng shēng, chūn, wǒmen yòng 1C 7C dàibiǎo.
  Huòjiǎng de zhuàngtài shì zhǐ yī zǔ 14 zhāng pái, tōngcháng bāohán yī duì xiāngtóng de pái (wǒmen chēng zhī wèi “yǎnjīng”) hé sì gè rónghé. Wúlùn shì sān gè xiāngtóng de pái (1M,1M,1M huò 2C,2C,2C lìrú) huò liánxù sān de fēi zìfú zhuān (1M,2M,3M huò lìrú 5S,6S,7S) shì yóu gèrén de MELD.
  Dànshì, yěyǒu liǎng gè tèbié jiǎng de zhuàngtài yǔ yǐshàng miáoshù bùtóng, tāmen shì:
  “Qǐ Toitsu” de, zhè yìwèizhe 7 duì bùtóng de cízhuān;
  “Mèng chuāng guó shī”, zhè yìwèizhe yī zǔ de cízhuān, bāohán suǒyǒu zhèxiē cízhuān:1 Mǐ,9 mǐ,1P, jiǔduàn,1S,9S suǒyǒu 7 gè zìfú cízhuān de. Hé qíyú cízhuān yě yīng zài shàngshù 13 zhāng pái zhī yī.
  Ér běn chǎng bǐsài kāishǐ jiēshōu 13 zhāng pái de sì míng qiúyuán. Zài měi yī lún, měi gè qiúyuán dōu bìxū cóng jiǎbǎn shàng yī huà yī wǎ yī. Rúguǒ tā dádào yīgè chénggōng de zhuàngtài, zhè 14 zhāng pái, tā kěyǐ shuō “jīn shì mò”, yíngdéle bǐsài. Fǒuzé, tā yīnggāi fàngqì tā de 14 zhāng pái zhī yī. Rènhé qítā qiúyuán de 13 zhāng pái, rúguǒ tā pāo chū de cízhuān kěyǐ xíngchéng yīgè chénggōng de zhuàngtài, wánjiā kěyǐ shuō “luō ēn”, yíngdéle bǐsài.
  Shūrù
  Shūrù de shùjù kāishǐ de yīgè zhěngshù T(1≤T≤20000). Jiē xiàlái shì T de qíngkuàng xià, měi gè dōu bāohán 13 zhāng pái. Měi wǎ de miáoshù rúshàng.
  Chǎnliàng
  Duìyú měi yī zhǒng qíngkuàng xià, rúguǒ quèshí cúnzài yīxiē cízhuān 13 zhāng pái, kěyǐ xíngchéng yīgè chénggōng de zhuàngtài, shǒuxiān dǎyìn de shùliàng, ránhòu dǎyìnle suǒyǒu de cízhuān zài cízhuān shàngmiàn de miáoshù shùnxù. Fǒuzé dǎyìn xiàn de “Nooten”(bù dài yǐnhào).
  Cǎiyàng shūrù
  2
  1 Miǎo 2 miǎo 3 miǎo 2C 2C 2C 2P 3P 5 mǐ yuè 67 mǐ 1P 1P
  1P 1P 2P 3P 4S 5S 6S 7C 7C 3S 3S 3219 mǐ 2 mǐ
  Yàngběn shūchū
  2 1P 4P
  Nooten
“”的用法示例:由 Google 自动翻译
字典Would you mind answering some questions to help improve translation quality?
Google 翻译(企业版):译者工具包网站翻译器全球商机洞察将文件或链接拖放到此处以翻译文档或网页。
将链接拖放到此处以翻译网页。
我们不支持您拖放的文件类型,请尝试其他文件类型。
我们不支持您拖放的链接类型,请尝试其他类型的链接。
关闭即时翻译关于 Google 翻译移动隐私权政策帮助发送反馈
点击可修改和查看其他翻译
按住 Shift 键的同时拖动短语即可重新排序。
JockeyDarcy 2013-08-09
  • 打赏
  • 举报
回复
求翻译 这么长英语
_暮落_ 2013-08-09
  • 打赏
  • 举报
回复
儿啦吧唧的.
max_min_ 2013-08-04
  • 打赏
  • 举报
回复


把你不明白 有问题的地方贴出来嘛, 你这样太多 ,
又没有代码格式,很难看的
落花闲子 2013-08-04
  • 打赏
  • 举报
回复
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; const int M=34; char ch[35][5]={"1m","2m","3m","4m","5m","6m","7m","8m","9m", "1s","2s","3s","4s","5s","6s","7s","8s","9s", "1p","2p","3p","4p","5p","6p","7p","8p","9p", "1c","2c","3c","4c","5c","6c","7c"}; char s[15][5]; int num[35]; int cnt[35]; int tot; int ans[35]; bool Cal_1(){ int ret=0; int i,j,k; for(i=0;i<M;i++){ if(num[i]<2)continue; for(j=0;j<M;j++) if(i==j) cnt[j]=num[j]-2; else cnt[j]=num[j]; int flag=0; for(j=0;j<M;j++){ if(j<27){ if(cnt[j]<=2){ int tp=cnt[j]; if(j+2<27 && cnt[j+1]>=tp && cnt[j+2]>=tp && j/9==(j+2)/9){ cnt[j+1]-=tp; cnt[j+2]-=tp; cnt[j]=0; flag+=tp; } }else if(cnt[j]==3){ cnt[j]=0; flag++; }else if(cnt[j]==4){ cnt[j]-=3; flag++; j--; } }else{ if(cnt[j]>=3) flag++; } } if(flag==4){ ret=1; break; } } return ret; } bool Cal_2(){ int ret=0; for(int i=0;i<M;i++) if(num[i]==2) ret++; return ret==7; } int g[15]={0,8,9,17,18,26,27,28,29,30,31,32,33}; bool Cal_3(){ int ret=0; for(int i=0;i<13;i++){ if(num[g[i]]==0) return 0; ret+=num[g[i]]; } return ret==14; } int main(){ int T; int i,j; scanf("%d",&T); while(T--){ memset(num,0,sizeof(num)); for(i=0;i<13;i++){ scanf("%s",s[i]); for(j=0;j<M;j++) if(strcmp(s[i],ch[j])==0) num[j]++; } tot=0; for(i=0;i<M;i++){ if(num[i]>=4)continue; num[i]++; if(Cal_2()){ ans[tot++]=i; }else if(Cal_3()){ ans[tot++]=i; }else if(Cal_1()){ ans[tot++]=i; } num[i]--; } if(tot==0) puts("Nooten"); else{ printf("%d",tot); for(i=0;i<tot;i++) printf(" %s",ch[ans[i]]); puts(""); } } return 0; }
落花闲子 2013-08-03
  • 打赏
  • 举报
回复
帮忙看看,是wa啊!一直
落花闲子 2013-08-03
  • 打赏
  • 举报
回复
#include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; int a[35]; bool qk4X3() { int s=0,tmp[35]; for(int i=0;i<34;i++) tmp[i]=a[i]; for(i=0;i<=18;i+=9) for(int j=0;j<9;j++) { if(tmp[i+j]>=3) { tmp[i+j]-=3; s++; } while(j+2<9&&tmp[i+j]&&tmp[i+j+1]&&tmp[i+j+2]) { tmp[i+j]--; tmp[i+j+1]--; tmp[i+j+2]--; s++; } } for(int j=0;j<7;j++) { if(tmp[27+j]>=3) { tmp[27+j]-=3; s++; } } if(s==4) return true; return false; } bool qk1() { for(int i=0;i<34;i++) { if(a[i]>=2) { a[i]-=2; if(qk4X3()) { a[i]+=2; return true; } a[i]+=2; } } return false; } bool qk2() { for(int i=0;i<34;i++) { if(a[i]!=2 && a[i]!=0) return false; } return true; } bool qk3() { for(int j=0;j<7;j++) if(a[j+27]==0) return false; for(int i=0;i<=18;i+=9) { if(a[i]==0 || a[i+8]==0)return false; for(int j=1;j<8;j++) if(a[i+j]!=0) return false; } return true; } bool qk() { if(qk1() || qk2() || qk3()) return true; return false; } int main() { int t; char str[10]; scanf("%d",&t); int ans[35],tol; while(t--) { memset(a,0,sizeof(a)); for(int i=0;i<13;i++) { scanf("%s",&str); int t=str[0]-'1'; if(str[1]=='m') t+=0; else if(str[1]=='s') t+=9; else if(str[1]=='p') t+=18; else t+=27; a[t]++; } tol=0; for(i=0;i<34;i++) { a[i]++; if(a[i]<=4 && qk()) ans[tol++]=i; a[i]--; } if(tol==0) printf("Nooten\n"); else { printf("%d",tol); for(int i=0;i<tol;i++) { printf(" %d",(ans[i]%9)+1); if(ans[i]/9==0) printf("m"); else if(ans[i]/9==1) printf("s"); else if(ans[i]/9==2) printf("p"); else printf("c"); } printf("\n"); } } return 0; }
zhctj159 2013-08-03
  • 打赏
  • 举报
回复
英语不好,翻译一下呗

69,381

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧