797C Minimal string
来源:互联网 发布:mac美国官网怎么下单 编辑:程序博客网 时间:2024/06/02 02:16
#include<iostream>#include<vector>#include<string>#include<set>#include<map>#include<algorithm>#include<queue>#include<stack>using namespace std;int main(){string s;while (cin >> s){vector<int> amount(26, 0);for (int i = 0; i < s.size(); i++) amount[s[i] - 'a']++;stack<char> st;for (int i = 0; i < s.size();){int kk = 26;if (!st.empty()){kk = st.top() - 'a';}int k;for (k = 0; k < 26; k++){if (amount[k]) break;}int min_val = min(kk, k);while (true){if (!st.empty() && st.top() - 'a' == min_val) break;st.push(s[i]);amount[s[i] - 'a']--;i++;if (i == s.size()) break;}if (!st.empty()){cout << st.top();st.pop();}}while (!st.empty()){cout << st.top();st.pop();}cout << endl;}return 0;}
0 0
- 797C Minimal string
- Codeforces 797C-Minimal string
- CodeForces 797C Minimal string
- Codeforces 797C Minimal String 贪心+模拟
- Codeforces 797C Minimal string【贪心】
- Codeforces 797C Minimal String 贪心
- Codeforces 797C Minimal string 简单模拟
- C. Minimal string
- 【CodeForces 797C】Minimal string(贪心+字符串)
- Educational Codeforces Round 19 C. Minimal string
- Educational Codeforces Round 19 C. Minimal string
- Minimal string
- Minimal string
- Minimal string
- Minimal string CodeForces
- CentOS7 minimal静默安装Oracle 12c
- 1.Minimal Number of Palindromes on a String(dp)
- c++String
- border与background定位
- 插入排序
- Python 脚本调试如何C代码--工程小札记
- CCFCSP201312-4有趣的数
- 总结C++中几种结构体初始化的方法
- 797C Minimal string
- 使用@responseBody遇见的异常
- C++第五次作业
- jupyter与Pycharm远程开发
- Android Fragment 深度解析
- Docker windows 安装MySql和Tomcat
- java中的多线程
- Mybatis学习(2):Mybatis和Spring整合详解
- NodeJS解析url参数