【CodeForces 777D】Cloud of Hashtags (模拟+字符串处理)
来源:互联网 发布:影视后期剪辑软件 编辑:程序博客网 时间:2024/06/01 12:12
题目大意:删除最少的字符使字符串成非递减排列
思路:倒着模拟,依次比较删除。(第一次使用了string字符串数组和resize)(get到新技能 #include<bits/stdc++.h> 万能头函数)
#include<bits/stdc++.h>#define manx 500005using namespace std;int main(){ int n; string s[manx]; cin>>n; for (int i=1; i<=n; i++) cin>>s[i]; for (int i=n-1; i>=1; i--){ if(s[i] > s[i+1]){ for (int j=1; j<s[i].length(); j++){ if(s[i][j] > s[i+1][j]) s[i].resize(j); } //删除s[i]第j个后的所有元素 } } for (int i=1; i<=n; i++) cout<<s[i]<<endl; return 0;}
关于string.reserve( ) 和string.resize( ) 的学习:
http://blog.csdn.net/freecloud_insky/article/details/47058597
0 0
- 【CodeForces 777D】Cloud of Hashtags (模拟+字符串处理)
- 【codeforces 777D】Cloud of Hashtags
- Codeforces 777D-Cloud of Hashtags
- 【Codeforces 777 D Cloud of Hashtags】
- CodeForces 777D Cloud of Hashtags
- (codeforces)D. Cloud of Hashtags
- Codeforces Round #401 (Div. 2) D. Cloud of Hashtags 贪心、字符串处理
- 777D. Cloud of Hashtags
- codeforces 777D. Cloud of Hashtags (逆序思维)
- D. Cloud of Hashtags
- Codeforces Round #401 (Div. 2) D. Cloud of Hashtags【模拟、贪心】
- Codeforces Round #401 (Div. 2) D. Cloud of Hashtags
- Codeforces Round #401 (Div. 2)D. Cloud of Hashtags
- Codeforces Round #401 (Div. 2) D. Cloud of Hashtags
- Codeforces Round #401 (Div. 2) D. Cloud of Hashtags(暴力)
- Codeforces Round #401(Div. 2)D. Cloud of Hashtags【逆序思维】
- Codeforces Round #401 (Div. 2) D Cloud of Hashtags —— 串
- Cloud of Hashtags
- 26、C++在 cmd 中给编译过的 mian 函数的可执行文件传入参数
- 使用javadoc工具生成API文档
- 倒直角
- c++primer读书笔记(6)
- Linux学习之:tmpfs简介及增加方式
- 【CodeForces 777D】Cloud of Hashtags (模拟+字符串处理)
- Makefile
- centos7 minimal安装tensorflow
- jieba分词支持关键词带空格和特殊字符
- MySQL添加映射连接到数据库时发生错误“FluentNHibernate.Cfg.FluentConfigurationException”
- 人在自然中生活
- MySQL数据库基础(一)(启动-停止、登录-退出、语法规范及最基础操作)(持续更新中)
- Ubuntu下配置Sublime的Jedi的代码自动补全
- oracle rac的特征