STL deque 版求助.
  • 板块P1106 删数问题
  • 楼主da_ke
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/4/17 13:20
  • 上次更新2023/10/23 18:13:16
查看原帖
STL deque 版求助.
766675
da_ke楼主2023/4/17 13:20
#include<bits/stdc++.h>

using namespace std;

string st;
int n,k;

deque<int> a;

int main()
{
    cin>>st>>k;
    int t=st.size();
    for(int i=0;i<t;i++) 
        a.push_back(st[i]-'0');
    for(int i=1;i<=k;i++)
        for(auto it=a.begin();it!=a.end();++it)
            if(*it>*(it+1)) {
                auto now=it;
                a.erase(it);
                it=now;
                break;
            }
    while(!a.empty()&&a.front()==0)
        a.pop_front();
    for(auto& it:a)
        cout<<it;
}

https://www.luogu.com.cn/record/108330803

2023/4/17 13:20
加载中...