Algo Beat R17A (Alterego) 题解

· · 题解

出题人题解。

预期定位:红 / 字符串 / 模拟

题目说得比较绕,其实优先级就是 kirai > daishuki > shuki。

直接按照题意模拟即可。

::::info[std by Karmallis]

#include<bits/stdc++.h>
using namespace std;
#define h(x) (s.find(x)!=s.npos)

int n,x,y;
string s;

main(){
    cin>>n>>y;
    x=y;
    while(n--){
        cin>>s;
        if(h("kirai")) x=-max(-x,0);
        else if(h("shuki")) x+=1+h("daishuki");
        else x--;
    }
    cout<<(x>0?to_string(x-y):"shuki");
}

::::