#9 TLE
查看原帖
#9 TLE
286238
TLE_Forever楼主2020/11/20 21:35

自己测试的时候感觉没T……是输入输出的问题吗?

CODE:

#include<cstdio>
#include<string>
using namespace std;
char ch;
string ans="";
inline string turnStr(char ch) {
    string result="";
    result+=ch;
    return result;
}
string check() {
    if(ch=='[') {
        int d;
        string tmp="",nxt="";
        scanf("%d",&d);
        while((ch=getchar())!=']') tmp+=check();
        for(int i=1;i<=d;i++) nxt+=tmp;
        return nxt;
    }
    else return turnStr(ch);
}
int main() {
    while((ch=getchar())!='\n') ans+=check();
    for(int i=0;i<ans.length();i++) putchar(ans[i]);
    return 0;
}

2020/11/20 21:35
加载中...