CF353E.Antichain

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You have a directed acyclic graph GG , consisting of nn vertexes, numbered from 00 to n1n-1 . The graph contains nn edges numbered from 00 to n1n-1 . An edge with number ii connects vertexes ii and (i+1) mod n(i+1) mod n , and it can be directed in either direction (from ii to (i+1) mod n(i+1) mod n , or vise versa).

Operation x mod yx mod y means taking the remainder after dividing number xx by number yy .

Let's call two vertexes uu and vv in graph GG comparable if the graph contains a path either from uu to vv or from vv to uu . We'll assume that an antichain is a set of vertexes of graph GG , where any two distinct vertexes are not comparable. The size of an antichain is the number of vertexes in the corresponding set. An antichain is maximum if the graph doesn't have antichains of a larger size.

Your task is to find the size of the maximum antichain in graph GG .

输入格式

The first line contains the sequence of characters s0s1... sn1s_{0}s_{1}...\ s_{n-1} (2<=n<=106)(2<=n<=10^{6}) , consisting of numbers zero and one. The length of the line (number nn ) corresponds to the number of vertexes and edges in graph GG . If character sis_{i} (i>=0)(i>=0) equals 00 , then the edge between vertexes ii and (i+1) mod n(i+1) mod n is directed from the ii -th vertex to the (i+1) mod n(i+1) mod n -th one, otherwise — to the opposite point.

It is guaranteed that the given graph is acyclic.

输出格式

Print a single integer — the size of the maximum antichain of graph GG .

输入输出样例

  • 输入#1

    001
    

    输出#1

    1
    
  • 输入#2

    110010
    

    输出#2

    3
    

说明/提示

Consider the first test sample. The graph's GG edges are: 010→1 , 121→2 , 020→2 . We can choose the set of vertexes [0][0] as the maximum antichain. We cannot choose an antichain of larger size.

首页