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 |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".
Maxim was very boring to... | instruction | 0 | 48,897 | 0 | 97,794 |
Yes | output | 1 | 48,897 | 0 | 97,795 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".
Maxim was very boring to... | instruction | 0 | 48,898 | 0 | 97,796 |
Yes | output | 1 | 48,898 | 0 | 97,797 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".
Maxim was very boring to... | instruction | 0 | 48,899 | 0 | 97,798 |
Yes | output | 1 | 48,899 | 0 | 97,799 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".
Maxim was very boring to... | instruction | 0 | 48,900 | 0 | 97,800 |
Yes | output | 1 | 48,900 | 0 | 97,801 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".
Maxim was very boring to... | instruction | 0 | 48,901 | 0 | 97,802 |
No | output | 1 | 48,901 | 0 | 97,803 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".
Maxim was very boring to... | instruction | 0 | 48,902 | 0 | 97,804 |
No | output | 1 | 48,902 | 0 | 97,805 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".
Maxim was very boring to... | instruction | 0 | 48,903 | 0 | 97,806 |
No | output | 1 | 48,903 | 0 | 97,807 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Today in the scientific lyceum of the Kingdom of Kremland, there was a biology lesson. The topic of the lesson was the genomes. Let's call the genome the string "ACTG".
Maxim was very boring to... | instruction | 0 | 48,904 | 0 | 97,808 |
No | output | 1 | 48,904 | 0 | 97,809 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a binary string s awesome, if it has at least 1 symbol 1 and length of the string is divisible by the number of 1 in it. In particular, 1, 1010, 111 are awesome, but 0, 110, 01010 are... | instruction | 0 | 48,933 | 0 | 97,866 |
No | output | 1 | 48,933 | 0 | 97,867 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a binary string s awesome, if it has at least 1 symbol 1 and length of the string is divisible by the number of 1 in it. In particular, 1, 1010, 111 are awesome, but 0, 110, 01010 are... | instruction | 0 | 48,934 | 0 | 97,868 |
No | output | 1 | 48,934 | 0 | 97,869 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a binary string s awesome, if it has at least 1 symbol 1 and length of the string is divisible by the number of 1 in it. In particular, 1, 1010, 111 are awesome, but 0, 110, 01010 are... | instruction | 0 | 48,935 | 0 | 97,870 |
No | output | 1 | 48,935 | 0 | 97,871 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Let's call a binary string s awesome, if it has at least 1 symbol 1 and length of the string is divisible by the number of 1 in it. In particular, 1, 1010, 111 are awesome, but 0, 110, 01010 are... | instruction | 0 | 48,936 | 0 | 97,872 |
No | output | 1 | 48,936 | 0 | 97,873 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You desperately need to build some string t. For that you've got n more strings s1, s2, ..., sn. To build string t, you are allowed to perform exactly |t| (|t| is the length of string t) operations on these strings. Each operation looks like... | instruction | 0 | 49,125 | 0 | 98,250 |
Tags: flows, graphs
Correct Solution:
```
class Edge:
def __init__(self, to, cost, capacity, next_edge):
self.to = to
self.cost = cost
self.origin_cost = cost
self.capacity = capacity
self.next_edge = next_edge
self.pair = None
class MinCostMaxFlow:
def __init__... | output | 1 | 49,125 | 0 | 98,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You desperately need to build some string t. For that you've got n more strings s1, s2, ..., sn. To build string t, you are allowed to perform exactly |t| (|t| is the length of string t) operations on these strings. Each operation looks like... | instruction | 0 | 49,126 | 0 | 98,252 |
Tags: flows, graphs
Correct Solution:
```
from heapq import heappush, heappop
class MinCostFlow:
INF = 10**18
def __init__(self, N):
self.N = N
self.G = [[] for i in range(N)]
def add_edge(self, fr, to, cap, cost):
G = self.G
G[fr].append([to, cap, cost, len(G[to])])
... | output | 1 | 49,126 | 0 | 98,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You desperately need to build some string t. For that you've got n more strings s1, s2, ..., sn. To build string t, you are allowed to perform exactly |t| (|t| is the length of string t) operati... | instruction | 0 | 49,127 | 0 | 98,254 |
No | output | 1 | 49,127 | 0 | 98,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The first semester ended. You know, after the end of the first semester the holidays begin. On holidays Noora decided to return to ViΔkopolis. As a modest souvenir for Leha, she brought a sausag... | instruction | 0 | 49,352 | 0 | 98,704 |
No | output | 1 | 49,352 | 0 | 98,705 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
At the Byteland State University marks are strings of the same length. Mark x is considered better than y if string y is lexicographically smaller than x.
Recently at the BSU was an important t... | instruction | 0 | 49,357 | 0 | 98,714 |
No | output | 1 | 49,357 | 0 | 98,715 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
At the Byteland State University marks are strings of the same length. Mark x is considered better than y if string y is lexicographically smaller than x.
Recently at the BSU was an important t... | instruction | 0 | 49,358 | 0 | 98,716 |
No | output | 1 | 49,358 | 0 | 98,717 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
At the Byteland State University marks are strings of the same length. Mark x is considered better than y if string y is lexicographically smaller than x.
Recently at the BSU was an important t... | instruction | 0 | 49,359 | 0 | 98,718 |
No | output | 1 | 49,359 | 0 | 98,719 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
At the Byteland State University marks are strings of the same length. Mark x is considered better than y if string y is lexicographically smaller than x.
Recently at the BSU was an important t... | instruction | 0 | 49,360 | 0 | 98,720 |
No | output | 1 | 49,360 | 0 | 98,721 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. The string s consists of lowercase Latin letters and at most one wildcard character '*', the string t consists only of lowercase Latin letters. The length of the string s equals n, the length of the string ... | instruction | 0 | 49,619 | 0 | 99,238 |
Tags: brute force, implementation, strings
Correct Solution:
```
from string import printable
#print(printable[10:36])
n,m = (input().split(" "))
#n=int(input())
#m=int(input())
#s,t = (input().split(" "))
s=(input())
t=(input())
if int(n)>int(int(m)+1):
print("NO")
exit(0)
if int(n)<=int(int(m)+1):
if '*' ... | output | 1 | 49,619 | 0 | 99,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. The string s consists of lowercase Latin letters and at most one wildcard character '*', the string t consists only of lowercase Latin letters. The length of the string s equals n, the length of the string ... | instruction | 0 | 49,620 | 0 | 99,240 |
Tags: brute force, implementation, strings
Correct Solution:
```
n, m = [int(x) for x in str(input()).split(' ', 1)]
s = str(input().strip())
t = str(input().strip())
s = s.split('*', 1)
# print(s, len(s))
if len(s) == 1:
if s[0] == t:
print('YES')
else:
print('NO')
elif s == ['', '']:
print... | output | 1 | 49,620 | 0 | 99,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. The string s consists of lowercase Latin letters and at most one wildcard character '*', the string t consists only of lowercase Latin letters. The length of the string s equals n, the length of the string ... | instruction | 0 | 49,621 | 0 | 99,242 |
Tags: brute force, implementation, strings
Correct Solution:
```
n, m = map(int,input().split())
s = input()
t = input()
ans = ''
if n - 1 > m:
ans = 'NO'
else:
if '*' not in s:
if s == t:
ans = 'YES'
else:
ans = 'NO'
else:
if s[:s.index('*')] == t[:s.index('*... | output | 1 | 49,621 | 0 | 99,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. The string s consists of lowercase Latin letters and at most one wildcard character '*', the string t consists only of lowercase Latin letters. The length of the string s equals n, the length of the string ... | instruction | 0 | 49,622 | 0 | 99,244 |
Tags: brute force, implementation, strings
Correct Solution:
```
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def solve():
n, m = map(int, input().split())
s, t = input().strip(), input().strip()
if s.find("*") >= 0:
ai = s.find("*")
if t.find(s[:ai]) != 0:
print("NO")
... | output | 1 | 49,622 | 0 | 99,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. The string s consists of lowercase Latin letters and at most one wildcard character '*', the string t consists only of lowercase Latin letters. The length of the string s equals n, the length of the string ... | instruction | 0 | 49,623 | 0 | 99,246 |
Tags: brute force, implementation, strings
Correct Solution:
```
n,m=map(int,input().split())
s,t=input(),input()
if s.count("*")==0 :
if s==t :
exit( print("YES"))
else :
exit(print("NO"))
a,b=s.split("*")
l1=len(a)
l2=len(b)
#print(a)
#print(t[:l1])
if a==t[:l1] :
if (m+1 )>=n :
# ... | output | 1 | 49,623 | 0 | 99,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. The string s consists of lowercase Latin letters and at most one wildcard character '*', the string t consists only of lowercase Latin letters. The length of the string s equals n, the length of the string ... | instruction | 0 | 49,624 | 0 | 99,248 |
Tags: brute force, implementation, strings
Correct Solution:
```
n,m=map(int,input().split())
s1=list(input())
s2=input()
i=0
seen=0
j=0
if '*' not in s1:
if ''.join(s1)!=s2:
print('NO')
exit()
while i<n and j<m:
if s1[i]=='*':
seen=1
break
i+=1
if not seen:
... | output | 1 | 49,624 | 0 | 99,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. The string s consists of lowercase Latin letters and at most one wildcard character '*', the string t consists only of lowercase Latin letters. The length of the string s equals n, the length of the string ... | instruction | 0 | 49,625 | 0 | 99,250 |
Tags: brute force, implementation, strings
Correct Solution:
```
n, m = [int(j) for j in input().split()]
s = input()
t = input()
if s == '*':
print('YES')
exit(0)
if len(s) - 1 > len(t):
print('NO')
exit(0)
a = s.split('*')
# print(len(a))
if len(a) == 1 and s != t:
print('NO')
exit(0)
elif len... | output | 1 | 49,625 | 0 | 99,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given two strings s and t. The string s consists of lowercase Latin letters and at most one wildcard character '*', the string t consists only of lowercase Latin letters. The length of the string s equals n, the length of the string ... | instruction | 0 | 49,626 | 0 | 99,252 |
Tags: brute force, implementation, strings
Correct Solution:
```
input()
a = input()
b = input()
a = a.split('*')
# print(a)
# print([b[:len(a[0])], b[-len(a[1]):]])
if len(a) == 1:
if a[0] == b:
print('YES')
else:
print('NO')
else:
if len(b) < len(a[0]) + len(a[1]) \
or (a[0... | output | 1 | 49,626 | 0 | 99,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing ... | instruction | 0 | 50,026 | 0 | 100,052 |
Tags: greedy
Correct Solution:
```
#compute hamming distance
# mark indexes that differ
#m_benefit=0,s_i,s_j
#for each i in index
# for each j in i+1
# swap i & j and see what is the benefit
# if benefit > m_benefit:
# m_ben=ben
# record m_i and m_j
#if m_ben = 0 then -1 -1
#else dist... | output | 1 | 50,026 | 0 | 100,053 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing ... | instruction | 0 | 50,027 | 0 | 100,054 |
Tags: greedy
Correct Solution:
```
import string
n, s, t = int(input()), input(), input()
x, i, j = 0, -1, -1
sc_dict = {c: set() for c in string.ascii_lowercase}
tc_dict = {c: set() for c in string.ascii_lowercase}
sti_dict, tsi_dict = dict(), dict()
for ci, sc, tc in zip(range(n), s, t):
if sc == tc:
c... | output | 1 | 50,027 | 0 | 100,055 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing ... | instruction | 0 | 50,028 | 0 | 100,056 |
Tags: greedy
Correct Solution:
```
n, s, t = int(input()), input(), input()
t_dict = dict()
diffs = list()
res_i, res_j = -1, -1
res_d = 0
for i in range(n):
if s[i] == t[i]:
continue
res_d += 1
diffs.append(i)
t_dict[t[i]] = i
perfect_swapped = False
swapped = False
for i in diffs:
if s[... | output | 1 | 50,028 | 0 | 100,057 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing ... | instruction | 0 | 50,029 | 0 | 100,058 |
Tags: greedy
Correct Solution:
```
_,s,t=input(),input(),input()
d=0
p=[[-1 for _ in range(26)] for _ in range(26)]
a,b=[-1 for _ in range(26)],[-1 for _ in range(26)]
for i in range(len(s)):
if s[i]!=t[i]:
cs=ord(s[i])-97
ct=ord(t[i])-97
d+=1
p[cs][ct]=i+1
a[cs]=i+1
... | output | 1 | 50,029 | 0 | 100,059 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing ... | instruction | 0 | 50,030 | 0 | 100,060 |
Tags: greedy
Correct Solution:
```
n=int(input())
s=input()
t=input()
dis=0
d=[[False for i in range(30)] for i in range(30)]
x=[[0 for i in range(30)] for i in range(30)]
for i in range(n):
if s[i]!=t[i]:
dis+=1
d[ord(s[i])-ord('a')][ord(t[i])-ord('a')]=True
x[ord(s[i])-ord('a')][ord(t[i])-ord('a')]=i+1
def pro... | output | 1 | 50,030 | 0 | 100,061 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing ... | instruction | 0 | 50,031 | 0 | 100,062 |
Tags: greedy
Correct Solution:
```
def solve():
r = 0
d = {}
for i in range(n):
if a[i] != b[i]:
r += 1
d[(a[i], b[i])] = i+1
symbols = [chr(ord('a') + i) for i in range(26)]
for i in symbols:
for j in symbols:
if (i, j) in d and (j, i) in d:
... | output | 1 | 50,031 | 0 | 100,063 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing ... | instruction | 0 | 50,032 | 0 | 100,064 |
Tags: greedy
Correct Solution:
```
xxx = 0
a1=[]
a2=[]
a = int(input())
x = input()
y = input()
of1=[]
of2=[]
a1 = {}
a2 = {}
for i in 'abcdefghijklmnopqrstuvwxyz':
a1[i] = []
a2[i] = []
for i in range(a):
if x[i]!=y[i]:
a1[x[i]].append(i+1)
a2[y[i]].append(i+1)
else:
x... | output | 1 | 50,032 | 0 | 100,065 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing ... | instruction | 0 | 50,033 | 0 | 100,066 |
Tags: greedy
Correct Solution:
```
n = int(input())
s = input()
t = input()
pair2ind = {}
letters_s = [0] * 26
letters_t = [0] * 26
non_common = set()
cnt = 0
for i in range(n):
if s[i] != t[i]:
pair2ind[(s[i], t[i])] = i + 1
letters_s[ord(s[i]) - ord('a')] = i + 1
letters_t[ord(t[i]) - ord(... | output | 1 | 50,033 | 0 | 100,067 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process... | instruction | 0 | 50,034 | 0 | 100,068 |
Yes | output | 1 | 50,034 | 0 | 100,069 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process... | instruction | 0 | 50,035 | 0 | 100,070 |
Yes | output | 1 | 50,035 | 0 | 100,071 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process... | instruction | 0 | 50,036 | 0 | 100,072 |
Yes | output | 1 | 50,036 | 0 | 100,073 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process... | instruction | 0 | 50,037 | 0 | 100,074 |
Yes | output | 1 | 50,037 | 0 | 100,075 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process... | instruction | 0 | 50,038 | 0 | 100,076 |
No | output | 1 | 50,038 | 0 | 100,077 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process... | instruction | 0 | 50,039 | 0 | 100,078 |
No | output | 1 | 50,039 | 0 | 100,079 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process... | instruction | 0 | 50,040 | 0 | 100,080 |
No | output | 1 | 50,040 | 0 | 100,081 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process... | instruction | 0 | 50,041 | 0 | 100,082 |
No | output | 1 | 50,041 | 0 | 100,083 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, β¦, a_j (1β€ iβ€ jβ€ n) a substring of string a.
You can apply the following operations any number of times:
... | instruction | 0 | 50,249 | 0 | 100,498 |
Tags: brute force, greedy, implementation, math
Correct Solution:
```
import sys
bla, wort, *_ = sys.stdin.read().split('\n')
n, x, y = [int(z) for z in bla.split(' ')]
anz = wort[0] == '0'
for a, b in zip(wort[:-1], wort[1:]):
if b=='0' and a!='0':
anz += 1
if anz==0:
print(0)
else:
print(y + min(x... | output | 1 | 50,249 | 0 | 100,499 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, β¦, a_j (1β€ iβ€ jβ€ n) a substring of string a.
You can apply the following operations any number of times:
... | instruction | 0 | 50,250 | 0 | 100,500 |
Tags: brute force, greedy, implementation, math
Correct Solution:
```
n, x, y = map(int, input().split())
s = input()
lst = -1
cnt = 0
for i in s:
if i == '1':
if lst == 0:
cnt += 1
lst = -1
else:
lst = 0
if s[n - 1] == '0':
cnt += 1
if cnt == 0:
exit(print(0)... | output | 1 | 50,250 | 0 | 100,501 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, β¦, a_j (1β€ iβ€ jβ€ n) a substring of string a.
You can apply the following operations any number of times:
... | instruction | 0 | 50,251 | 0 | 100,502 |
Tags: brute force, greedy, implementation, math
Correct Solution:
```
n, x, y = map(int, input().split())
s = input()
if '0' not in s:
print(0)
elif '1' not in s:
print(y)
else:
zero_start = s[0] == '0'
zero_end = s[-1] == '0'
ones_groups = 0
i = 0
while i < n:
found = False
while i < n and s[i] =... | output | 1 | 50,251 | 0 | 100,503 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, β¦, a_j (1β€ iβ€ jβ€ n) a substring of string a.
You can apply the following operations any number of times:
... | instruction | 0 | 50,252 | 0 | 100,504 |
Tags: brute force, greedy, implementation, math
Correct Solution:
```
n,x,y=map(int, input().split())
a=input()
k=0
i=0
if a[i]=='0':
k+=1
while i<n and a[i]=='0':
i+=1
for j in range(i,n-1):
if a[j]=='1' and a[j+1]=='0':
k+=1
if k==0:
print(0)
elif x<y:
print((k-1)*x+y)
else:
pr... | output | 1 | 50,252 | 0 | 100,505 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, β¦, a_j (1β€ iβ€ jβ€ n) a substring of string a.
You can apply the following operations any number of times:
... | instruction | 0 | 50,253 | 0 | 100,506 |
Tags: brute force, greedy, implementation, math
Correct Solution:
```
n, x, y = input().split()
n = int(n)
x = int(x)
y = int(y)
s = input()
count = 0
is_zero = (s[0] == '0')
if is_zero:
count += 1
for i in range(1, n):
if s[i] == '0' and not is_zero:
is_zero = True
count += 1
elif s[i] == '... | output | 1 | 50,253 | 0 | 100,507 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.
Let's call a sequence of consecutive elements a_i, a_{i + 1}, β¦, a_j (1β€ iβ€ jβ€ n) a substring of string a.
You can apply the following operations any number of times:
... | instruction | 0 | 50,254 | 0 | 100,508 |
Tags: brute force, greedy, implementation, math
Correct Solution:
```
n, x, y = map(int, input().split())
u = list(map(int, input()))
d0 = 0
k0 = 0
for i in range(n):
if k0 == 1 and u[i] == 1:
d0 += 1
k0 = 0
elif u[i] == 0:
k0 = 1
if k0 == 1:
d0 += 1
if d0 == 0:
p = 0
else:
p... | output | 1 | 50,254 | 0 | 100,509 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.