題目描述
牛牛内推了好多人去牛客網參加面試,面試總共分四輪,每輪的面試官都會對面試者的發揮進行評分。評分有 A B C D A B C D ABCD四種。如果面試者在四輪中有一次發揮被評為 D D D,或者兩次發揮被評為 C C C,就不會通過面試。如果面試者沒有一次被評為 D D D,并且有三個或以上的 A A A,則會獲得 s p e c i a l o f f e r special offer specialoffer。其餘情況會獲得普通 o f f e r offer offer。
現在告訴你一些面試者的發揮,請你算一算,他們的面試結果分别是什麼。
輸入描述:
第一行輸入一個 T,代表面試者的個數。
接下來有 T 行,每行都有一個長度為 4 的字元串,每個位置的字元分别代表面試者每一輪的發揮。
輸出描述:
輸出 T 行,分别表示 T 個面試者的面試結果。如果面試失敗,輸出 f a i l e d failed failed,如果面試通過,但不是 s p e c i a l special special o f f e r offer offer,則輸出 o f f e r offer offer,否則輸出 s p sp sp o f f e r offer offer。
輸入
2
AAAB
ADAA
輸出
sp offer
failed
備注:
T < = 1000 T <= 1000 T<=1000
解題思路
簡單的模拟,把題目意思翻譯一下就是A大于等于3的時候輸出 s p sp sp o f f e r offer offer,有 2 2 2個 C C C或者出現 D D D則 f a i l e d failed failed,否則輸出 o f f e r offer offer
代碼
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
int t,x,y,flag;
string c;
int main(){
scanf("%d",&t);
for(int i=1;i<=t;i++)
{
x=0,y=0,flag=0;
cin>>c;
for(int j=0;j<=3;j++)
{
if(c[j]=='A')
x++;
if(c[j]=='D')
{
flag=1;
break;
}
if(c[j]=='C')
{
y++;
if(y==2)
{
flag=1;
break;
}
}
}
if(flag==1) printf("failed\n");
else if(x>=3) printf("sp offer\n");
else printf("offer\n");
}
}