A. Infinity Gauntlet

通过颜色识别漫威宇宙中无限手套上缺失的宝石名称,利用编程技巧解析宝石的颜色并确定其对应的宝石名,如时间、心灵、现实等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems:

the Power Gem of purple color,
the Time Gem of green color,
the Space Gem of blue color,
the Soul Gem of orange color,
the Reality Gem of red color,
the Mind Gem of yellow color.
Using colors of Gems you saw in the Gauntlet determine the names of absent Gems.

Input
In the first line of input there is one integer nn (0≤n≤60≤n≤6) — the number of Gems in Infinity Gauntlet.

In next nn lines there are colors of Gems you saw. Words used for colors are: purple, green, blue, orange, red, yellow. It is guaranteed that all the colors are distinct. All colors are given in lowercase English letters.

Output
In the first line output one integer mm (0≤m≤60≤m≤6) — the number of absent Gems.

Then in mm lines print the names of absent Gems, each on its own line. Words used for names are: Power, Time, Space, Soul, Reality, Mind. Names can be printed in any order. Keep the first letter uppercase, others lowercase.

Examples
inputCopy
4
red
purple
yellow
orange
outputCopy
2
Space
Time
inputCopy
0
outputCopy
6
Time
Mind
Soul
Power
Reality
Space
Note
In the first sample Thanos already has Reality, Power, Mind and Soul Gems, so he needs two more: Time and Space.

In the second sample Thanos doesn’t have any Gems, so he needs all six.

#include <iostream>
#include <string>
#include <map>
using namespace std;

string s[10];
bool vis[7];

void check(string a)
{
    if(a == "purple")
        vis[1] = 1;
    if(a == "green")
        vis[2] = 1;
    if(a == "blue")
        vis[3] = 1;
    if(a == "orange")
        vis[4] = 1;
    if(a == "red")
        vis[5] = 1;
    if(a == "yellow")
        vis[6] = 1;
    return ;
}

int main()
{
    map<int, string> mp;
    mp.insert(pair<int, string> (1, "Power"));
    mp.insert(pair<int, string> (2, "Time"));
    mp.insert(pair<int, string> (3, "Space"));
    mp.insert(pair<int, string> (4, "Soul"));
    mp.insert(pair<int, string> (5, "Reality"));
    mp.insert(pair<int, string> (6, "Mind"));
    int n;
    while(cin >> n)
    {
        for(int i = 0; i < n; ++i)
        {
            cin >> s[i];
            check(s[i]);
        }
        cout << 6 - n << '\n';
        for(int i = 1; i <= 6; ++i)
            if(!vis[i])
            {
                map<int, string>::iterator a = mp.find(i);
                cout << a -> second << '\n';
            }
    }
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值