Baby Bites
Time Limit: 1 Sec Memory Limit: 128 Mb
练习链接https://codeforces.com/gym/101933/problem/B
Description
Arild just turned 1 year old, and is currently learning how to count. His favorite thing to count is how many mouthfuls he has in a meal: every time he gets a bite, he will count it by saying the number out loud.
Unfortunately, talking while having a mouthful sometimes causes Arild to mumble incomprehensibly, making it hard to know how far he has counted. Sometimes you even suspect he loses his count! You decide to write a program to determine whether Arild’s counting makes sense or not.
Input
The first line of input contains an integer n (1 ≤ n ≤ 1 000), the number of bites Arild receives. Then second line contains n space-separated words spoken by Arild, the i’th of which is either a non-negative integer ai (0 ≤ ai ≤ 10 000) or the string “mumble”.
Output
If Arild’s counting might make sense, print the string “makes sense”. Otherwise, print the string “something is fishy”.
Sample Input
5
1 2 3 mumble 5
8
1 2 3 mumble mumble 7 mumble 8
3
mumble mumble mumble
Sample Output
makes sense
something is fishy
makes sense
简单模拟,没什么好说的。。。
题目大意是这样的,判断一个数列是否是连续的,中间有模糊的数。如果是连续的输出makes sense否则输出something is fishy
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#define RI register int
using namespace std;
# define IOS ios::sync_with_stdio(false)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
#define lowbit(x) (x&-x)
string str;
int change(string s){
int len=s.size();
int ret=0;
for(int i=0;i<len;i++){
ret=ret*10+str[i]-'0';
}
return ret;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
int flag=0;
for(int i=1;i<=n;i++){ //注意是从一开始的
cin>>str;
if(str[0]>='0'&&str[0]<='9'){
int num=change(str);
if(num!=i) flag=1;
}
}
if(flag) cout<<"something is fishy"<<endl;
else cout<<"makes sense"<<endl;
return 0;
}