message stringlengths 2 23.8k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 97 109k | cluster float64 0 0 | __index_level_0__ int64 194 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by underscores). All patterns are pairwise distin... | instruction | 0 | 44,054 | 0 | 88,108 |
Tags: bitmasks, data structures, dfs and similar, graphs, hashing, sortings, strings
Correct Solution:
```
import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split(... | output | 1 | 44,054 | 0 | 88,109 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by underscores). All patterns are pairwise distin... | instruction | 0 | 44,055 | 0 | 88,110 |
Tags: bitmasks, data structures, dfs and similar, graphs, hashing, sortings, strings
Correct Solution:
```
from sys import stdin, gettrace
if gettrace():
def inputi():
return input()
else:
def input():
return next(stdin)[:-1]
def inputi():
return stdin.buffer.readline()
def patte... | output | 1 | 44,055 | 0 | 88,111 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by underscores). All patterns are pairwise distin... | instruction | 0 | 44,056 | 0 | 88,112 |
Tags: bitmasks, data structures, dfs and similar, graphs, hashing, sortings, strings
Correct Solution:
```
import sys
input = sys.stdin.readline
from collections import deque
n,m,k = map(int,input().split())
p = [input().rstrip() for i in range(n)]
idx = {s:i for i,s in enumerate(p)}
def match(s):
res = []
... | output | 1 | 44,056 | 0 | 88,113 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by underscores). All patterns are pairwise distin... | instruction | 0 | 44,057 | 0 | 88,114 |
Tags: bitmasks, data structures, dfs and similar, graphs, hashing, sortings, strings
Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().rstrip()
#CF-E-00
from collections import deque, defaultdict
def topological_sort(In, Out):
dq, L = deque(), []
for i, I in enumerate(In):
if not I:
... | output | 1 | 44,057 | 0 | 88,115 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by underscores). All patterns are pairwise distin... | instruction | 0 | 44,058 | 0 | 88,116 |
Tags: bitmasks, data structures, dfs and similar, graphs, hashing, sortings, strings
Correct Solution:
```
import math,sys,bisect,heapq,os
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
from functools import lru_cache
#sys.setrecursionlimit(200000000)
int1 = lambda x: int(x) ... | output | 1 | 44,058 | 0 | 88,117 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by... | instruction | 0 | 44,059 | 0 | 88,118 |
Yes | output | 1 | 44,059 | 0 | 88,119 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by... | instruction | 0 | 44,060 | 0 | 88,120 |
Yes | output | 1 | 44,060 | 0 | 88,121 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by... | instruction | 0 | 44,061 | 0 | 88,122 |
Yes | output | 1 | 44,061 | 0 | 88,123 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by... | instruction | 0 | 44,062 | 0 | 88,124 |
Yes | output | 1 | 44,062 | 0 | 88,125 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by... | instruction | 0 | 44,063 | 0 | 88,126 |
No | output | 1 | 44,063 | 0 | 88,127 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by... | instruction | 0 | 44,064 | 0 | 88,128 |
No | output | 1 | 44,064 | 0 | 88,129 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by... | instruction | 0 | 44,065 | 0 | 88,130 |
No | output | 1 | 44,065 | 0 | 88,131 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given n patterns p_1, p_2, ..., p_n and m strings s_1, s_2, ..., s_m. Each pattern p_i consists of k characters that are either lowercase Latin letters or wildcard characters (denoted by... | instruction | 0 | 44,066 | 0 | 88,132 |
No | output | 1 | 44,066 | 0 | 88,133 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hurricane came to Berland and to suburbs Stringsvill. You are going to it to check if it's all right with you favorite string. Hurrinace broke it a bit by reversing some of its non-intersecting ... | instruction | 0 | 44,381 | 0 | 88,762 |
No | output | 1 | 44,381 | 0 | 88,763 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hurricane came to Berland and to suburbs Stringsvill. You are going to it to check if it's all right with you favorite string. Hurrinace broke it a bit by reversing some of its non-intersecting ... | instruction | 0 | 44,382 | 0 | 88,764 |
No | output | 1 | 44,382 | 0 | 88,765 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hurricane came to Berland and to suburbs Stringsvill. You are going to it to check if it's all right with you favorite string. Hurrinace broke it a bit by reversing some of its non-intersecting ... | instruction | 0 | 44,383 | 0 | 88,766 |
No | output | 1 | 44,383 | 0 | 88,767 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Hurricane came to Berland and to suburbs Stringsvill. You are going to it to check if it's all right with you favorite string. Hurrinace broke it a bit by reversing some of its non-intersecting ... | instruction | 0 | 44,384 | 0 | 88,768 |
No | output | 1 | 44,384 | 0 | 88,769 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
*... | instruction | 0 | 44,469 | 0 | 88,938 |
"Correct Solution:
```
N = int(input())
MOD = 10 ** 9 + 7
memo = [{} for _ in range(N + 1)]
def ok(last4):
for i in range(4):
t = list(last4)
if i >= 1:
t[i - 1], t[i] = t[i], t[i - 1]
if "".join(t).count("AGC") > 0:
return False
return True
def dfs(cur, la... | output | 1 | 44,469 | 0 | 88,939 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
*... | instruction | 0 | 44,470 | 0 | 88,940 |
"Correct Solution:
```
n = int(input())
mod = 10**9+7
dp = [[0]*4 for i in range(n)]
for i in range(4):
dp[0][i] = 1
dp[1][i] = 4
dp[2][i] = 16
dp[2][1] -= 2
dp[2][2] -= 1
for i in range(3,n):
for j in range(4):
dp[i][j] = sum(dp[i-1])%mod
dp[i][1] -= dp[i-2][0] #AGC
dp[i][1] -= dp[i-2][2] #GAC... | output | 1 | 44,470 | 0 | 88,941 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
*... | instruction | 0 | 44,471 | 0 | 88,942 |
"Correct Solution:
```
N = int(input())
mod = 10 ** 9 + 7
memo = [{} for i in range(N+1)]
def ok(last4):
for i in range(4):
t = list(last4)
if i >= 1:
t[i-1], t[i] = t[i], t[i-1]
if ''.join(t).count('AGC') >= 1:
return False
return True
def dfs(cur, last3):
... | output | 1 | 44,471 | 0 | 88,943 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
*... | instruction | 0 | 44,472 | 0 | 88,944 |
"Correct Solution:
```
n=int(input())
M,R=10**9+7,range(4)
dp=[[[[0]*4for k in R]for j in R]for i in range(n+1)]
dp[0][3][3][3]=1
for i in range(1,n+1):
for j in R:
for k in R:
for l in R:
for m in R:
if(2,0,1)!=(k,l,m)!=(0,1,2)!=(k,l,m)!=(0,2,1)!=(j,l,m)!=(0,2,1)!=(j,k,m):dp[i][k][l][m]=(... | output | 1 | 44,472 | 0 | 88,945 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
*... | instruction | 0 | 44,473 | 0 | 88,946 |
"Correct Solution:
```
N , mod = int(input()) , 10**9+7
memo = [{} for i in range(N+1)]
def ok(last4):
for i in range(4):
t = list(last4)
if i >= 1:
t[i-1] ,t[i] = t[i],t[i-1]
if ''.join(t).count("AGC") >= 1:
return False
return True
def dfs(cur,last3)... | output | 1 | 44,473 | 0 | 88,947 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
*... | instruction | 0 | 44,474 | 0 | 88,948 |
"Correct Solution:
```
N = int(input())
mod = 10**9+7
def check(s):
for i in range(4):
l=list(s)
if i>0:
l[i-1],l[i]=l[i],l[i-1]
if "".join(l).count("AGC"):
return False
else:
return True
memo=[dict() for _ in range(N)]
def dfp(i,seq):
if i==N:
... | output | 1 | 44,474 | 0 | 88,949 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
*... | instruction | 0 | 44,475 | 0 | 88,950 |
"Correct Solution:
```
N = int(input())
mod = 10**9+7
dp = [[0]*4 for _ in range(N)]
dp[0] = [1,1,1,1]
dp[1] = [4,4,4,4]
#AGC, ACG, GAC, A?GC,AG?C -> AGGC, ATGC,AGTC
for i in range(2,N):
if i == 2:
dp[i][0] = dp[i-1][0]*4
dp[i][1] = dp[i-1][1]*4-2
dp[i][2] = dp[i-1][2]*4-1
dp[i][3] = dp[i-1][3]*4
... | output | 1 | 44,475 | 0 | 88,951 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
*... | instruction | 0 | 44,476 | 0 | 88,952 |
"Correct Solution:
```
N = int(input())
ng = ["agc", "aagc", "acgc", "aggc", "atgc", "agac", "agcc", "aggc", "agtc", "acg", "gac"]
x = {"a": 1, "g": 1, "c": 1, "t": 1}
for _ in range(1,N):
y = dict()
for let,num in x.items():
for a in ["a", "c", "g", "t"]:
if let[-3:] + a in ng or (let[-3:... | output | 1 | 44,476 | 0 | 88,953 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T... | instruction | 0 | 44,477 | 0 | 88,954 |
Yes | output | 1 | 44,477 | 0 | 88,955 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T... | instruction | 0 | 44,478 | 0 | 88,956 |
Yes | output | 1 | 44,478 | 0 | 88,957 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T... | instruction | 0 | 44,479 | 0 | 88,958 |
Yes | output | 1 | 44,479 | 0 | 88,959 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T... | instruction | 0 | 44,480 | 0 | 88,960 |
Yes | output | 1 | 44,480 | 0 | 88,961 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T... | instruction | 0 | 44,481 | 0 | 88,962 |
No | output | 1 | 44,481 | 0 | 88,963 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T... | instruction | 0 | 44,482 | 0 | 88,964 |
No | output | 1 | 44,482 | 0 | 88,965 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T... | instruction | 0 | 44,483 | 0 | 88,966 |
No | output | 1 | 44,483 | 0 | 88,967 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T... | instruction | 0 | 44,484 | 0 | 88,968 |
No | output | 1 | 44,484 | 0 | 88,969 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left a... | instruction | 0 | 44,540 | 0 | 89,080 |
"Correct Solution:
```
"""
Writer: SPD_9X2
https://atcoder.jp/contests/arc065/tasks/arc065_d
圧倒的dp感
lは非減少なので、 l[i-1] ~l[i] の間が確定する範囲
dp[i][今の区間に残っている1の数] = 並び替えの通り数 でやると
dp推移がO(N^2)になってしまう…
1の位置さえ決まればよい。
あらかじめ、それぞれの1に関して、移動しうる最小のindexと最大のindexを前計算
→どうやって?
→heapといもす法で、最小・最大値管理しつつ
あとはdp中に一点取得、区間加算がO(N)で出来れば、O(N**2)... | output | 1 | 44,540 | 0 | 89,081 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left a... | instruction | 0 | 44,541 | 0 | 89,082 |
"Correct Solution:
```
#!/usr/bin/env python3
M = 10 ** 9 + 7
def solve(n, m, s, lst):
cnt = [0] * n
t = 0
for i in range(n):
if s[i] == '1':
t += 1
cnt[i] = t
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1
r = 0
j = 0
for i in range(n):
... | output | 1 | 44,541 | 0 | 89,083 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left a... | instruction | 0 | 44,542 | 0 | 89,084 |
"Correct Solution:
```
mod=10**9+7
N,M=map(int,input().split())
L=-1;R=-1
S=input()
ope=[]
for i in range(M):
l,r=map(int,input().split())
l-=1;r-=1
if L<=l and r<=R:
continue
else:
L,R=l,r
ope.append((l,r))
M=len(ope)
data=[-1]*N
for i in range(M):
l,r=ope[i]
for j in ... | output | 1 | 44,542 | 0 | 89,085 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left a... | instruction | 0 | 44,543 | 0 | 89,086 |
"Correct Solution:
```
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline
n,m = map(int,readline().split())
s = input()
mp = map(int,read().split())
r = list(range(n))
for i,j in zip(mp,mp):
if r[i-1] < j-1:
r[i-1] = j-1
for i in range(1,n):
if r[i] < r[i... | output | 1 | 44,543 | 0 | 89,087 |
Provide a correct Python 3 solution for this coding contest problem.
There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left a... | instruction | 0 | 44,544 | 0 | 89,088 |
"Correct Solution:
```
import sys
readline = sys.stdin.readline
MOD = 10**9+7
N, M = map(int, readline().split())
S = list(map(int, readline().strip()))
Query = [tuple(map(lambda x: int(x) - 1, readline().split())) for _ in range(M)]
PP = S.count(1)
Li = [None]*PP
Ri = [None]*PP
T1 = S[:]
for l, r in Query:
cnt... | output | 1 | 44,544 | 0 | 89,089 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substri... | instruction | 0 | 44,545 | 0 | 89,090 |
No | output | 1 | 44,545 | 0 | 89,091 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substri... | instruction | 0 | 44,546 | 0 | 89,092 |
No | output | 1 | 44,546 | 0 | 89,093 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substri... | instruction | 0 | 44,547 | 0 | 89,094 |
No | output | 1 | 44,547 | 0 | 89,095 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substri... | instruction | 0 | 44,548 | 0 | 89,096 |
No | output | 1 | 44,548 | 0 | 89,097 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.
Kirk has a binary string s (a string which consists of zeroes and ones) of length n and he is asking ... | instruction | 0 | 44,677 | 0 | 89,354 |
Tags: brute force, greedy, strings
Correct Solution:
```
st = input().rstrip()
a = []
for item in st:
a.append(int(item))
a.reverse()
zero_count = 0
for i, item in enumerate(a):\
#huaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
#where all this peps got this kind of solutionnnnnnnnnn
#huaawdkaowkdoakw... | output | 1 | 44,677 | 0 | 89,355 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.
Kirk has a binary string s (a string which consists of zeroes and ones) of length n and he is asking ... | instruction | 0 | 44,678 | 0 | 89,356 |
Tags: brute force, greedy, strings
Correct Solution:
```
s = list(map(int, input()))
ps = [0]
for i in s:
if i == 0:
ps.append(ps[-1] + 1)
else:
ps.append(ps[-1] - 1)
b = 0
maba = 0
sufmax = [-10 ** 9]
for i in range(len(ps) - 1, 0, -1):
sufmax.append(max(sufmax[-1], ps[i]))
sufmax = sufmax[... | output | 1 | 44,678 | 0 | 89,357 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.
Kirk has a binary string s (a string which consists of zeroes and ones) of length n and he is asking ... | instruction | 0 | 44,679 | 0 | 89,358 |
Tags: brute force, greedy, strings
Correct Solution:
```
# -*- coding: utf-8 -*-
# @Date : 2019-08-21 13:24:15
# @Author : raj lath (oorja.halt@gmail.com)
# @Link : link
# @Version : 1.0.0
import sys
sys.setrecursionlimit(10**5+1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdi... | output | 1 | 44,679 | 0 | 89,359 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.
Kirk has a binary string s (a string which consists of zeroes and ones) of length n and he is asking ... | instruction | 0 | 44,680 | 0 | 89,360 |
Tags: brute force, greedy, strings
Correct Solution:
```
s = str(input().strip())
t = list(s[::-1])
cnt = 0
for i,v in enumerate(t):
if v == '0':
cnt += 1
else:
if cnt:
cnt -= 1
else:
t[i] = '0'
print("".join(t[::-1]))
``` | output | 1 | 44,680 | 0 | 89,361 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.
Kirk has a binary string s (a string which consists of zeroes and ones) of length n and he is asking ... | instruction | 0 | 44,681 | 0 | 89,362 |
Tags: brute force, greedy, strings
Correct Solution:
```
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
# from fractions import *
# from heapq import*
from bisect import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('... | output | 1 | 44,681 | 0 | 89,363 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.
Kirk has a binary string s (a string which consists of zeroes and ones) of length n and he is asking ... | instruction | 0 | 44,682 | 0 | 89,364 |
Tags: brute force, greedy, strings
Correct Solution:
```
a=input()
a=list(a)
l=[]
for i in range(0,len(a)):
l.append([a[i],i])
i=1
while(i<len(l)):
if l[i][0]=='0' and l[i-1][0]=='1':
l.pop(i)
l.pop(i-1)
i-=2
if i==-1:
i=0
i+=1
for i in range(0,len(l)):
a[l[i][1]]=0
p... | output | 1 | 44,682 | 0 | 89,365 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.
Kirk has a binary string s (a string which consists of zeroes and ones) of length n and he is asking ... | instruction | 0 | 44,683 | 0 | 89,366 |
Tags: brute force, greedy, strings
Correct Solution:
```
s = input()
res = ["0"]*len(s)
min_dif = 0
length = len(s)
for i in range(length):
if s[length-i-1] == "0":
min_dif = min([-1, min_dif-1])
else:
if min_dif < 0: res[length-i-1] = "1"
min_dif = min([1, min_dif+1])
print("".join(re... | output | 1 | 44,683 | 0 | 89,367 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the length of the string. You can hack this problem only if you solve both problems.
Kirk has a binary string s (a string which consists of zeroes and ones) of length n and he is asking ... | instruction | 0 | 44,684 | 0 | 89,368 |
Tags: brute force, greedy, strings
Correct Solution:
```
''' Hey stalker :) '''
INF = 10**10
def main():
print = out.append
''' Cook your dish here! '''
st = list(input())
stk = []
for index, i in enumerate(st):
if i=='0' and len(stk)>0 and stk[-1][0]=='1':
stk.pop()
else... | output | 1 | 44,684 | 0 | 89,369 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.