Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 41 point C region 2016 first tour
- # include <set>
- # include <string>
- # include <iostream>
- using namespace std;
- int32_t check_st(string &s, set<string> &checked) {
- checked.insert(s);
- bool first = true;
- char pr = s[0];
- for (size_t i = 1; i < s.length(); i++) {
- if (s[i] != pr) {
- if (first) {
- first = false;
- pr = s[i];
- } else {
- return 0;
- }
- }
- }
- return 1;
- }
- int main() {
- string s;
- int32_t count = 0;
- set<string> checked;
- cin >> s;
- for (size_t i = 0; i < s.length(); i++) {
- string st_cur;
- st_cur += s[i];
- if (checked.find(st_cur) == checked.end()){
- count += check_st(st_cur, checked);
- }
- for (size_t j = i + 1; j < s.length(); j++) {
- st_cur += s[j];
- if (checked.find(st_cur) == checked.end()){
- count += check_st(st_cur, checked);
- }
- }
- }
- cout << count;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement