我是菜鸡,大佬勿喷,AC的只有1,3两题,水平有限,仅供参考。
7-1 Simple Lie Detection (20 分)
Lie detection usually uses a set of prepared questions to ask the testee, and the result is obtained by analyzing the testee’s reactions. The more advanced technology uses a polygraph (测谎仪) to monitor the physical activities of the testee. Our simple polygraph here is to make a judgment by analyzing the characteristics of the answers to the questions.
First, we ask the testee to complete N multiple choice questions, each with a single answer. Each question has 8 options, which are represented by the lowercase English letters a-h. Then we can obtain a string of length N, consisting of only the lowercase English letters a-h. Score each string, and those whose score exceeds a certain threshold (阈值) T are judged as “suspected liars”. The scoring rules are as follows:
- the string starts with an f has its score −2;
- the string ends with an a has its score −1;
- for every longest segment of answeres where the same letter is chosen
for consecutive questions, if the segment length is larger than 5,
the score is to +3; - if an a is immediately followed by e or h, the score is to −4;
- for every longest segment of answeres where consecutively increasing
letters are chosen to answer consecutive questions (such as abcd or
defgh), if the segment length is larger than 3, the score is to +5.
Your job is to score the answers and make a judgement.
Input Specification:
Each input file contains one test case. For each case, the first line gives 3 positive integers N (6≤N≤100), the number of questions; T (≤100), the threshold for judging a liar; and K (≤100), the number of testees.
Then K lines follow, each gives the string of answers of a testee.
Output Specification:
For each testee, print in a line the total score of his/her answers. If the score exceeds the threshold, print !!! after the score.
Sample Input:
12 1 6
fghaebcdeddd
ahhhhhhgbaaa
cdefffffffff
fffffghecaaa
feeeeeeeegcb
aaaaaabbbbbb
Sample Output:
-1
-2
8!!!
-3
1
6!!!
AC代码:
#include<iostream>
#include<string>
using namespace std;
int n,t,k;
int judge(string s){
int ans=0;
if(s[0]=='f')
ans-=2;
if(s[n-1]=='a')
ans-=1;
for(int i=0;i<n-1;i++){
if( (s[i]=='a' && s[i+1]=='e') || (s[i]=='a' && s[i+1]=='h') )
ans-=4;
}
for(int i=