CoderFroces ~ 987A ~ Infinity Gauntlet (水,map)

题意:有六种颜色宝石,每种宝石对应一种能力。你现在已经有N个颜色宝石了,问你还缺少哪几个能力的宝石?


思路:用map颜色映射一下能力,暴力查找看缺少哪几个。


#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
map<string, string> mp;
set<string> s;
string ans[10];
int main()
{
    mp["purple"] = "Power"; mp["green"] = "Time"; mp["blue"] = "Space";
    mp["orange"] = "Soul"; mp["red"] = "Reality"; mp["yellow"] = "Mind";
    int n; scanf("%d", &n);
    string str;
    for (int i = 0; i < n; i++) cin >> str, s.insert(str);
    int cnt = 0;
    for (auto i: mp)
    {
        if (!s.count(i.first)) ans[cnt++] = i.second;
    }
    cout << cnt << endl;
    for (int i = 0; i < cnt; i++) cout << ans[i] << endl;
    return 0;
}
/*
0
*/


猜你喜欢

转载自blog.csdn.net/zscdst/article/details/80528151