Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.util.*; import java.util.stream.*; import java.util.function.*; import java.io.*; import java.math.*; import java.awt.geom.*; import static java.util.Comparator.*; import static java.lang.Math.*; public class Main { public static final PrintWriter outWriter = new PrintWriter(System.out); public static v...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 100; char s[maxn]; int n; int main() { scanf("%s", s); n = strlen(s); int beg = 1; for (beg; beg < n; beg++) { if (s[beg] == s[beg - 1]) { beg--; break; } } int fron; if (beg >= n) fron = n; else fron = b...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
word = input() maximum = 0 prev = "-" curlen = 0 for i in word: if prev == i: maximum = max(maximum, curlen) curlen = 1 else: curlen += 1 prev = i maximum = max(maximum, curlen) start = word[0] left = 1 i = 1 while True: if left == len(word): break if word[i] != start: left += 1 start = word[i] i...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
//package pack; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class first { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw=new PrintWriter(System.out); static ...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; int n = s.length(); int ans = 1, count = 1; for (int i = 1; i < 2 * n; i++) { if (s[i % n] != s[(i - 1) % n]) count++; else { ans = max(ans, count); count = 1; } } ans = min(n, max(ans, count)); ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; char S[111111]; int main() { scanf("%s", S); int N = strlen(S); int s = 0, result = 0; ; for (int i = (1); i < (2 * N); ++i) { if (S[i % N] == S[(i - 1) % N]) s = i; result = max(result, i - s + 1); } printf("%d\n", min(resu...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
def zebra(s,l): if(l==1): return l t=1 a=[] for i in range(1,l): if(s[i]==s[i-1]): a.append(t) t=1 else: t+=1 a.append(t) t=max(a) if(s[0]==s[l-1])or(len(a)==1): return t else: return max(t,a[0]+a[le...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s = input() s = s*3 n = len(s) m,curr=1,1 for i in range(n-1): if s[i]!=s[i+1]: curr+=1 m=max(curr,m) else: curr=1 print(min(m,n//3))
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s = list(input()) u = [] n = len(s) k = 1 for i in range(1, n): if s[i] != s[i - 1]: k += 1 else: u.append(k) k = 1 u.append(k) if s[0] == s[-1] or len(u) == 1: print(max(u)) else: print(max(max(u), u[0] + u[-1]))
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int oo = INT_MAX; string s; int main() { ios_base::sync_with_stdio(0); cin >> s; int n = s.size(); s = s + s; int ans = 0, cur = 1; for (int i = 1; i < s.size(); i++) { if (s[i] != s[i - 1]) cur++; else { if (cu...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
a=list(input()) b=[] k=1 for i in range(len(a)-1): if a[i]!=a[i+1]: k+=1 else: b.append(k) k=1 if len(b)>0: if a[-1]!=a[0]: k+=b[0] b.append(k) else: b.append(k) else: b.append(k) print(max(b))
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s=list(input()) ans=0 far=0 for i in range(len(s)-1): if(s[i]!=s[i+1]): far+=1 continue if(s[0]!=s[-1]): s[:i+1]=s[:i+1][::-1] s[i+1:]=s[i+1:][::-1] far+=1 else: ans=max(ans,far+1) far=0 #print(s) print(max(far+1,ans)) # b w w w b w w b w
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int sol = 1, temp = 1; for (int i = 1; i < s.length(); i++) { if (s[i] != s[i - 1]) { temp++; } else { sol = max(sol, temp); temp = 1; } if (i == s.length() - 1) sol = max(sol, temp); } if (sol =...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
st=str(raw_input()) st=st+st #print st ans=[] cs=0 n=len(st) #print n,st for i in range(0,n-1): if st[i]!=st[i+1]: cs=cs+1 else: ans.append(cs) cs=0 ans.append(cs) print min(n/2,max(ans)+1)
PYTHON
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.util.*; public class Main{ public static int fun(String s){ int n = s.length(); if(n==0 || n==1) return n; int ans = 1; int count = 1; for(int i=1;i<n;i++){ ...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; void output(int out) { printf("%d\n", out); exit(0); } int main() { string s; cin >> s; int l = s.size(); int out = 1; int cnt = 1; for (int i = 1; i < l; i++) if (s[i] != s[i - 1]) { cnt++; out = max(out, cnt); } else { out = max(o...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin >> s; int i, j, ans = 0, maxx = 0, startt = 0, endd = 0, ff = 0; for (i = 0; i < (2 * s.size()); i++) { if (i == s.size() - 1) { if (i == ans) { cout << ans...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Iterator; import java.io.IOException; import java.util.InputMismatchException; import java.io.InputStream; /** * Built using CHelper plug-in Actual solution is at ...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.util.*; import java.io.*; public class TaskC { FastScanner in; public void solve() throws IOException { String s = in.next(); int n = s.length(); int[] a = new int[n]; for (int i = 0; i < n; i++) { if (s.charAt(i) == 'b') { a[i] = 1; } } int[] b = new int[n]; b[0] = 1; for (int...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s = input() s += s n = len(s) ans = 0 temp = 1 for i in range(1,n): if(s[i] == "b"): if(s[i-1] == "w"): temp += 1 else: ans = max(ans, temp) temp = 1 else: if(s[i-1] == "b"): temp += 1 else: ans = max(ans, temp) ...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; //http://codeforces.com/contest/1025/problem/C public class PlasticineZebra { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.lang.reflect.Array; import java.util.*; import java.io.*; /* 999999999 1 590350599 637664270 */ public class Main { // static class Node{ // int left; // int right; // Node(int left,int right){ // this.left=Math.min(left,right); // this.right=Math.max(left...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch <= '9' && ch >= '0') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } char s[100010]; int len...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#!/usr/bin/env python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip def main(): s = input() from_start = True s...
PYTHON
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; char s[maxn]; int cut[maxn]; signed main() { scanf("%s", s); int l = strlen(s); s[l] = s[0]; int cnt = 0; for (int i = 0; i < l; i++) { if (s[i] == s[i + 1]) cnt++, cut[cnt] = i; } int ans = 0; for (int i = 1; i <= cnt; i++) { ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
/** * Created by sky on 20/8/18. * www.github.com/aakashjaiswal1 * aakashjaiswal@hotmail.co.in * aakashjaiswal.in@gmail.com * people die if they are killed */ /** * Created by sky on 19/8/18. * www.github.com/aakashjaiswal1 * aakashjaiswal@hotmail.co.in * aakashjaiswal.in@gmail.com * people die if they are k...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> const int inf = 0x3f3f3f3f; const int mod = (int)1e9 + 7; const int maxn = (int)150000 + 5; using namespace std; int main() { string s; cin >> s; int now = 1, ans = 0, len = s.size(); s += s; for (int i = 1; i < 2 * len; i++) { if (s[i] != s[i - 1]) now++; else ans...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int x = 0; int y = 0; for (int i = 0; i < s.length(); i++) { if (s[i] != s[i + 1]) x++; else break; } int c = 0; for (int i = s.length() - 1; i >= 0; i--) { if (s[i] != s[i - 1]) y++; else { ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); s = s + s; int c = 1, max = 0; for (int i = 0; i < s.size() - 1; i++) { if (s[i] == 'b') { if (s[i + 1] == 'w') { c++; } else c = 1; } else { if (s[i + 1] == 'b') { ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
a=input() a+=a n=len(a) ans=1 s=1 for i in range(n): if a[i-1]!=a[i]: s+=1 else: if s>ans: ans=s s=1 if s>n//2: s=n//2 break if s>ans: ans=s print(ans)
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.util.LinkedList; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Reader.i...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import sys, os, io def rs(): return sys.stdin.readline().rstrip() def ri(): return int(sys.stdin.readline()) def ria(): return list(map(int, sys.stdin.readline().split())) def ws(s): sys.stdout.write(s + '\n') def wi(n): sys.stdout.write(str(n) + '\n') def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n') ...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.util.Scanner; public class Zebra { public static void main(String[] args) { Scanner kb = new Scanner(System.in); String s = kb.nextLine(); s += s; if (s.length() == 0) { System.out.println(0); } boolean[] diff...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 777; char s[N]; int dp[N][2]; int main() { scanf("%s", s); int len = strlen(s); for (int i = len, j = 0; j < len; ++j, ++i) s[i] = s[j]; for (int i = 2 * len - 1; i >= 0; --i) { if (s[i] == 'b') { dp[i][1] = 1 + dp[i + 1][0]; } else...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author nirav */ public class Mai...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; string str; int main() { cin >> str; int num = 1, ans1 = 0; for (int i = 0; i < str.size() - 1; i++) { if (str[i] != str[i + 1]) num++; else { ans1 = max(num, ans1); num = 1; } } if (num == str.size()) { cout << str.size() << endl...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class DivCmb_505C { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReade...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
def abcd(str) : str = str * 2 previous="t";ans=0;count=0; for i in str : if i != previous : previous=i count+=1 else : count=1 #need not to do previous =i bcoz previous will be i-1 wala hi hogaa ans = max (ans,count) m=min(len(str)...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.util.*; public class CodeForces1025C{ public static void main(String[] args) { Scanner input = new Scanner(System.in); char[] s = input.nextLine().toCharArray(); int n = s.length; int ans = 0; int roll = 0; char last = s[0]; for(int i = 0; i < 3*n; i++) { if(s[i%n] == last) roll = 1; ...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class C { public static void main(String args[])throws Exception{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(br.readLine()); ...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
def max_zebra(str): res=1 cur=1 for i in range(1,len(str)): if str[i] != str[i-1]: cur +=1 else: if res < cur: res = cur cur = 1 if res < cur: res = cur return res str = input() res = max_zebra(str+str) if res > len(str...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T> void prn(T first) { cout << first << "\n"; } template <typename T, typename... Args> void prn(T first, Args... args) { cout << first << " "; prn(args...); } int main() { long long i, j, t, n, l = 1; string a; cin >> a; n = a.length(); l...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.Input...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s = input() t = s * 2 m, n = 1, 1 z = len(t) for i in range(z - 1): if t[i] != t[i + 1]: n += 1 else: if n > m: m = n n = 1 if n > m: m = n print(min(z // 2, m))
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; s += s; bool b = (s[0] == 'w'); int res = 1, cnt = 1; for (int i = 1; i < s.length(); i++) { bool bb = (s[i] == 'w'); if (b != bb) { cnt++; res = max(res, cnt); } else cnt = 1; b = bb; } res ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; signed main() { string s; cin >> s; vector<int> v; for (auto it : s) { if (it == 'b') { v.push_back(0); } else { v.push_back(1); } } vector<int> g(v.size(), 0); for (int i = 1; i < v.size(); ++i) { if (v[i] == v[i - 1]) { g.fr...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s = input() n = len(s) ar = [i for i in range(n) if s[i] == s[(i-1)%n]] if len(ar) > 0: ar.append(ar[0]+n) else: print(n) exit() best = 0 for i in range(len(ar)): best = max(best, ar[(i+1)%len(ar)] - ar[i]) print(best)
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
//package round505; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class C { InputStream is; PrintWriter out; String INPUT = ""; void solve() { char[] s = ns().toC...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; char s[200005]; int main() { scanf("%s", s); int len = strlen(s); for (int i = 0; i < len; i++) { s[i + len] = s[i]; } int l = 0, r = 1, ans = 0; while (l < len * 2 && r < len * 2) { while (r < len * 2 && r - l < len && s[r] != s[r - 1]) ++r; ans = m...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; string s; int main() { cin >> s; int len = s.size(); s += s; int ans = -1, cnt = 1; for (int i = 1; i < 2 * len; i++) { if (s[i] != s[i - 1]) cnt++; else { ans = max(cnt, ans); cnt = 1; } } ans = max(cnt, ans); ans = min(ans, le...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
str = input("") str = 2 * str len = len(str) pre = str[0] maxlen = 1 nowlen = 1 for i in range(1, len): if pre == str[i]: maxlen = max(nowlen, maxlen) nowlen = 1 else: nowlen += 1 pre = str[i] maxlen = max(maxlen, nowlen) print("%d" % (maxlen if maxlen <= len // 2 else len // 2)) ...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = (int)s.size(); int ans = 1; if (s.front() != s.back()) { int f = 1; for (int i = 1; i < n; i++) { if (s[i] != s[i - 1]) { f++; } else { ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.util.Arrays; import java.util.Scanner; import java.util.Stack; public class PlasticineZebra { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String str = scanner.nextLine(); System.out.println(plasticineZebra(str)); } private stati...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.*; import java.util.*; public class C implements Runnable{ public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();} public void run() { FastScanner fs = new FastScanner(); PrintWriter out = new PrintWriter(System.out); System.err.println("Go!"); char[] str...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; string s; int ans, cnt; int main() { cin >> s; s += s; for (int i = 0; i < s.size(); ++i) { if (i && s[i] == s[i - 1]) cnt = 1; else ++cnt; ans = max(ans, std::remove_reference<decltype(ans)>::type(cnt)); } ans = min(ans, std::remove_refere...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 200000; int n, ans; char s[maxn + 5]; int main() { scanf("%s", s + 1); n = strlen(s + 1); for (int i = 1; i <= n; i++) s[n + i] = s[i]; n <<= 1; for (int i = 1, now = 0; i <= n; i++) s[i - 1] == s[i] ? now = 1 : now++, ans = max(ans, now); r...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { char s[100007]; cin >> s; int n = strlen(s); vector<pair<pair<char, char>, int> > v; char now = s[0]; char prev = s[0]; int cnt = 1; int m = 1; for (int i = 1; i < n; i++) { if (s[i] != now) { cnt++; now = s[i]; } else { ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; static inline void canhazfast() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <typename T> T extgcd(T a, T b, T &x, T &y) { T x0 = 1, y0 = 0, x1 = 0,...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s = input().strip() n = len(s) max_l = 1 cur_l = 1 last_c = s[0] for i in range(1, n*2): cur_c = s[i%n] if last_c!=cur_c: cur_l += 1 max_l = max(max_l, cur_l) if cur_l == n: break else: cur_l = 1 last_c = cur_c print(max_l)
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return x * f; } const int inf = 0x3f3f3f3f; cons...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s = raw_input()*2 n = len(s)/2 i = 0 ans = 0 while i < n: k = 1 while k < n and s[i+1] != s[i]: i += 1 k += 1 ans = max(ans,k) i += 1 print ans
PYTHON
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s=input() x=len(s) left=1 for i in range(1,x): if s[i]!=s[i-1]: left+=1 else: break right=1 for i in range(x-2,-1,-1): if s[i]!=s[i+1]: right+=1 else: break count=1 ANS=0 for i in range(1,x): if s[i]!=s[i-1]: count+=1 else: if count>ANS: ...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; long long a[maxn]; int main() { string s; cin >> s; long long l = int((s).size()), cur = 0, maxx = 0; for (int i = 0; i < 2 * l - 1; ++i) { if (s[i % l] != s[(i + 1) % l]) { cur++; } else cur = 0; maxx = max(cur, max...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; string a; void Doit(int pos) { string t1 = a.substr(0, pos); reverse(t1.begin(), t1.end()); string t2 = a.substr(pos); reverse(t2.begin(), t2.end()); a = t1 + t2; } int main() { cin >> a; int n = a.length(); for (int i = 1; i < n; i++)...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long int n = s.length(); s = s + s; long long int cnt = 1, max1 = 1; for (long long int i = 1; i < s.length() - 1; i++) { if (s[i] != s[i - 1]) { cnt++; if (cnt > max1) max1 = cnt; } else cnt = 1; ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; string s; int pref = 1, type = 1, cnt = 0, id = 0, mx; int main() { cin.tie(0), ios::sync_with_stdio(0); cin >> s; s = s + s; int n = s.length(); for (int i = 0; i < n; i++) { if (s[i] == 'b' && id == 0) { id = 1; typ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.*; import java.util.*; public class Main { FastReader scn; PrintWriter out; String INPUT = ""; void solve() { String str = scn.next(); int n = str.length(); StringBuilder sb1 = new StringBuilder(str); int x = func(sb1, n); StringBuilder sb2 = new StringBuilder(str); sb2.reverse(); int...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.*; import java.util.*; import java.text.*; import java.lang.*; import java.lang.reflect.Array; import java.math.BigInteger; import java.util.regex.*; public class Myclass { public static ArrayList a[]=new ArrayList[300001]; /*static boolean visited[]=new boolean [300001]; static b...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; int n = s.length(); string t = s + s; int ans = 1; int length = 1; for (int i = 1; i < t.length(); i++) { if (t[i] != t[i - 1]) length++; else length = 1; ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int o, i, j = 1, j1 = 1, j2 = 0, j3, k, h = 1; string s; cin >> s; for (i = 1; i < s.length(); ++i) { if (j1 < h) j1 = h; if (h == s.length()) break; if (s[i - 1] != s[i] && i !=...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
/* * Author Ayub Subhaniya * Institute DA-IICT */ import java.io.*; import java.math.*; import java.text.DecimalFormat; import java.util.*; public class C { InputStream in; PrintWriter out; long mod = (long) 1e9 + 7; int MAX = (int) 1e6 + 7; double eps = 1e-6; String high = ""; void solve() { String s...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
/* * * @author Mukesh Singh * */ import java.io.*; import java.util.*; import java.text.DecimalFormat; @SuppressWarnings("unchecked") public class Solution { //solve test cases void solve() throws Exception { String s = in.readLine(); //count start, end and max boolean isStart = true; int start =...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); S...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.util.*; import java.math.*; public class q_3 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); String s = sc.nextLine(); String str = s+s; int len = str.length(); int max = 1; int curr = 1; for (int i=1 ; i<len ; i++){...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.util.*; import java.io.*; import java.lang.*; public class C { public static void main(String[] args) { Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); byte[] s = in.next().getBytes(); while (s[0] != s[s.length - 1]) { int index = 1; while (index < s.length && ...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
def mni(i, n): return i + 1 def check(s, b): res = 1 i = b cur = s[i] i = (i + 1) % len(s) while i != b: if cur != s[i]: res += 1 cur = s[i] i = (i + 1) % len(s) else: break return res S = input() N = len(S) if S == 1: an...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; int n = a.size(); int bs = 0; for (int i = 0; i < a.size() - 1; ++i) if (a[i] == a[i + 1]) { bs = i + 1; break; } int ans = 1; int tmp = 1; for (int i = bs; i < a.size() + bs - 1; ++i) if (a[i % n] == ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
/* * Remember a 7.0 student can know more than a 10.0 student. * Grades don't determine intelligence, they test obedience. * I Never Give Up. */ import java.util.*; import java.util.Map.Entry; import java.io.*; import static java.lang.System.out; import static java.util.Arrays.*; import static java.lang.Math.*; ...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cer...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, i, j = 1, j2 = 0, j3, k, h = 1; string s; cin >> s; for (i = 1; i < s.length(); ++i) { if (j < h) j = h; if (h == s.length()) break; if (s[i - 1] != s[i] && i != 0) ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.lang.*; import java.math.*; import java.util.*; import java.io.*; public class Main { class Node { int x; long g; public Node(int x,long g){ this.x=x; this.g=g; } public boolean equals(Object o){ Node c=(Node)o; return x==c.x && g==c.g; } public i...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; for (int i = 1; i < a.size(); ++i) { if (a[i] == a[i - 1]) { if (a[0] != a[a.size() - 1]) { reverse(a.begin(), a.begin() + i); reverse(a.begin() + i, a.end()); } } } int cur = 0; int max = 0; ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#!/bin/python3 a = input() a = a + a ma = 1 last = 'x' pos = 0 cur = 0 while pos < len(a): if a[pos] != last: cur += 1 ma = max(ma, cur) else: cur = 1 last = a[pos] pos += 1 print(min(ma, len(a) // 2))
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s = raw_input().strip() s += s a = [c == 'bw'[i%2] for i, c in enumerate(s)] p = a[0] ans = c = 0 for x in a: if x == p: c += 1 else: c = 1 p = x if ans < c: ans = c print min(ans, len(s) / 2)
PYTHON
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
###### ### ####### ####### ## # ##### ### ##### # # # # # # # # # # # # # ### # # # # # # # # # # # # # ### ###### ######### # # # # # # ...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; string second; int main() { cin >> second; int len = (int)second.length(); int ans = 0; int cur = 0; char prv = '#'; for (int i = 0; i < len; i++) { if (second[i] != prv) { cur += 1; prv = second[i]; ans = max(ans, cu...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.io.IOException; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; impo...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
s = input() n = len(s);prepos = 0 b = '' for i in range(1, n): if s[i] != s[i-1]: prepos = i else: break b = s[:prepos + 1][::-1] + s[prepos+1:][::-1] cnt = 1; ans1 = 1 for i in range(1, len(s)): if s[i] != s[i-1]: cnt += 1 else: ans1 = max(ans1, cnt) ...
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#coding:utf-8 data = [str(i) for i in raw_input()] # lst = [] cnt = 1 ans = 1 new = data+data for i in range(1,len(new)-1): if new[i] == new[i-1]: # lst.append(cnt) ans = max(ans,cnt) cnt = 1 else: cnt += 1 ans = max(ans,cnt) print(min(ans,len(data)))
PYTHON
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e6 + 10; string second; int ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> second; int cur = 1; for (int i = 1; i < second.size(); i++) { if (second[i] != second[i - 1]) { cur++; } else { ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; int n; char ch[200010]; int main() { int i, ans, cnt; scanf("%s", ch); n = strlen(ch); for (i = 0; i < n; i++) ch[n + i] = ch[i]; ans = 0, cnt = 0; for (i = 0; i < 2 * n; i++) { if (ch[i] != ch[i - 1]) cnt++; else cnt = 1; ans = max(ans, ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class ...
JAVA
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typename T> void mintt(T& t1, T t2) { t1 = min(t1, t2); } bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "RDLU"; long long ln, lk, lm; void etp(b...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
string = input() string += string ans = 0 sm = 0 for i in range(len(string) - 1): if string[i] != string[i - 1]: sm += 1 ans = max(ans, sm) else: sm = 0 print(min(ans + 1, len(string) // 2))
PYTHON3
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int N; char s[MAXN]; bool opp(char a, char b) { return (a == 'w' && b == 'b') || (a == 'b' && b == 'w'); } int main() { scanf("%s", s); N = strlen(s); int best = 0; int cur = 0; char prev = 'z'; for (int i = 0; i < 2 * N; ++i) { ...
CPP
1025_C. Plasticine zebra
Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack (represented as a sequence of black and white stripes), Grisha now ...
2
9
import java.io.*; import java.util.*; public class main { public static void main(String[] args) throws IOException { Locale.setDefault(Locale.US); br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); String s = next(); char...
JAVA