题解:P17232 [Algo Beat Contest 017 A] 串哈希
思路
赛时读一眼题目,这不是直接模拟吗,所以端了盘大芬上去,直接判断是不是此单词,0分!
再一读题,发现如果应援词包含字符串这么一个东西,知道了是判断是否包含,便想到了string的find函数,又看到满足此条件忽略前面的条件,便想到从后往前判断,便有了以下代码。
代码
#include<bits/stdc++.h>
using namespace std;
int n;
long long s;
int main(){
cin>>n>>s;
long long t=s;
for(int i=0;i<n;i++){
string st;
cin>>st;
bool a=st.find("shuki")!=string::npos;
bool b=st.find("daishuki")!=string::npos;
bool c=st.find("kirai")!=string::npos;
if(c){
if(t>0)
t=0;
}
else if(b)
t+=2;
else if(a)
t++;
else
t--;
}
if(t>0){
cout<<t-s;
return 0;
}
cout<<"shuki";
return 0;
}