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; const int max_n = 100005; string s; int l[max_n * 2]; int main() { cin >> s; s += s; int ans = 0; for (int i = 1; i < s.size(); i++) { if (s[i] != s[i - 1]) l[i] = l[i - 1] + 1; ans = max(ans, l[i]); } printf("%d\n", min((int)s.size() / 2, ans + 1)); 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
s=input() i=1 n=len(s) ans=0 curr=1 while i<n: if s[i]!=s[i-1]: curr+=1 else: ans=max(ans,curr) curr=1 i+=1 ans=max(ans,curr) i=1 new=0 while i<n and s[i]!=s[i-1]: i+=1 j=n-2 l=1 if s[0]!=s[-1]: while j>=i and s[j]!=s[j+1]: j-=1 l+=1 if ans!=n and s[0]!=s[-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.util.Arrays; import java.util.Collections; import java.util.Scanner; /** * * @author Arpit */ public class JavaApplication174 { /** * @param args the command line arguments */ //public void gen(int arr[]) public static void main(String[] args) { // TODO code...
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
from collections import deque s=raw_input().strip() s=s.replace('b','0') s=s.replace('w','1') s=map(int,s) ans = 0 ind = 0 Cur = 0 while ind<len(s): if Cur == 0: Cur += 1 need = 1-s[ind] ind += 1 elif need == s[ind]: Cur += 1 ind += 1 need = 1-need else: ...
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.length(), cur = 1, best = 1; s += s; for (size_t i = 1; i < s.size(); i++) if (s[i] != s[i - 1]) cur++; else { best = max(best, cur); cur = 1; } best = max(best, cur); cout << min(n, best...
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.*; import java.lang.*; import java.math.*; public class C { public static void main(String[] args) throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(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
s = input().strip() n = len(s) a = '' for i in range(n): if i == 0: l = n-1 else: l = i-1 if s[l] != s[i]: a += s[i] else: break s += a r = 1 sum = 1 for i in range(1,len(s)): if s[i] != s[i-1]: sum += 1 else: sum = 1 r = max(r, sum) print(min...
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 double inf = 1e-9; int eps = 1e9 + 7; long long Eps = 1e12; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; int max1 = 1; int i = 1; while (i < s.size() && s[i] != s[i - 1]) { i++; } i--; int j = s.size() - ...
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 TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << " = " << h << endl; } template <class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) { while (*sdbg != ',') cerr << *sdbg++; cerr << " = " << h << ", "; _dbg(sdbg + 1, a...); } 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
import java.util.*; import java.io.*; public class Main { static long startTime = System.currentTimeMillis(); // for global initializations and methods starts here // global initialisations and methods end here static void run() { boolean tc = false; //AdityaFastIO r = new AdityaFas...
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 >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } char s[2 * 100000 + 5];...
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 second; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> second; int cur = 1; int n = second.size(); if (n == 1) cout << 1, exit(0); int ans = 1; for (int i = 1; i < n; 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; #pragma comment(linker, "/STACK:102400000,102400000") template <class T> void chkmax(T &a, T b) { if (a < b) a = b; } template <class T> void chkmin(T &a, T b) { if (a > b) a = b; } const int inf = 0x3f3f3f3f; const long long linf = 2e18 + 100; const double dinf = 2e18 ...
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 Mainn { 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(); 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.Scanner; public class PlasticineZebra { public static void main(String[] args) { String str = new Scanner(System.in).next(); int start = 1; for (int i = 1; i < str.length(); i++) { if (str.charAt(i) != str.charAt(i - 1)) start++; else break; ...
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.awt.color.*; import java.util.*; import java.awt.Point; import java.math.*; import java.io.*; @SuppressWarnings("unused") public class constructivealgo {int[] b; String g="";int c=0;int M=1000000000+7;ArrayList<Integer> list=new ArrayList<Integer>();String s;int[] size;int[] id; int[]ab;int[] data;int mod...
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 main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s; s += s; int dp = 0, ans = 1; char last = '#'; for (auto e : s) { if (e == last) { dp = 1; } else { ++dp; ans = max(ans, dp); last = e; ...
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; char s[160000]; int main() { scanf("%s", s); int n = strlen(s); int p = 0, q = 0; int move = 0; int ans = 0; while (true) { while (s[(q + 1) % n] != s[q] && (q + 1) % n != p) { q = (q + 1) % n; } ans = max(ans, q - p < 0 ? q - p + n + 1 : q - p...
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=[i for i in input() if i!='\n'] def checker(s): forw,back=0,0 for i in range(1,len(s)): if s[i-1]!=s[i]: forw+=1 else: break for i in range(len(s)-1,0,-1): if s[i]!=s[i-1]: back+=1 else: bre...
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; long long n, m, q, k; string s; int MOD = 1e9 + 7; const int INF = 1e9; const long long INF64 = 2e18; const double PI = 3.141592653589793238463; long long ar[100004], ar1[100004], vis[100004], pre[100004], dp[3004][3004]; vector<long long> gr[100004], path; set<long long> 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.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class CopyOfMain { public static void main(String[] args)...
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 N = 2e5 + 50; const int MOD1 = 1e9 + 7; const int MOD2 = 19260817; using namespace std; int len, cnt, ans; char s[N]; int read() { int s = 0, t = 1; char c; while (c < '0' || c > '9') { if (c == '-') t = -1; c = getchar(); } while (c >= '0' && c <= '9') { s = 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; int main() { string str; cin >> str; int maxLen = 0; bool circleCompl = false; for (int i = 0; !circleCompl && i < str.size(); i++) { int count = 0; int j = i + 1; if (j >= str.size()) { j -= str.size(); circleCompl = true; } if (st...
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::sync_with_stdio(false); string s; cin >> s; long long int N = s.size(); long long int M = 2 * N; vector<long long int> a(M); for (long long int i = 0; i < (long long int)(N); ++i) a[i] = s[i] == 'w'; for (long long int i = 0; i < (long 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
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.write(nam...
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; vector<int> p(100005, 1), prime; void sieve() { p[0] = p[1] = 0; for (int i = 2; i * i <= 100005; i++) { if (p[i]) { for (int j = i * i; j < 100005; j += i) { p[j] = 0; } } } for (int i = 2; i < 100005; i++) if (p[i]) prime.push_back(...
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.*; /** * Copyright © 2018 Chris. All rights reserved. * * @author Chris * 2018/7/9 15:33 * @see format */ public class C { private static BufferedReader br; private static StreamTokenizer st; private static PrintWriter pw; private static void solve() throws IOException { ...
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.PrintWriter; import java.util.Scanner; public class A { public static void main(String[]args) { Scanner zizo = new Scanner(System.in); PrintWriter wr = new PrintWriter(System.out); String s = zizo.next(); int c = 1; int ans = 1; for(int i = 0;i < 2 * s.length(); i++) { if(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; int main() { string a; cin >> a; int n = a.length(); int cnt = 1; int mx = 0; int ind = 1; for (int i = 1; i < 2 * n; i++) { if (a[i % n] != a[(i - 1) % n]) cnt++; else { mx = max(mx, cnt); cnt = 1; } } mx = max(mx, cnt); 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
s = map(lambda x: 1 if x == 'b' else 0, list(raw_input().strip())) sl = 1 ml = 1 for i in range(1, len(s)): if s[i] != s[i - 1]: sl += 1 else: ml = max(ml, sl) sl = 1 ml = max(ml, sl) s1 = 1 for i in range(1, len(s)): if s[i] != s[i - 1]: s1 += 1 else: break 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
import javax.swing.plaf.synth.SynthOptionPaneUI; import java.util.Scanner; import java.util.*; import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.negateExact; public class Main { public static void main(String[] args) { Scanner in = new Scanner(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.Scanner; public class Main { private static int[] dp = new int[200010]; public static void main(String[] args) throws Exception { Scanner scan = new Scanner(System.in); String string = scan.next(); String s = string + string; int i , length = s.length() , ans = 0; for (i = 0;i < l...
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.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import static java.lang.Math.*; public class PlasticineZebra implements Closeable { private InputReader...
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 r(string& str) { int n = str.size(); for (int i = 0; i < n / 2; i++) swap(str[i], str[n - i - 1]); } int find(string s) { int m = 1, now = 1; for (int i = 0; i < s.size() - 1; i++) { if (s[i] == s[i + 1]) m = max(now, m), now = 1; else now++...
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 warning(disable : 4018) using namespace std; const int Inf = int(1e9) + 7; namespace { int get(const string& s, int l, int r) { int ans = 1; for (int i = l + 1, cur = 1; i < r; i++) { if (s[i] != s[i - 1]) cur += 1; else cur = 1; ans = max(ans, cur); } re...
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 *= 2 prv, res, cnt = '$', 0, 0 for i in s: if (i != prv): cnt += 1 else : cnt = 1 prv = i res = max(res, cnt) print(min(len(s)//2, res))
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
// Don't place your source in a package import javax.swing.*; import java.lang.reflect.Array; import java.text.DecimalFormat; import java.util.*; import java.lang.*; import java.io.*; import java.math.*; import java.util.stream.Stream; // Please name your class Main public class Main { static FastScanner fs=ne...
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 static java.lang.Math.*; public class C { public Object solve() { String S = sc.next(); char [] X = (S + S).toCharArray(); int res = count(X); res = min(S.length(), res); exit(res); return null; } int count (char [] A) { int res = 1, p = 0, q = 1, N = A.length; while (q < N) { if (A[q] ...
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 ch[100000 + 7]; char str[200000 + 7]; int main() { scanf("%s", ch); int len = strlen(ch); for (int i = 0; i < len; i++) { str[i] = ch[i]; str[i + strlen(ch)] = ch[i]; } int ans = 1, ans_max = 0; for (int i = 0; i < strlen(str) - 1; i++) { if (st...
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 CFC { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; private static final long MOD = 1000L * 1000L * 1000L + 7; private static final int[] dx = {0, -1, 0, 1}; private static final int[] dy = {1, 0, -1, 0}; privat...
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 target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") #pragma GCC optimize("unroll-loops") using namespace std; void Draganov47(string click) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void submit() { string s; cin >> 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
import sys f=sys.stdin s=f.readline().rstrip('\r\n') arr=[] cnt=1 ma=0 for i in range(1,len(s)): if s[i]!=s[i-1]: cnt+=1 else: ma=max(ma,cnt) cnt=1 ma=max(ma,cnt) if ma==len(s): print(str(ma)+"\n") else: cnt1=1 cnt2=1 if s[0]!=s[-1]: for i in range(1,len(s)): if s[i]!=s[i-1]: cnt1+=1 else: ...
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[310000]; int n, m, ans; inline void wor() { int he = 1, le = 1; for (int i = 2; i <= m; i++) { if (le >= n) { he++; le--; } if (s[i] != s[i - 1]) { le++; if (le > ans) ans = le; } else { he = i; le = 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() { string s; cin >> s; string l; l = s + s; int may = 0; int cont = 1; for (int i = 0; i < l.length() - 1; i++) { if (l[i] == l[i + 1]) { may = may < cont ? cont : may; cont = 1; } else { cont++; } } may = may < cont...
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.lang.*; import java.io.*; import java.awt.*; // U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................ // ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 2 = 3.3219 // odd:: (x^2+1)/2 , (x^2-1)/2 ; x>=3// even:: (x^2/4)+1 ,(x^2/4)-1 x >=4 //...
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 test_3(): # A - import math from collections import Counter ss = input() n = len(ss) ss = ss+ss max = 0 count = 1 for i in range(1, len(ss)): if ss[i] != ss[i-1]: count += 1 else: count = 1 if max < count: max = count ...
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; int ds = 0; int ls = 0; for (int i = 1; i < s.size(); i++) { if (s[i] == s[i - 1]) { ds = i; } ls = max(ls, i - ds + 1); } cout << min(ls, (int)s.size() / 2) << endl; return 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 s; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> s; int n = s.size(); s += s; char p = 'a'; int cur = 0, mx = 0; for (char x : s) { if (x != p) mx = max(++cur, mx); else cur = 1; p = x; } cout << 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
s = input() n = len(s) rec = [] pre = s[0] prei = 0 for i in range(1, n): if pre != s[i]: pre = s[i] continue else: rec.append(s[prei: i]) pre = s[i] prei = i rec.append(s[prei:]) num = 0 for i in rec: num = max(num, len(i)) if len(rec) >= 2: if rec[0][0] != re...
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 sys import stdin, stdout ti = lambda : stdin.readline().strip() ma = lambda fxn, ti : map(fxn, ti.split()) ol = lambda arr : stdout.write(' '.join(str(i) for i in arr) + '\n') os = lambda i : stdout.write(str(i) + '\n') olws = lambda arr : stdout.write(''.join(str(i) for i in arr) + '\n') s = ti() news = list(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
s = input() s += s cnt, res, prev = 1, 1, s[0] for i in range(1, len(s)): if s[i] is not prev: cnt += 1 else: res = max(res, cnt) cnt = 1 prev = s[i] res = max(res, cnt) 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
#include <bits/stdc++.h> using namespace std; string s; int ans; int main() { cin >> s; int l = s.length(); s += s; int cnt = 1; for (int i = 1; i < l * 2; i++) { if (s[i] != s[i - 1]) cnt++; else ans = max(ans, cnt), cnt = 1; } ans = max(ans, cnt); cout << min(ans, l) << endl; ret...
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.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
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.Arrays; import java.util.InputMismatchException; public class Zebra1025C { InputStream is; PrintWriter out; String INPUT = ""; void solve() { String s= ns(); s = s+s; c...
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 long double EPS = 1e-9; const long long MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout << setprecision(20); string s; cin >> s; int n = s.size(); s += s; char c = 'w'; int ans = 0; char prev = s[0] == 'w' ? '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
#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(); if (s[0] == s[n - 1]) { int x = 1; int best = x; for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) x = 1; else x++; 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
#########################################################################################################\ ######################################################################################################### ###################################The_Apurv_Rathore##################################################### #...
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 long long gcd(long long a, long long b) { a = ((a) < 0 ? -(a) : (a)); b = ((b) < 0 ? -(b) : (b)); while (b) { a = a % b; swap(a, b); } return a; } const long long inf = 2147383647; const long long mod = 1000000007; const double pi = 2 * acos(0.0); c...
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.*; //Question C 502 public class Main2 { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = br.readLine(); int n = s.length(); int[] l= new int[n]; int[] r= new int[n]; int ans = ...
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.Scanner; public class c { public static void main(String[] args) { Scanner in = new Scanner(System.in); char[] str = in.next().toCharArray(); int N = str.length; int[] switchArr = new int[N]; for(int n=0;n<N;n++){ if(str[n] != str[(n+1)%N]){ switchArr[n] = 1; } } int consecSwa...
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 decimal,math from collections import * from fractions import gcd from bisect import bisect_right,bisect_left import sys decimal.getcontext().prec = 15 def primeFactors(n): arr =set([]) while n % 2 == 0: arr.add(2) n = n / 2 for i in xrange(3,int(math.sqrt(n))+1,2): while n % i== 0: arr.add(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
import java.io.*; import java.util.*; public class PlasticineZebra { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream);...
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.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.FileNotFoundException; import java.util.StringTokenizer; import java.io.Writer; import java.io.Buffer...
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 long long LINF = 1e18; const int INF = 1e9 * 2; const int MOD = 1e9 + 7; const int modulo = 1e8; const int nax = 2 * 1e5; void solve() { string s; cin >> s; int cur = 1; s += s; int ans = 0; for (int i = 1; i < (int)s.size(); i++) { if (s[i] != s[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
#include <bits/stdc++.h> using namespace std; long long int powm(long long int base, long long int exp) { long long int ans = 1; while (exp) { if (exp & 1) ans = (ans * base) % 1000000007; exp >>= 1, base = (base * base) % 1000000007; } return ans; } int main() { string second; cin >> second; int ...
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
n = raw_input() slen = len(n) if slen == 1: print(1) exit(0) slst = n + n cnt = 0 lastcnt = -1 for i in range(1, 2*slen, 1): if slst[i] != slst[i-1]: cnt += 1 else: lastcnt = max(cnt, lastcnt) cnt = 1 lastcnt = max(cnt, lastcnt) if lastcnt > slen: lastcnt = slen print(lastcnt...
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() { int n, c = 1, mx = 0; string a; cin >> a; n = a.size(); for (int i = 1; i < n; i++) { if (a[i] != a[i - 1]) c++; else { mx = max(mx, c); c = 1; } } mx = max(mx, c); if (a[0] != a[n - 1]) { c = 2; for (int 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; 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 = 1e5 + 6.66; int main() { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); string str; cin >> str; int n = str.size(); int ans = 0; char prv = '3'; int len = 0; for (int i = 0; i < 2 * n; i++) { char now = str[i % n]; 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
#include <bits/stdc++.h> using namespace std; int a[705]; int g[705][705]; int gcd(int a, int b) { if (!b) return a; return gcd(b, a % b); } int dp[705][705]; int d[100500]; int main() { ios_base::sync_with_stdio(false); string s; cin >> s; int n = s.length(); s += s; d[0] = 1; int res = 1; for (int...
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() i = 0 j = len(s) - 1 c = 1 while i + 1 < len(s) and s[i] != s[i + 1]: c += 1 i += 1 if i + 1 < len(s) and s[0] != s[len(s) - 1]: i = 0 s = s[::-1] while i + 1 < len(s) and s[i] != s[i + 1]: c += 1 i += 1 c += 1 c2 = 1 c2_max = 0 for i in range(len(s) - 1): if s[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
s=raw_input() s=s+s n=len(s) res=0 j=0 while j<n: st=j j+=1 while j<n and s[j]!=s[j-1]: j+=1 res=max(res,j-st) if res>n/2: print n/2 else: print res
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 void main(String[] args) { Scanner sc = new Scanner(System.in); int last; char ch_l; int t_max; int ans; String str_f; String str = sc.nextLine(); if(str.length()>2) { StringBui...
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 ans = cur = 1 for i in range(1, len(s)): if s[i] != s[i - 1]: cur += 1 ans = max(ans, cur) else: cur = 1 ans = min(ans, len(s) // 2) 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
#include <bits/stdc++.h> using namespace std; int a[200000]; int flag[200000]; int main() { string str; cin >> str; int n = str.length(); int maxl = 0; int start = 0; for (int i = 1; i < 2 * n + 8;) { int after = i % n; int before = (i - 1 + n) % n; if (str[after] == str[before]) { 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
#include <bits/stdc++.h> using namespace std; int main() { string str; int sum = 0, maxx = 0; bool f1 = false, f2 = false; cin >> str; str += str; for (int i = 1; i < str.size(); i++) { if (str[i] == 'b') f1 = true; if (str[i] == 'w') f2 = true; if (str[i] != str[i - 1]) sum++, maxx = 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; int main() { char ch[400010]; scanf("%s", ch); int len = strlen(ch), l = len, ans = 1, maxx = 1; for (int i = 0; i < len; i++) { ch[i + len] = ch[i]; } len = strlen(ch); for (int i = 1; i < len; i++) { if (ch[i] != ch[i - 1]) { maxx++; 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.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
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 Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next()...
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.lang.*; import java.util.HashMap; public class templ implements Runnable { class pair { int v,val; pair(int f,int s) { v=f; val=s; } } //public static ArrayList<Integer> g[]=new ArrayList[1000000]; ...
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 check(st): count = 1 i = 1 pre = st[0] maxi = 0 pre_indx = 0 indx = [0 for i in range(n)] while i<n: if pre != st[i]: count+=1 else: indx[pre_indx] =count count=1 pre_indx=i pre =st[i] i+=1 indx[pre_indx]...
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+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)//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 double eps = 1e-8; const int M = 1e5 + 5; const int N = 1e6 + 5; const int mod = 1e9 + 7; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const long long lINF = 0x3f3f3f3f3f3f3f3fLL; const int sINF = 0xcfcfcfcf; char s[M * 2], s1[M]; int mx, tmp, len; int ma...
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 = 1e5; const double Pi = acos(-1.0); long long a[maxn], b[maxn]; char s[maxn]; char tem[maxn]; int main() { while (~scanf("%s", &s)) { int len = strlen(s); int res = 1; int te = 1; int flag = 1; int val = 1; if (len > 2) { for ...
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(0); string s; int d[100009], c[100009]; cin >> s; int n = s.size(); if (n == 1) { cout << 1; return 0; } d[0] = 1; for (int i = 1; i <= n - 1; i++) { if (s[i] != s[i - 1]) d[i] = d[i - 1] + 1; el...
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
//codeforces_1025C //tut import java.io.*; import java.util.*; import static java.lang.Math.*; import java.math.*; public class acm { static PrintWriter go = new PrintWriter(System.out); //takeaway: 'Arrays.fill()' (as well as 'new int[n]') eats up a huge amount of time //so avoid using these inside large ...
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 static java.lang.Math.*; public class cfs505C { public static void main(String[] args) { FastScanner sc = new FastScanner(); StringBuilder sb = new StringBuilder(); char[] s = sc.next().toCharArray(); int n = s.length; int maxCo...
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 Main { static long startTime = System.currentTimeMillis(); // for global initializations and methods starts here // global initialisations and methods end here static void run() { boolean tc = false; //AdityaFastIO r = new AdityaFas...
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 = raw_input() while True: i = -1 while True: i-=1 if i<-len(s) or s[i]==s[i+1]: break ts=s if s[0] != s[-1]: s = s[i+1:]+s[:i+1] else: break if ts==s: break i=1 ans = 1 tmp=1 while i<len(s): if s[i] == s[i-1]: if tmp>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
import java.util.*; import java.util.Arrays; public class Lo { public static void main(String[] args) { Scanner sc = new Scanner(System.in); //int t =sc.nextInt(); String str = sc.next(); str +=str; char[] a = str.toCharArray(); int m1 = 1; 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.*; /* * Heart beats fast * Colors and promises * How to be brave * How can I love when I am afraid... */ public class Main { public static void main(String[]args) throws Exception { String s=ns(); s=s.concat(s); int ans=1; int te=1; boolean last=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
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int st = 1, en = 1; int ans = 1; int n = s.length(); if (s[0] != s[n - 1]) { for (int i = 1; i < n; i++) { if (s[i] != s[i - 1]) st++; else break; } for (int i = n - 2; i >= 0; 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; 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
s=input().strip() s=s+s n=len(s) an=1 m=1 #print(s) for i in range(1,n): if s[i]!=s[i-1]: m+=1 an = max(an, m) else: an = max(an, m) m=1 #print(an) print(min(an,n//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() #s='bwwwbwwbw' n=len(s) if n==1: print 1 exit() if n==2: if s[0]==s[1]: print 1 exit() else: print 2 exit() def cal(s): n=len(s) if n==1: return 1 ct=1 maxct=1 for i in range(1,n): if s[i]!=s[i-1]: ct+=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.length(); int fir = s[0], sec = s[0], pos_right = 0, pos_left = n - 1; int counter = 0; bool flag = true; int last_right = -1, last_left = n, cur = 1; while (flag) { if (cur == 1) { last_right = pos_right;...
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=str(input()) m=0 n=len(s) a=s[0] s+=s t=0 for i in range(n*2-1): if s[i+1]==a: if t>m: m=t t=0 else: t+=1 if t==n: m=t a=s[i+1] print(m+1)if m<n else print(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.*; import java.math.BigInteger; import java.util.*; public class Main { /* static StreamTokenizer in=new StreamTokenizer(new BufferedReader((new InputStreamReader(System.in)))); static int nextInt() throws IOException { in.nextToken(); return (int)in.nval; } static long n...
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; signed main() { string s; cin >> s; long long n = s.length(); s = s + s; long long i = 0; long long res = 0; while (i < n) { long long j = i; while (j - i + 1 < n) { if (s[j] != s[j + 1]) j++; else break; } res = 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; string S; int prefix[2000006]; int main() { int N, i, j, k; cin >> S; S += S; N = S.size(); prefix[0] = 1; int ans = 0; for (i = 1; i < N; i++) { if (S[i] != S[i - 1]) prefix[i] = prefix[i - 1] + 1; else prefix[i] = 1; ans = max(ans, pr...
CPP