[Luo Gu] P5601 D with a small pen questions solution

Topic background

D is a small man who will participate in the IO ION players, however, the written exam in the myriad of strange title made him a big headache, come help him!

Title Description

Written exam can be abstracted as \ (n \) item questionnaire that face each question of the questions and answers composition, is a string, to ensure that all surfaces differ topic title.

To test the effect of small D written back, the coach made a mock exam, exam contains \ (q \) item questionnaire that each question has a \ (4 \) option, a small D needs from the \ (4 \) options selected the option that coincides answer.

Now you need to help small D to complete the exam.

Input Format

The first line of two positive integers \ (n-, Q \) .

Next \ (n-\) rows, each row \ (2 \) , separated by a space string representing object of this question and answers questions surface.

Next \ (Q \) rows, each row \ (5 \) , separated by a space character string, the first string showing simulated test questions in this question object surface, the remaining \ (4 \) string by This question object sequence are options options A to D, to ensure that different options.

Output Format

For exams in each question, the output of a character representation corresponding options This question is the answer to ensure that all the problems have solution.

Sample

Entry

3 4
decoak yes
duliuchutiren nonono
csps noiptg
decoak yes no qwq qaq
csps noiptg noippj noi cspj
decoak qwq qaq yesyes yes
duliuchutiren yes no nono nonono

Export

A
A
D
D

text

I am committed to write konjac (like me) can understand the problem solution.


analysis

Simulation, emergent, everyone can do.

method

Pure analog, while being read to lose Dafa is good.

Code

#include<bits/stdc++.h>
int n,q;
struct an{
    std::string at;//题面
    std::string aa;//答案
}tm[105];//背的题面和答案。
struct zz{
    std::string t;//题面
    std::string a[5];//选项
}da[105];
char anssc[5]={'1','A','B','C','D'};//直接输出,免得乱搞。
int main()
{
    //freopen("in.txt","r",stdin);//测试专用
    //freopen("out.txt","w",stdout);
    std::cin>>n>>q;//读入
    for(int i=1;i<=n;i++)
    {
        std::cin>>tm[i].at>>tm[i].aa;
    }
    for(int i=1;i<=q;i++)
    {
        std::cin>>da[i].t;
        int cache=0;//临时存储数据
        for(int j=1;j<=n;j++)
        {
            if(da[i].t==tm[j].at)//找相同的题面
                cache=j;
        }
        for(int j=1;j<=4;j++)
        {
            std::cin>>da[i].a[j];
            if(da[i].a[j]==tm[cache].aa)//找答案
            {
                std::cout<<anssc[j]<<"\n";//记得回车
            }
        }
    }
    return 0;
 } 

Guess you like

Origin www.cnblogs.com/wasonliu/p/11758356.html