zoukankan      html  css  js  c++  java
  • CF1025C Plasticine zebra

    思路:

    不要被骗了,这个操作实际上tm是在循环移位。

    实现:

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 int main()
     4 {
     5     string s;
     6     while (cin >> s)
     7     {
     8         int n = s.length(), maxn = 0, cnt = 1, pos = -1;
     9         for (int i = 0; i < n - 1; i++)
    10         {
    11             if (s[i] == s[i + 1])
    12             {
    13                 maxn = max(maxn, cnt);
    14                 cnt = 1;
    15                 pos = i;
    16             }
    17             else cnt++;
    18         }
    19         maxn = max(maxn, cnt);
    20         if (pos != -1)
    21         {
    22             int i = pos + 1; cnt = 1;
    23             while (i != pos && s[i] != s[(i + 1) % n])
    24             {
    25                 i = (i + 1) % n;
    26                 cnt++;
    27             }
    28             maxn = max(maxn, cnt);
    29         }
    30         cout << maxn << endl;
    31     }
    32     return 0;
    33 }
  • 相关阅读:
    Ansible概述
    iptables端口转发
    iptables配置实例
    iptables常用操作
    iptables常用命令
    每日总结3.15
    每日总结3.12
    每日总结3.11
    每日总结3.10
    每日总结3.9
  • 原文地址:https://www.cnblogs.com/wangyiming/p/9513108.html
Copyright © 2011-2022 走看看