UVA 340 - Master-Mind Hints 简单题 题面难看

讲真,第一遍读下来不知道在讲个什么东西

大致就是有一个二人的game,一个designer和一个player,player可以guess很多次,每guess一次designer会给一个hint,任务就是要你输出每一次的hint

好吧,至于题目给了两个matches的independent的定义,以及一个集合independent的定义,这里我没怎么看懂

关键的句就是input的上面那一段的第二行“The hint then consists of the number of strong followedby the number of weak matches in M.”

这不就出来了么,hint是有strong和weak matches组成的,strong和weak的定义上面写的很清楚,以及strong强于weak

一看样例全都懂了

(第一次说话夹这么多洋字,hhhhhhhhhh。这一次分析题目有一种高中阅读理解的感觉,hhhhhhhh)

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int n,arr[1010],guess[1010],te,a,b,ca,origin[10],corigin[10],gue[10];

int main(){
    ios_base::sync_with_stdio(false);
    while(cin>>n&&n){
        cout<<"Game "<<++ca<<":\n";
        for(int i=0;i<n;++i)
            cin>>arr[i],origin[arr[i]]++;
        while(true){
            for(int i=0;i<n;++i)
                cin>>guess[i],te+=guess[i],++gue[guess[i]];
            if(!te)break;
            for(int i=0;i<10;++i)
                corigin[i]=origin[i];

            for(int i=0;i<n;++i)
            if(arr[i]==guess[i])
                ++a,--corigin[arr[i]],--gue[arr[i]];

            for(int i=0;i<10;++i)
                b+=min(corigin[i],gue[i]);

            cout<<"    ("<<a<<','<<b<<")\n";
            memset(gue,0,sizeof gue);
            a=b=te=0;
        }
        memset(origin,0,sizeof origin);
        memset(gue,0,sizeof gue);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值