简单模拟题(NWERC 2017Dunglish)

前言:

做题的时候脑抽,想记录每个单词的所有正确翻译,但是根本不需要呀,只要统计个数即可。

收获:

  1. map用法有时候有点迷
  2. 读string类型空格是不能读的,总是不太记得清
  3. 与其统计个数,不如边遍历边乘。
#include<bits/stdc++.h>
using namespace std;
const int N=25;
map<string,int> cor,inc;
map<string,string> match;
string s[25];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>s[i];
    int m;
    cin>>m;
    while(m--)
    {
        string a,b,c;
        cin>>a>>b>>c;
        match[a]=b;
        if(c[0]=='c')
            cor[a]++;
        else
            inc[a]++;
    }
    int tot=1,cnt=1;//tot表示总可能数,cnt为正确数
    for(int i=1;i<=n;++i) //与其提前统计个数,不如边循环边乘
    {
        tot*=cor[s[i]]+inc[s[i]];
        cnt*=cor[s[i]];
    }
    if(tot==1)
    {
        for(int i=1;i<=n;++i)
            cout<<match[s[i]]<<' '<<endl;
        cout<<endl;
        if(cnt==tot)
            cout<<"correct"<<endl;
        else
            cout<<"incorrect"<<endl;
    }
    else
    {
        cout<<cnt<<' '<<"correct"<<endl;
        cout<<tot-cnt<<' '<<"incorrect"<<endl;
    }
    return 0;
}

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值