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
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; int n = s.size(), ans = 0; s += s; vector<int> l(s.size(), 0), r(s.size(), 0); for (int i = 0; i < 2 * n; ++i) { int j = i; while (i < 2 * n - 1 and s[i] != s[i + 1]) { ++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> #pragma GCC optimize("O3") #pragma ma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") using namespace std; long lon...
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 plasticineZebra { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String s=sc.nextLine(); s=s+s; int ans=0; for(int i=0;i<s.length();i++) { int t=1; while(i+1<s.len...
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.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class C { public static void main(String[] ar...
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 + 5; char s[N]; int main() { scanf("%s", s); int len = strlen(s); for (int i = 0; i < len; i++) { s[i + len] = s[i]; } len <<= 1; int ans = 0, cnt = 0; for (int i = 1; i < len; i++) { if (s[i] != s[i - 1]) { cnt++; 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class PlasticineZebra { public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); char[] c = br.readLine().toCharArray(); ...
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> namespace xxx { using namespace std; const double EPS = 1e-8; const double PI = acos(-1.0); const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; inline long long rd() { long long x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(...
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; typedef pair<long long, long long> pll; int max_zebra(string S, int n) { int max_length = 1; for (int i = int(0); i <= int(n - 1); i++) { int j = i + 1; int length = 1; while (j <= n - 1 && S[j - 1] != S[j]) { length += 1; j += 1; } max_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.util.*; import java.io.*; public class roatae2 { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); String s = reader.readLine(); char[] str = (s+s).toCharArray(...
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
#!/usr/bin/python import sys import math S = input() S = S + S result = [1] for i in range(1, len(S)): if S[i] != S[i - 1]: result.append(result[i - 1] + 1) else: result.append(1) print(int(min(len(S) / 2, max(result))))
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 PlasticineZebra { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); String str = s.next(); StringBuilder sb = new StringBuilder(str); sb = sb.append(str); int c=1,sm=1;; for(int i=1;i<sb.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
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int INFMEM = 63; const int INF = 1061109567; const long long LINF = 4557430888798830399LL; const double DINF = numeric_limits<double>::infinity(); const long long MOD = 1000000007; const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}; const int dy[8]...
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.IOException; import java.io.InputStreamReader; import java.util.*; public class CF2 { public static void main(String[] args) { // TODO Auto-generated method stub FastReader s = new FastReader(); String str = s.next(); int n = str.length(); char[] arr = new char...
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_base::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = s.size(); int max = 1; int counter = 1; char a; a = s[0]; for (int i = 1; i < 2 * n - 1; i++) { if (s[i % (n)] != a) { counter++; a = s[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
s = input() a = [0]*len(s) prev = None l = 1 first = 0 for i in range(len(s)): if prev is not None and prev == s[i]: if first == 0: first = l-1 l = 1 a[i] = l prev = s[i] l += 1 ans = max(a) if s[-1] != s[0]: if a[-1]+first <= len(s): ans = max(ans, a[-1]+first) p...
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
# ========= /\ /| |====/| # | / \ | | / | # | /____\ | | / | # | / \ | | / | # ========= / \ ===== |/====| # code def main(): s = input() n = len(s) k = 1 mk = 1 if n == 1: print(1) retur...
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; 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
a=list(input()) ans=1 l=len(a) i=0 while i<l: count=1 j=i+1 while j<l: if a[j]!=a[j-1]: count+=1 j+=1 else: break if i==0: count1=count if j==l: count2=count ans=max(ans,count) i=j #print(ans,count1,count2) if a[0]==a[-1]: print(ans) else: print(min(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
s = input() last = s[0] count = 1 best = 1 for i in range(1, len(s) * 2): if last != s[i % len(s)]: count += 1 best = max(best, count) last = s[i % len(s)] else: count = 1 print(min(best, len(s)))
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 = 1e5 + 10; char s[N * 2]; int main() { cin >> s; int len = strlen(s); for (int i = 0; i < len; ++i) { s[i + len] = s[i]; } s[len + len - 1] = 0; int len2 = len + len - 1; int ans = 0; for (int i = 0, j = 0; j < len2; ++j) { while (j + 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C { public static void main(String[] args) throws IOException { MyScanner sc = new MyScanner(); PrintWriter out = new PrintWriter(System.out); ...
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 math_codet; import java.io.*; import java.util.*; import java.math.*; /****************************************** * AUTHOR: AMAN KUMAR SINGH * * INSTITUITION: KALYANI GOVERNMENT ENGINEERING COLLEGE * ******************************************/ public class lets_do { InputReader 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.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class C { FastScanner scanner; Prin...
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 = 4 * 100000 + 10; char ss[MAXN]; int main() { scanf("%s", ss); int cis; int len = strlen(ss); int l = len; for (int i = 0; i < len; i++) { ss[i + len] = ss[i]; } len = strlen(ss); int ans = 1; int maxx = 1; for (int i = 1; i < len; 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; template <class T> using vv = vector<vector<T>>; template <class T> ostream &operator<<(ostream &os, const vector<T> &t) { os << "{"; for (int(i) = 0; (i) < (t.size()); ++(i)) { os << t[i] << ","; } os << "}" << endl; return os; } template <class T, size_t 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
"""def f(s, d): if s not in d: d.add(s) for i in range(len(s) - 1): f(s[i::-1] + s[:i:-1], d) d = set() f('0123456789', d) print(len(d)) print(*sorted(list(d))) """ s = input() max_stripes = 1 cur_stripes = 1 i = 0 while i < len(s) - 1: if s[i] != s[i + 1]: cur_stripes += 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
import java.io.*; import java.math.BigInteger; import java.util.*; /** * Created by aditya on 5/3/17. */ public class Solution { static long MOD = 1000000007; static int n, m; public static void main(String args[]) throws Exception{ FastInput fi = new FastInput(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.util.*; import java.lang.*; import java.math.*; import java.io.*; /* spar5h */ public class cf3 implements Runnable{ final static long mod = (long)1e9 + 7; public void run() { InputReader s = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int t = 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
zebra = input() length = len(zebra) #Call this at the beginnign to check if unchanged string has longest sequence def checkLongest(zebra): longest = 0 curr = 0 prev = 0 for i in zebra: if ord(i) != prev: curr += 1 else: if curr > longest: longest = curr curr = 1 prev = ord(i) if curr > longest:...
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
from collections import defaultdict, deque, Counter from sys import stdin, stdout from heapq import heappush, heappop import math import io import os import math import bisect #?############################################################ def isPrime(x): for i in range(2, x): if i*i > x: brea...
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 * * @author Pradyumn */ public class M...
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=str(input()) fans=1 first=s[0] last=s[-1] i=0 j=len(s)-1 tempans=1 turns=0 counter=len(s)-1 while(i<counter and i<j and i<len(s)-1): if(turns%2==0): if(s[i]!=s[i+1]): tempans+=1 fans=max(tempans,fans) i+=1 else: if(first==last): tempa...
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 n = s.size(); s.insert(s.size(), s); int seq = 0, ans = 1; for (int i = 1; i < s.size(); i++) { if (s[i] != s[i - 1]) seq = seq == 0 ? 2 : seq + 1 > n ? n : seq + 1; else { ans = max(ans, seq); seq =...
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 = list(raw_input()) n = len(s) ans = 0 cur = 1 for i in range(1,n*2): if s[i%n] != s[(i-1)%n]: cur += 1 else: cur = 1 ans = max(ans,cur) print min(ans,n)
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
//package CodeForces.C; import java.util.Scanner; public class Task1025C { public static void main(String[] args) { Scanner scn = new Scanner(System.in); String s = scn.next(); int kol = 1; int max = 1; for(int i = 1; i<s.length(); i++){ if(s.charAt(i)!=s.charAt...
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; using namespace std; clock_t time_p = clock(); void Time() { time_p = clock() - time_p; cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n"; } const int INF = 1e9 + 7; long double pi = 3.1415926535897932; const long long INF64 = 9e18; const long long mod...
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 = (int)1e5 + 10; char s[maxn]; int dp[maxn]; int main() { scanf("%s", s); int n = strlen(s); dp[n - 1] = 1; int ans = 1; for (int i = n - 2; i >= 0; i--) { if (s[i] != s[i + 1]) { dp[i] = dp[i + 1] + 1; } else { dp[i] = 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
def zebra_len(zebra): l = 1 c = 0 p = "x" for z in zebra: if (p == "w" and z == "b") or (p == "b" and z == "w"): c += 1 l = max(l, c) else: c = 1 p = z return l class CodeforcesTask1025CSolution: def __init__(self): self.resul...
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.*; import java.io.*; public class Solve{ public static void main(String[] args) throws Exception{ Fast sc=new Fast(); StringBuilder sb=new StringBuilder(); String s=sc.next(); char[] c=s.toCharArray(); int n=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
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class B { InputStream is; PrintWriter out; String INPUT = ""; static int fun(String s){ s = s + s; int n = s.length(); int ans = 1; char start = s.charAt(0); ...
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.lang.*; import java.io.*; // THIS TEMPLATE MADE BY AKSH BANSAL. public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { 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.io.*; import java.util.StringTokenizer; public class C { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); String s = sc.next(); int ans = max(s.toCharArray()); String...
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 unsigned mod = 998244353; const unsigned _mod = 1e9 + 7; const long long infi = 0x3f3f3f3f3f3f3f3fll; const int inf = 0x3f3f3f3f; long long read() { long long x = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') { if (ch == '-') f = -1; ch = g...
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.*; import java.util.Scanner; import java.io.*; import javax.lang.model.util.ElementScanner6; import static java.lang.System.out; import java.util.Stack; import java.util.Queue; import java.util.LinkedList; public class C1025 { public static void main(String args[]) { Fast...
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 func(string &str) { int i, j, k, l = str.length(); int cnt, ans; cnt = ans = 0; cnt++; for (i = 0; i + 1 < l; i++) { if (str[i] != str[i + 1]) { cnt++; } else { ans = max(ans, cnt); cnt = 1; } } ans = max(ans, cnt); return a...
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() prev = '' index = -1 for i in xrange(len(s)): c = s[i] if prev == c: index = i break else: prev = c if index == -1: print len(s) exit() else: start = index m = -1 count = 1 prev = s[start] for i in xrange(1,len(s)+1): j = (start + i...
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() l = len(s) s = s*2 c,ma = 1,1 f = 0 for i in range(2*l-1): if s[i] == s[i+1]: f = 1 if c > ma: ma = c c = 0 c += 1 if f == 0: ma = c if ma > l: print(l) else: print(ma)
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; #pragma warning(disable : 4996) string S; int t = 0, maxn = 0; int main() { cin >> S; t = 1; maxn = 1; for (int i = 1; i < S.size() * 3; i++) { char c1 = S[i % S.size()]; char c2 = S[(i - 1) % S.size()]; if (c1 != c2) { t++; } else t = 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 = 1000 * 1000 * 1000 + 7; const double pi = acos(-1.0); const double eps = 1e-9; const long long inf = 1e18; int toint(string s) { int sm; stringstream ss(s); ss >> sm; return sm; } long long tolint(string s) { long long sm; stringstream ss(s...
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; template <class RandomAccessIterator> void Print(RandomAccessIterator first, RandomAccessIterator last, char endl1 = '\n', char endl2 = ' ') { while (first != last) cout << (*first++) << (last - 1 == first ? endl1 : endl2); } struct QuickIO { QuickIO() { ...
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() s=s+s+s m=cur=1 for i in range(len(s)-1): if s[i]!=s[i+1]: cur+=1 m=max(m,cur) else: cur=1 print(min(m,len(s)//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
// @jagrit_07. import java.util.*; import java.math.*; import java.io.*; import java.lang.*; public class Main { public static void main(String[] args) { FastReader sc = new FastReader(); char ch[] = sc.next().toCharArray(); if(ch.length==1) { System.out.println(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.util.*; import java.io.*; public class zerbra { public static void main(String[] ag) throws IOException{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); char[] s = reader.readLine().toCharArray(); int n = 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
// @jagrit_07.. import java.util.*; import java.math.*; import java.io.*; import java.lang.*; public class Main { public static void main(String[] args) { FastReader sc = new FastReader(); char ch[] = sc.next().toCharArray(); if(ch.length==1) { System.out.println(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
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; const long long mod = 998244353; const int phash = 3; const long long modhash = 1000000000000000003; char c[2] = {'b', 'w'}; int main() { ios_base::sync_with_stdio(false); stri...
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
from __future__ import division from math import log from math import ceil from bisect import bisect_right as br from bisect import bisect_left as bl r = raw_input() z = [] ch = '' st = 0 en = 0 l = 1 mst = 0 ml = 0 for i in range(0, len(r)-1) : if(r[i] != r[i+1] ): en+=1; else: z.append([st,en]) if en-st+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
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.size(); s += s; int count = 1; int maxc = 1; for (int i = 0; i < s.size() - 1; i++) { if (s[i] != s[i + 1]) count++; else { maxc = max(maxc, count); count = 1; } } maxc = max(maxc, co...
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 sys def input(): return sys.stdin.readline().strip() s = input() n = len(s) if n == 1: print(1) sys.exit() seq = [1] for i in range(1, n): seq.append(seq[i - 1] + 1 if s[i] != s[i - 1] else 1) ans = max(seq) if ans == n: print(n) sys.exit() if s[0] != s[-1]: i = 1 while 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
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int len = s.size(); if (len == 2) { if (s[0] == s[1]) { cout << "1" << endl; } else { cout << "2" << endl; } return 0; } int f = 0, best = 0; for (int i = 0; i < len; i++) { int f = i, l = 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; const int lim = 2e5 + 5; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; s += s; int cnt = 0; char lseen = 'g'; int n = s.size(); int gcnt = 1; for (int i = 0; i < n; ++i) { if (lseen != s[i]) ++cnt; else cn...
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 = (int)1e5 + 5; int dp1[N]; int main() { string s; cin >> s; dp1[0] = 1; int ans = 1; for (int i = 1; i < s.length(); i++) { if (s[i] != s[i - 1]) { dp1[i] = dp1[i - 1] + 1; } else { dp1[i] = 1; } ans = max(ans, dp1[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; int n = s.length(); int cnt = 1; int ans = 0; bool b = true; for (int i = 1; i < n; ++i) { if (s[i] == s[i - 1]) { b = false; break; } } if (b) { cout << n << endl; return 0; } s += s; 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
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Problem505C { public static void main(String[] args) { // TODO Auto-generated method stub out=new PrintWriter (new BufferedOutputStream(...
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.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.BufferedReader; import java.io.Reader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-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
/** * BaZ :D */ import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { static MyScanner scan; static PrintWriter pw; public static void main(String[] args) { new Thread(null,null,"BaZ",1<<25) { public void run() { tr...
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 res, sofar = 1, 1 for i in range(1,len(s)): if s[i] == s[i-1]: sofar = 1 else: sofar += 1 res = max(res,sofar) print(min(res,len(s)//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
def ct(t): j=t[0];ans=1;ansSet=set() for i in t[1:]: if j!=i: ans+=1 else: ansSet.add(ans) ans=1 j=i ansSet.add(ans) return max(ansSet) txt=raw_input() if txt[0]==txt[-1]: print ct(txt) else: for i in xrange(len(txt)-1): if txt[i]==txt[i+1]: txt=txt[:i+1][::-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
from itertools import cycle s1 = input() s = cycle(s1) mx = 1 numb = 1 steps, krug = 0, 0 cur = [] for i in s: if len(cur) < 2: cur.append(i) if len(cur) == 2: if cur[0] != cur[1]: numb += 1 del cur[0] else: if numb > mx: mx = numb ...
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> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; long long int l[100010], r[100010]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; long long int n = s.size(); long long int ans = 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
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; s = s + s; long long int n = s.size(), i, l = 1, ans = 0; char c = s[0]; if (c == 'b') c = 'w'; else c = 'b'; for (i = 0; i < n; i++) { if (s[i] == c) { l++; if (c == 'b') c = 'w'; 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; const int maxn = 110; const int INF = 0x3f3f3f3f; char s[200005]; int main() { memset(s, 0, sizeof(s)); scanf("%s", s); int n = strlen(s); for (int i = 0; i < n; i++) { s[i + n] = s[i]; } int now = 1; int ans = 0; for (int i = 1; i < 2 * n; i++) { if...
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() ans = 1 m = [1] * len(s) for i in range(1, len(s)): if s[i] != s[i-1]: m[i] = m[i-1] + 1 if m[i] > ans: ans = m[i] else: m[i] = 1 if s[0] != s[-1]: if m[-1] == len(s): print(m[-1]) exit() else: for i in range(len(s)): ...
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> char zebra[100005]; int max; int main() { scanf("%s", zebra + 1); max = 0; int n = strlen(zebra + 1); int t = 0; int ans = 0; for (int i = 1; i <= n; i++) { int k = 1; while (zebra[i] != zebra[i + 1] && i + 1 <= n) { k++; i++; } if (i == n && t == 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
#include <bits/stdc++.h> using namespace std; string helper(int n, int m, int k, vector<vector<int>> &dp) { string res = ""; if (k > dp[n][m]) return ""; while (k > 0 && n > 0) { if (dp[n - 1][m] >= k) { res += "0"; n--; } else { res += "1"; k = k - dp[n - 1][m]; 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
import java.util.*; public class C { public static void main(String[] args) { Scanner console = new Scanner(System.in); String zebra = console.nextLine(); int result = 1; int temp = -1; if (zebra.length() == 1) { System.out.println(1); } else { temp = 1; for (int i = 1; i <= 2 * zebra.length(); 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; const int maxn = 200005; char s[maxn]; int main() { scanf("%s", s); int n = strlen(s); for (int i = 0; i < n; i++) { s[n + i] = s[i]; } int mx = 1, cnt = 1, flag = 0; for (int i = 0; i < 2 * n - 1; i++) { if (i == flag + n - 1) break; if (s[i] != s[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
def per(c): if c=='w': a=0 else: a=1 return(a) s=input() l=[] a=1 first=per(s[0]) last=per(s[-1]) for i in range(1,len(s)): if per(s[i-1])+per(s[i])==1: a+=1 else: l.append(a) a=1 i+=1 l.append(a) if first+last==1 and len(l)!=1: l.append(l[0]+l[-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
a=input() n=len(a) b=[] c=0 d=0 for i in range(1,n): if a[i]==a[i-1]: b.append(['bw'.find(a[c]),i-c]) d=max(d,i-c) c=i b.append(['bw'.find(a[c]),n-c]) d=max(d,n-c) if d<n and b[0][0]==(b[-1][0]+b[-1][1])%2: d=max(d,b[-1][1]+b[0][1]) print(d)
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.length(); int ans = 1; for (int i = 0; i < n; i++) { int temp = 1, j = i; while (a[j % n] != a[(j + 1) % n]) { j++; temp++; if ((j + 1) % n == i) { break; } } 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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { private FastScanner scanner = new FastScanner(); public static void main(String[] args) { new Main().solve(); } int k; private void solve() { Strin...
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.util.*; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.Random; import java.util.Set; import java.util.StringTokenizer; public class A { public static void main(String[] args) { FastScanner ...
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() { int n; string s; char cur; int beg = 1, end, mid = 0; int i, j; cin >> s; n = s.length(); end = n - 2; cur = s[0]; while (beg < n && s[beg] != cur) cur = s[beg++]; cur = s[n - 1]; while (end >= 0 && s[end] != cur) cur = s[end--]; end++...
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; string str; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> str; N = (int)(str.size()); str += str; int mxl = 1; int cur = 1; for (int i = 1; i <= N * 2 - 1; i++) { if (str[i] != str[i - 1]) { cur++; mxl = max(mxl, cur); ...
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 sys input=sys.stdin.readline s=list(input().rstrip()) n=len(s) s.extend(s) cnt=0 c=1 for i in range(len(s)-1): if s[i]!=s[i+1]: c+=1 else: cnt=max(c,cnt) c=1 cnt=max(cnt,c) print(min(cnt,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.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.PrintStream; import java.util.*; public class Main { public static String s=""; public static int gcd(int a, int b) { if(a>b) { int c=a; a=b; b=c; } if(a == 0) return b; return gc...
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() * 2 l = len(s) i = 0 ans = 1 def check(): global i res = 1 last = s[i] stop = min(l, i + l // 2) i += 1 while i < stop: if s[i] == last: break else: res += 1 last = s[i] i += 1 return res while i < l // 2: 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
s = raw_input() n = len(s) dp = [1]*n for i in range(1,n): if s[i]!= s[i-1]: dp[i] = dp[i-1]+1 maxv = dp[-1] if s[0]!=s[-1]: for i in range(n): if dp[i]<=i: maxv += i break maxv = min(n,max(maxv,max(dp))) print maxv
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.io.*; import java.util.*; import java.lang.*; public class Rextester{ public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); br.close(); boolean doneBeg = false,doneEnd...
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 read(int &x) { int v = 0, f = 1; char c = getchar(); while (!isdigit(c) && c != '-') c = getchar(); if (c == '-') f = -1; else v = v * 10 + c - '0'; while (isdigit(c = getchar())) v = v * 10 + c - '0'; x = v * f; } void read(long long &x) { long...
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 ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) s = input().strip() n = len(s) s += s p = ans = 1 for i in range(1, len(s)): if s[i] == s[i - 1]: p = 1 else: p += 1 ans = max(ans, p) ans = min(ans, n) 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.*; import java.util.*; import java.math.BigInteger; import java.util.Map.Entry; import static java.lang.Math.*; public class C extends PrintWriter { void run() { char[] str = next().toCharArray(); int n = str.length; int[] r = new int[n]; r[n - 1] = 1; fo...
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_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; int n; int l = s.length(); int ans = 1; int cnt = 1; for (int i = 0; i < 2 * l; i++) { if (s[i % l] != s[(i + 1) % l]) cnt++; else { cnt = 1; } an...
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.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
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.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class PlasticineZebra { void solve() { char[] s = in.nextToken().toCharArray(); int n = s.length; 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.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.util.Arrays; import java.util.InputMismatchException; /** * @author thesparkboy * */ public class temp { public static void main(String[] args) { InputReader 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
#include <bits/stdc++.h> using namespace std; int alternate(string& s, int pos) { char c = s[pos]; int i = pos + 1, ans = 1; while (i < s.size() && s[i] != c) { c = s[i]; ans++; i++; } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; int mx ...
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) s = s + s cnt = ans = 1 for i in range(1, len(s)): cnt = (cnt+1) if s[i] != s[i-1] else 1 ans = max(ans, cnt) if ans > n: ans = n 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 math s=input() n=len(s) str=s+s i=0 j=0 m=0 while(i<n): j = i while(j-i+1<n): if(str[j] != str[j+1]): j+=1 else: break m=max(m,j-i+1) i=j+1 print(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
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 Jenish */ public class Ma...
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() c = 1 mx = 1 for i in range(len(s) - 1): if s[i] != s[i + 1]: c += 1 else: if s[0] != s[-1]: s = s[:i + 1][::-1] + s[i + 1:][::-1] c += 1 # print(s) else: if c > mx: mx = c c = 1 # print(s) print(...
PYTHON3