[ABC426A]OS Versions题解
Time Limit: 2 sec / Memory Limit: 1024 MiB
Score : 100 points
Problem Statement
The versions of a certain OS in chronological order are "Ocelot", "Serval", "Lynx".
Determine whether version X is the same as or newer than version Y.
有道 翻译
问题陈述
某个操作系统的版本按时间顺序依次是“Ocelot”,“Serval”,“Lynx”。
确定版本 X 是否与版本 Y 相同或更新。
Constraints
- Each of X and Y is one of "
Ocelot", "Serval", "Lynx" (without quotation marks).
有道 翻译
# #约束
- X 和 Y 分别为“Ocelot”、“Serval”、“Lynx”(不带引号)中的一个。
Input
The input is given from Standard Input in the following format:
X Y
有道 翻译
# #输入
输入来自标准输入,格式如下:
X Y
Output
If version X is the same as or newer than version Y, print Yes; otherwise, print No.
有道 翻译
# #输出
如果版本 X 与版本 Y 相同或更新,则打印‘ Yes ’;否则,打印‘ No ’。
Sample Input 1
Copy
Serval Ocelot
Sample Output 1
Copy
Yes
Version Serval is the same as or newer than version Ocelot. Therefore, print Yes.
有道 翻译
###输出示例
Yes
版本‘几个’与版本‘ Ocelot ’相同或更新。因此,打印“Yes”。
Sample Input 2
Copy
Serval Lynx
Sample Output 2
Copy
No
Version Serval is not the same as nor newer than version Lynx. Therefore, print No.
有道 翻译
###示例输出
No
版本“若干”与版本“Lynx”不同,也不更新。因此,打印“No”。
Sample Input 3
Copy
Ocelot Ocelot
Sample Output 3
Copy
Yes
Version Ocelot itself is the same as or newer than version Ocelot. Therefore, print Yes.
有道 翻译
###输出示例
Yes
版本‘ Ocelot ’本身与版本‘ Ocelot ’相同或更新。因此,打印“Yes”。
思路
直接map判断记录即可。
代码见下
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
map<string,long long> mp;
int main(){
mp["Ocelot"]=1;
mp["Serval"]=2;
mp["Lynx"]=3;
cin>>s1>>s2;
if(mp[s1]>=mp[s2]){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
return 0;
}

浙公网安备 33010602011771号