7.9刚考了,今天又考ρωρ

T1 高级打字机

7.10校内测

7.10校内测

7.10校内测

这里undo可以撤销undo操作emm可真是神奇

先说一下50pts:直接开数组模拟

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
using namespace std;
int read()
{
    char ch=getchar();
    int x=0;bool f=0;
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<3)+(x<<1)+(ch^48);
        ch=getchar();
    }
    return f?-x:x;
}
int n,u;
char zs[100009];
int main()
{
    freopen("type.in","r",stdin);//考试不要忘了
    freopen("type.out","w",stdout);
    n=read();
    for(int i=1;i<=n;i++)
    {
        char cz=getchar();
        while(cz!='T'&&cz!='U'&&cz!='Q')cz=getchar();
        if(cz=='T')
        {
            char ty=getchar();
            while(ty==' '||ty=='\n'||ty=='\n')ty=getchar();
            zs[++u]=ty;
        }
        if(cz=='Q')
        {
            int num=read();
            if(num>u)printf(" \n");
            else printf("%c\n",zs[num]);
        }
        if(cz=='U')
        {
            int num=read();
            u-=num;
        }
    }
}
50pts

相关文章: