题解 p2628

· · 题解

思路:

纯模拟(不懂模拟的可以理解为就是你在玩这个游戏,你就是游戏人物,你在执行规则就可以了)

#include<bits/stdc++.h>
using namespace std;
string s;
int n,a,cishi=-1,tot=0;
int main() {
    getline(cin,s);
    scanf("%d",&n);
    int length=s.length()-1;
    for(int i=1; i<=n; i++) {
        scanf("%d",&a);
        cishi+=a;
        if(cishi>=length) cishi=length-1;
        if(s[cishi]=='>'&&s[cishi+1]=='>'&&s[cishi+2]=='>')
            while(s[cishi]=='>')cishi++;
        else if(s[cishi]=='*'&&s[cishi+1]=='*'&&s[cishi+2]=='*') {
            while(s[cishi+tot]=='*')tot++;
            cishi-=tot;
        }
        if(cishi<0)cishi=0;
        if(cishi>=length)cishi=length-1;
    }
    cout<<cishi+1<<' '<<length-1-cishi;
    return 0;
}

总结一下:有一些比较坑人的点(对于我这样脑子不大灵光的人)

1.刚开始的时候他还没有在棋盘上,一定要注意!!(卡了我一上午)不注意的话,洛谷上只能AC一半数据点。

2.样例我没过!!!(我的输出是20 4)代码玄学还是样例有误我不晓得,

3.while(s[cishi+tot]=='')tot++;在判断倒退的时候一定是加上‘’这个符号的格数,不然还是卡一半数据点。

4.读好题目读好题目读好题目(重要的事情来三遍)