60分求调,#2,6,7,9 TLE
查看原帖
60分求调,#2,6,7,9 TLE
579238
Xiang127332楼主2025/6/30 23:49
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;


string src;
void exp(int sbegin, int send)
{
    int i;
    for(i=sbegin; i<send; i++)
    {
        if(src[i] !='[')
        {
            cout<<src[i];
            continue;
        }
        //i -> [
        int times=0, beg, end = send-1;
        for(beg=i+1; src[beg]>='0'&&src[beg]<='9'; beg++)
        {
            times*=10;
            times+=src[beg]-'0';
        }
        while(src[end] != ']') end--;
        i=end;
        for(int j=0; j<times; j++) exp(beg, end);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>src;

    exp(0, src.size());
    return 0;
}

评测记录 谢谢大家

2025/6/30 23:49
加载中...