Codeforces Round #306 (Div. 2) A. Two Substrings string两个函数使用
来源:互联网 发布:mysql 解锁 编辑:程序博客网 时间:2024/05/21 17:29
C++ 中 string 的 find 函数 和 reverse 函数的使用
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <vector>#include <set>#include <stack>#include <map>#include <climits>using namespace std;typedef long long ll;const int maxn = 10000 + 7, INF = 0x3f3f3f3f, mod = 1e9 + 7;string s;int main() { cin >> s; int len = (int) s.size(); if(len < 4) return 0*puts("NO"); string t = s; reverse(t.begin(), t.end()); // void string t1 = "AB", t2 = "BA"; int p1 = s.find(t1), p2 = t.find(t1); //cout << p1 << " == " << p2 << endl; if( p1 >= 0 && p2 >= 0 && p1+p2+4 <= len) return 0*puts("YES"); p1 = s.find(t2), p2 = t.find(t2); if( p1 >= 0 && p2 >= 0 && p1+p2+4 <= len) return 0*puts("YES"); return 0*puts("NO");}
阅读全文
1 0
- Codeforces Round #306 (Div. 2) A. Two Substrings string两个函数使用
- Codeforces Round #306 (Div. 2)---A. Two Substrings
- Codeforces Round #306 (Div. 2) A. Two Substrings
- Codeforces Round #306 (Div. 2), problem: (A) Two Substrings
- Codeforces,306DIV.2A. Two Substrings
- Codeforces Round #212 (Div. 2) A A. Two Semiknights Meet
- Codeforces Round #212 (Div. 2) A. Two Semiknights Meet
- Codeforces Round #128 (Div. 2) A. Two Problems
- Codeforces Round #333 (Div. 2) A. Two Bases
- Codeforces Round #333 (Div. 2) A. Two Bases
- Codeforces Round #333 (Div. 2) A. Two Bases
- Codeforces Round #333 (Div. 2) A. Two Bases
- Codeforces Round #333 (Div. 2) A. Two Bases
- Codeforces Round #294 (Div. 2)D. A and B and Interesting Substrings
- hash(Codeforces Round #294 (Div. 2)D. A and B and Interesting Substrings)
- Codeforces Round #294 (Div. 2) -- D. A and B and Interesting Substrings
- Codeforces Round #294 (Div. 2) D. A and B and Interesting Substrings
- Codeforces Round #294 (Div. 2) D. A and B and Interesting Substrings(map)
- pytorch初学(1)(安装及入门)
- 一个故事来说NIO
- nagios(centos7.3环境) 的源码安装
- Java开发环境的搭建以及使用eclipse从头一步步创建java项目
- STL之set
- Codeforces Round #306 (Div. 2) A. Two Substrings string两个函数使用
- Hibernate中Session的load和get方法的区别是什么?
- python 学习之 Pig Latin
- 安装系统
- JavaScript深入系列15篇正式完结!
- Android开发:XML简介及DOM、SAX、PULL解析对比
- zcmu-1986
- js中问号
- 单表查询