CodeForces 777D Cloud of Hashtags
来源:互联网 发布:一条网线开两个淘宝店 编辑:程序博客网 时间:2024/06/02 21:25
题目链接:http://codeforces.com/contest/777/problem/D
题意:给你n个#开头的字符串,让你通过删除一些字符(不能删除#),使得他们呈非递减的序列,并输出这个序列
解析:非递减,那么你从序列的末尾扫一遍上去,遇到前一个字符串比当前字符串大的就处理一下即可
#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <iostream>#include <vector>#include <queue>#include <string>#include <set>#include <map>using namespace std;const int maxn = 1e6+100;string a[maxn];int main(){ int n; scanf("%d",&n); for(int i=0;i<n;i++) cin>>a[i]; for(int i=n-1;i>=1;i--) { if(a[i]<a[i-1]) { int j = 0; for(;j<a[i-1].length();j++) { if(a[i-1][j]>a[i][j]) break; } a[i-1] = a[i-1].substr(0,j); } } for(int i=0;i<n;i++) cout<<a[i]<<endl; return 0;}
0 0
- 【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
- 777D. Cloud of Hashtags
- 【CodeForces 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 —— 串
- Codeforces Round #401 (Div. 2) D. Cloud of Hashtags【模拟、贪心】
- Cloud of Hashtags
- 在线帮助文档转CHM方法
- [生存志] 第146节 秦汉之官制
- 【Effective Objective-C 2.0:编写高质量iOS与OS X代码的52个有效方法】总结(一)
- 算法10:给一个array和一个target value, 检查array里是否存在两个数之和为target
- LINUX常用命令--重定向、管道篇(四)
- CodeForces 777D Cloud of Hashtags
- 范数(机器学习中的使用)
- 使用moy快速开发后台管理系统(四)
- fastText原理及应用
- 数据结构与算法之深度搜索(理论+代码)
- Numeral.js – 格式化和操作数字的 JavaScript 库
- osgEarth编译——以VS2012为例
- redis学习笔记
- struts2 核心控制器:FilterDispatcher (写的真心清晰)