第46屆ICPC亚洲区域赛(昆明热身赛) Letterle

信使

时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64 位 IO 格式: %lld

题目描述

通过给用户最多七个猜测来玩新游戏,以找出一个字母(发音:letter-el)。字母由五个字母(A-Z)组成,按特定顺序排列。每次猜测后,都会向用户提供有关其猜测正确性的反馈。反馈以五个字母的字符串形式提供,仅包含以下字母:X、Y 和 G。
X = 此位置的字母不出现在字母中
Y = 此位置的字母出现在字母中,但它不在正确的位置
G = 字母在这个位置是正确的(好)。
对于此问题,您将编写一个程序,该程序为提供的 letterle 生成最多七个猜测的反馈。

输入描述:

The first line of input contains a five character string of capital letters (A-Z) that are the letterle. The next seven lines contain guesses that the program must evaluate and generate feedback for the user. 

输出描述:

Output consists of one or more lines. For each guess, if the guess is correct, the output line is WINNER and the program should not process any more input. If the guess is incorrect, and this is the seventh guess, the output line is “LOSER”. Otherwise, the output line is a five character string where each position has one of X, Y or G (as described above). First, any position that a letter is correct, should have a G. Then, any position where a letter is not in the letterle, should contain an X. The remaining positions should contain a Y indicating the letter is correct, but in the wrong position.
示例1

输入

复制
LIMIT
ABCDE
FGHIJ
KLMNO
PQRST
LIMIT
LEMET
LAMET

输出

复制
XXXXX
XXXGX
XYGXX
XXXXG
WINNER
#include<bits/stdc++.h>
using namespace std;
int character[29];
string s,t;

int main(){
	cin>>s;
	for(int i=0;i<5;i++)
		character[s[i]-'A']=1;
	for(int i=1;i<=7;i++){
		cin>>t;
		if(s==t) return cout<<"WINNER",0;
		if(i==7) return cout<<"LOSER",0;
		for(int i=0;i<5;i++){
			if(s[i]==t[i]) cout<<'G';
			else if(character[t[i]-'A']) cout<<'Y';
			else cout<<'X';
		}
		cout<<endl;
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

热血少年鸡小龙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值