[CodeForces518A]Vitaly and Strings[字符串][构造]
来源:互联网 发布:哪件商品能在淘宝发布 编辑:程序博客网 时间:2024/06/17 04:08
题目链接:[CodeForces518A]Vitaly and Strings[字符串][构造]
题意分析:给出字符串s,t,问:是否有字符串,使得其大于s小于t。(s < t)
解题思路:题目即问:s的下一个排列是否小于t。
个人感受:下一个排列的构造我也是醉了。WA49都出来了XD
具体代码如下:
#include <iostream>#include <string>using namespace std;typedef long long ll;int main() { string s1, s2, s3; cin >> s1 >> s2; int len = s1.size(); s3 = s1; for (int i = len - 1; i >= 0; i--) //s1的下一个排列 { if (s3[i] != 'z') { s3[i] += 1; break; } else s3[i] = 'a'; //有点像26进制的意味,从末尾开始进位,超过z就进位直到不进位为止 } if (s3 < s2) cout << s3 << '\n'; else cout << "No such string\n"; return 0;}
0 0
- [CodeForces518A]Vitaly and Strings[字符串][构造]
- CF 518A(Vitaly and Strings-构造)
- Codeforces Round #293 (Div. 2) -- A. Vitaly and Strings (字符串构造)
- Vitaly and Strings
- A. Vitaly and Strings
- A. Vitaly and Strings
- A. Vitaly and Strings
- Vitaly and Strings
- ACdream 1056 Vitaly and Strings
- codeforces 293 dvi2 A. Vitaly and Strings
- codeforces 518A Vitaly and Strings
- 518A - Vitaly and Strings【string】
- CF(#293 div2):A:Vitaly and Strings
- CF 293 A. Vitaly and Strings
- CodeForces 518A Vitaly and Strings
- Codeforces Round #293 (Div. 2)A. Vitaly and Strings
- Codeforces Round #293 (Div. 2) -- A. Vitaly and Strings
- CodeForces - 518A Vitaly and Strings(水题)
- Oracle Study之--DataGuard 最大保护模式故障(ORA-16198)
- opencv MAT数据操作
- Sass浅谈
- github 上的好文章
- Facebook 开源项目 Fresco 使用简介,facebookfresco
- [CodeForces518A]Vitaly and Strings[字符串][构造]
- Windows中的时间(SYSTEMTIME和FILETIME)
- Ubuntu14.04 (x64) 下hadoop2.5.0的编译
- 使用北邮人开放平台OAuth2.0心得
- 缺陷(bug)严重级别定义
- 安全退出多个activity
- USB WDM驱动开发实例 bulkusb
- 安装和使用memcached
- 基于openfire和spark的二次开发。