A1116 Come on! Let‘s C [map]

在这里插入图片描述

#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn = 100001;
int a[maxn];
map<string, int>m;
map<string, bool>e;
bool isprime(int x)
{
	if (x <= 1)
		return false;
	for (int i = 2; i <= sqrt(x); i++)
	{
		if (x % i == 0)
			return false;
	}
	return true;
}
int main()
{
	int n,q; string s;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> s;
		m[s] = i;
		e[s] = true;
	}
	cin >> q;
	for (int i = 1; i <= q; i++)
	{
		cin >> s;
		auto j = m.find(s);
		if (j!=m.end()&&m[s] == 1)
		{
			if (e[s])
			{
				cout << s << ":" << " " << "Mystery Award" << endl;
				e[s] = false;
			}
			else
				cout << s << ":" << " " << "Checked" << endl;
		}
		else if (j != m.end() && isprime(m[s]))
		{
			if (e[s])
			{
				cout << s << ":" << " " << "Minion" << endl;
				e[s] = false;
			}
			else
				cout << s << ":" << " " << "Checked" << endl;
		}
		else if(j != m.end())
		{
			if (e[s])
			{
				cout << s << ":" << " " << "Chocolate" << endl;
				e[s] = false;
			}
			else
				cout << s << ":" << " " << "Checked" << endl;
		}
		else
		{
			cout << s << ":" << " " << "Are you kidding?" << endl;
		}
	}
}
posted @ 2020-08-10 11:03  _Hsiung  阅读(53)  评论(0编辑  收藏  举报