首页 > 其他 > 详细

[Luogu] 外星密码

时间:2018-01-06 17:52:55      阅读:167      评论:0      收藏:0      [点我收藏+]

https://www.luogu.org/problemnew/show/P1928

沙比提

读清题目

#include <bits/stdc++.h>

using namespace std;
const int N = 20010;

int pre[N], hou[N];

string s;
string ss;
int main()
{
    cin >> s;
    if(s.find([) == -1) {
        cout << s;
        return 0;
    }
    for(int T = 1; T <= 10; T ++){
        
        if(T != 1) s = ss;
        int len = s.length(), last;
        if(s.find([) == -1) break;
        memset(hou, 0, sizeof(hou));
        bool flag;
        for(int i = 0; i < len; i ++){
            if(s[i] == [) {last = i; flag = 1;}
            else if(s[i] == ] && flag) {hou[last] = i; flag = 0;} 
        }
        ss.clear();
        for(int i = 0; i < len; i ++){
            if(!hou[i]) {ss += s[i]; continue ;}
            int tot = 0, j;
            j = i + 1;
            while(s[j] >= 0 && s[j] <= 9){
                tot = tot * 10 + s[j] - 0;
                j ++;
            }
            string s1;
            while(s[j] != ]) s1 += s[j ++];
            for(int k = 1; k <= tot; k ++) ss += s1;
            i = hou[i];
        }
    }
    cout << ss;
    
    return 0;
}

 

[Luogu] 外星密码

原文:https://www.cnblogs.com/shandongs1/p/8214679.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!