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.
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.
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.
4 red purple yellow orange
2 Space Time
0
6 Time Space Power Reality Mind Soul
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.
题是水题 , 主要是练STL
#include <iostream> #include <cstdio> #include <map> #include <string> using namespace std; map<string , pair<bool,string> > mp; int main(){ mp["purple"]=make_pair(false,"Power"); mp["green"] =make_pair(false,"Time"); mp["blue"] =make_pair(false,"Space"); mp["orange"]=make_pair(false,"Soul"); mp["red"] =make_pair(false,"Reality"); mp["yellow"]=make_pair(false,"Mind"); std::ios::sync_with_stdio(false); std::cin.tie(); int n; cin>>n; string s; for (int i=0;i<n;i++){ cin>>s; mp[s].first=1; } int ans=0; for (map<string,pair<bool,string> >::iterator i=mp.begin();i!=mp.end();i++){ if(i->second.first==false) ans++; } cout<<ans<<endl; for (map<string,pair<bool,string> >::iterator i=mp.begin();i!=mp.end();i++){ if(i->second.first==false) cout<<i->second.second<<endl; } return 0; }