message stringlengths 2 28.7k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 21 109k | cluster float64 7 7 | __index_level_0__ int64 42 217k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bu... | instruction | 0 | 47,873 | 7 | 95,746 |
"Correct Solution:
```
# AOJ 0603 Illumination
# Python3 2018.7.2 bal4u
import sys
from sys import stdin
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
t, k = [], 0
for i in range(n):
if k > 0:
if a[i] == a[i-1]:
t.append(k)
k = 0
k += 1
if k > 0: t.append(k)
ans = k = 0
for i i... | output | 1 | 47,873 | 7 | 95,747 |
Provide a correct Python 3 solution for this coding contest problem.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bu... | instruction | 0 | 47,874 | 7 | 95,748 |
"Correct Solution:
```
#A
N = int(input())
S = list(map(int,input().split()))
R = []
now = 1
for i in range(N-1):
if S[i] != S[i+1]:
now+=1
else:
R.append(now)
now = 1
R.append(now)
#print(R)
RL = len(R)
ans = 0
for i in range(RL):
if i == 0:
if RL == 1:
... | output | 1 | 47,874 | 7 | 95,749 |
Provide a correct Python 3 solution for this coding contest problem.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bu... | instruction | 0 | 47,875 | 7 | 95,750 |
"Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
l_c=[0]
c=1
for i in range(1,n):
if l[i]==l[i-1]:
l_c.append(c)
c+=1
l_c.append(c)
if len(l_c)<5:
print(n)
else:
ans=-1
for i in range(len(l_c)-3):
ans=max(ans,l_c[i+3]-l_c[i])
print(ans)
``` | output | 1 | 47,875 | 7 | 95,751 |
Provide a correct Python 3 solution for this coding contest problem.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bu... | instruction | 0 | 47,876 | 7 | 95,752 |
"Correct Solution:
```
n=int(input())
a=input().split()
p=a.pop();c=1;d=[]
while a:
if a[-1]==p:d+=[c];c=1
else:c+=1
p=a.pop()
d+=[c]
if len(d)<=3:print(sum(d))
else:
print(max(sum(d[i:i+3]) for i in range(len(d)-2)))
``` | output | 1 | 47,876 | 7 | 95,753 |
Provide a correct Python 3 solution for this coding contest problem.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bu... | instruction | 0 | 47,877 | 7 | 95,754 |
"Correct Solution:
```
_ = input()
A = [0]
b = ''
for a in input().split():
if b == '' or b == a:
A.append(1)
else:
A[-1] += 1
b = a
ans = 0
if len(A) < 5:
ans = sum(A)
else:
for i in range(1, len(A)-2):
ans = max(ans, sum(A[i:i+3]))
print(ans)
``` | output | 1 | 47,877 | 7 | 95,755 |
Provide a correct Python 3 solution for this coding contest problem.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bu... | instruction | 0 | 47,878 | 7 | 95,756 |
"Correct Solution:
```
n = int(input())
a = list(map(int,input().split()))
d = []
l = 0
for i in range(n-1):
if a[i+1] == a[i]:
r = i+1
d.append(r-l)
l = r
d.append(n-l)
ans = 0
for i in range(len(d)-2):
ans = max(ans,d[i]+d[i+1]+d[i+2])
if len(d) == 2:
ans = max(d[0]+d[1],ans)
... | output | 1 | 47,878 | 7 | 95,757 |
Provide a correct Python 3 solution for this coding contest problem.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bu... | instruction | 0 | 47,879 | 7 | 95,758 |
"Correct Solution:
```
N = int(input())
a = list(map(int, input().split()))
dp = [[0]*3 for _ in [0]*N]
dp[0] = [1, 1, 1]
ans = 0
for i, (n1, n2) in enumerate(zip(a, a[1:]), start=1):
if n1 != n2:
for j in range(3):
dp[i][j] = dp[i-1][j]+1
else:
dp[i][0] = 1
if dp[i-1][2] > ... | output | 1 | 47,879 | 7 | 95,759 |
Provide a correct Python 3 solution for this coding contest problem.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bu... | instruction | 0 | 47,880 | 7 | 95,760 |
"Correct Solution:
```
n = int(input())
a = list(map(int,input().split()))
dp = [[1]*3 for i in range(n)]
ans = 1
for i in range(n-1):
for j in range(3):
if a[i] != a[i+1]:
if dp[i+1][j] < dp[i][j] + 1:
dp[i+1][j] = dp[i][j] + 1
if j<2 and a[i] == a[i+1]:
if ... | output | 1 | 47,880 | 7 | 95,761 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the w... | instruction | 0 | 47,881 | 7 | 95,762 |
Yes | output | 1 | 47,881 | 7 | 95,763 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the w... | instruction | 0 | 47,882 | 7 | 95,764 |
Yes | output | 1 | 47,882 | 7 | 95,765 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the w... | instruction | 0 | 47,883 | 7 | 95,766 |
Yes | output | 1 | 47,883 | 7 | 95,767 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the w... | instruction | 0 | 47,884 | 7 | 95,768 |
No | output | 1 | 47,884 | 7 | 95,769 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the w... | instruction | 0 | 47,885 | 7 | 95,770 |
No | output | 1 | 47,885 | 7 | 95,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Illumination
Illuminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the w... | instruction | 0 | 47,886 | 7 | 95,772 |
No | output | 1 | 47,886 | 7 | 95,773 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the colo... | instruction | 0 | 48,210 | 7 | 96,420 |
Tags: implementation
Correct Solution:
```
s = str(input())
t = str(input())
idx = 0
ans = s[idx]
for i in range(len(t)):
if (ans == t[i]):
idx += 1
ans = s[idx]
print(idx + 1)
``` | output | 1 | 48,210 | 7 | 96,421 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the colo... | instruction | 0 | 48,211 | 7 | 96,422 |
Tags: implementation
Correct Solution:
```
# A. Colorful Stones (Simplified Edition)
s = input()
t = input()
output = 1
i, j = (0,)*2
while i < len(s) and j < len(t):
if s[i] == t[j]:
i += 1
j += 1
output += 1
else:
j += 1
print(output)
``` | output | 1 | 48,211 | 7 | 96,423 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the colo... | instruction | 0 | 48,212 | 7 | 96,424 |
Tags: implementation
Correct Solution:
```
#code
a,b = input(),input()
j = 0
for i in range(len(b)):
if b[i] == a[j]:
j+=1
print(j+1)
``` | output | 1 | 48,212 | 7 | 96,425 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the colo... | instruction | 0 | 48,213 | 7 | 96,426 |
Tags: implementation
Correct Solution:
```
s=input()
t=input()
j=0
i=0
while j<len(t):
if(t[j]==s[i]):
i+=1
j+=1
print(i+1)
``` | output | 1 | 48,213 | 7 | 96,427 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the colo... | instruction | 0 | 48,214 | 7 | 96,428 |
Tags: implementation
Correct Solution:
```
s=input()
k=input()
c=1
i=0
t=1
while(t<=len(k)):
if k[i]==s[c-1]:
c=c+1
t=t+1
i+=1
print(c)
``` | output | 1 | 48,214 | 7 | 96,429 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the colo... | instruction | 0 | 48,215 | 7 | 96,430 |
Tags: implementation
Correct Solution:
```
s1 = input()
s2 = input()
i, j = 0, 0
while j < len(s2):
if s1[i] == s2[j]:
j += 1
i += 1
else:
j += 1
print(i+1)
``` | output | 1 | 48,215 | 7 | 96,431 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the colo... | instruction | 0 | 48,216 | 7 | 96,432 |
Tags: implementation
Correct Solution:
```
s = input()
t = input()
step = 0
for i in range(len(t)):
if s[step] == t[i]:
step += 1
print(step+1)
``` | output | 1 | 48,216 | 7 | 96,433 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone. If the character is "R", "G", or "B", the colo... | instruction | 0 | 48,217 | 7 | 96,434 |
Tags: implementation
Correct Solution:
```
import sys
from math import ceil,log
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): retu... | output | 1 | 48,217 | 7 | 96,435 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone.... | instruction | 0 | 48,218 | 7 | 96,436 |
Yes | output | 1 | 48,218 | 7 | 96,437 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone.... | instruction | 0 | 48,219 | 7 | 96,438 |
Yes | output | 1 | 48,219 | 7 | 96,439 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone.... | instruction | 0 | 48,220 | 7 | 96,440 |
Yes | output | 1 | 48,220 | 7 | 96,441 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone.... | instruction | 0 | 48,221 | 7 | 96,442 |
Yes | output | 1 | 48,221 | 7 | 96,443 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone.... | instruction | 0 | 48,222 | 7 | 96,444 |
No | output | 1 | 48,222 | 7 | 96,445 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone.... | instruction | 0 | 48,223 | 7 | 96,446 |
No | output | 1 | 48,223 | 7 | 96,447 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone.... | instruction | 0 | 48,224 | 7 | 96,448 |
No | output | 1 | 48,224 | 7 | 96,449 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a sequence of colorful stones. The color of each stone is one of red, green, or blue. You are given a string s. The i-th (1-based) character of s represents the color of the i-th stone.... | instruction | 0 | 48,225 | 7 | 96,450 |
No | output | 1 | 48,225 | 7 | 96,451 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this problem it is a square of size 1Γ1.
Also, the given image... | instruction | 0 | 48,671 | 7 | 97,342 |
"Correct Solution:
```
n,m = map(int,input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]
for i in range(n-m+1):
for p in range(n-m+1):
for c in range(m):
if B[c] != A[p+c][i:i+m]:
break
else:
print("Yes")
exit()
print("No")
``` | output | 1 | 48,671 | 7 | 97,343 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this problem it is a square of size 1Γ1.
Also, the given image... | instruction | 0 | 48,675 | 7 | 97,350 |
"Correct Solution:
```
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
ans = "Yes"
for i in range(n):
for j in range(m):
if b[j] not in a[i]:
ans = "No"
print(ans)
``` | output | 1 | 48,675 | 7 | 97,351 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this problem it is a square of size 1Γ1.
Also, the given image... | instruction | 0 | 48,676 | 7 | 97,352 |
"Correct Solution:
```
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
A.append(input())
for i in range(M):
B.append(input())
for h in range(N-M+1):
for w in range(N-M+1):
if list(map(lambda x:x[w:w+M], A[h:h+M])) == B:
print("Yes")
exit()
print("No")
``` | output | 1 | 48,676 | 7 | 97,353 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this p... | instruction | 0 | 48,678 | 7 | 97,356 |
Yes | output | 1 | 48,678 | 7 | 97,357 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this p... | instruction | 0 | 48,679 | 7 | 97,358 |
Yes | output | 1 | 48,679 | 7 | 97,359 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this p... | instruction | 0 | 48,680 | 7 | 97,360 |
Yes | output | 1 | 48,680 | 7 | 97,361 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this p... | instruction | 0 | 48,681 | 7 | 97,362 |
Yes | output | 1 | 48,681 | 7 | 97,363 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this p... | instruction | 0 | 48,682 | 7 | 97,364 |
No | output | 1 | 48,682 | 7 | 97,365 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this p... | instruction | 0 | 48,683 | 7 | 97,366 |
No | output | 1 | 48,683 | 7 | 97,367 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this p... | instruction | 0 | 48,684 | 7 | 97,368 |
No | output | 1 | 48,684 | 7 | 97,369 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels.
A pixel is the smallest element of an image, and in this p... | instruction | 0 | 48,685 | 7 | 97,370 |
No | output | 1 | 48,685 | 7 | 97,371 |
Provide tags and a correct Python 3 solution for this coding contest problem.
According to a new ISO standard, a flag of every country should have, strangely enough, a chequered field n Γ m, each square should be wholly painted one of 26 colours. The following restrictions are set:
* In each row at most two differ... | instruction | 0 | 49,122 | 7 | 98,244 |
Tags: dp
Correct Solution:
```
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n, m = map(int, input().split())
flag = [tuple(map(lambda c: ord(c) - 97, input().rstrip())) for _ in range(n)]
dp = [[[m] * 26 for _ in range(26)] for _ in range(n)]
... | output | 1 | 49,122 | 7 | 98,245 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
According to a new ISO standard, a flag of every country should have, strangely enough, a chequered field n Γ m, each square should be wholly painted one of 26 colours. The following restriction... | instruction | 0 | 49,123 | 7 | 98,246 |
No | output | 1 | 49,123 | 7 | 98,247 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
According to a new ISO standard, a flag of every country should have, strangely enough, a chequered field n Γ m, each square should be wholly painted one of 26 colours. The following restriction... | instruction | 0 | 49,124 | 7 | 98,248 |
No | output | 1 | 49,124 | 7 | 98,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initiall... | instruction | 0 | 49,302 | 7 | 98,604 |
Tags: dp
Correct Solution:
```
n, m, k = map(int, input().split())
colors = list(map(int, input().split()))
costs = [list(map(int, input().split())) for _ in range(n)]
dp = [[[float('inf') for _ in range(k+1)]
for _ in range(m+1)]
for _ in range(n+1)]
for i in range(m+1):
... | output | 1 | 49,302 | 7 | 98,605 |
Provide tags and a correct Python 3 solution for this coding contest problem.
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initiall... | instruction | 0 | 49,303 | 7 | 98,606 |
Tags: dp
Correct Solution:
```
# [https://codeforces.com/contest/711/submission/20819531]
(n, m, k) = map(int, input().split())
cc = list(map(int, input().split()))
c = cc[0]
cc = cc[1:]
ppp = [list(map(float, input().split())) for _ in range(n)]
pp = ppp[0]
ppp = ppp[1:]
inf = 2.0 ** 47
nxt = [[0.0 if i == c - 1 else... | output | 1 | 49,303 | 7 | 98,607 |
Provide tags and a correct Python 3 solution for this coding contest problem.
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initiall... | instruction | 0 | 49,304 | 7 | 98,608 |
Tags: dp
Correct Solution:
```
n,m,k=map(int,input().split())
col=list(map(int,input().split()))
p=[]
for i in range(n):p.append(list(map(int,input().split())))
dp=[[[float('inf')]*m for i in range(k+1)] for i in range(n)]
if col[0]==0:
for i in range(m):
dp[0][1][i]=p[0][i]
else:
dp[0][1][col[0]-1]=0
for i in rang... | output | 1 | 49,304 | 7 | 98,609 |
Provide tags and a correct Python 3 solution for this coding contest problem.
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initiall... | instruction | 0 | 49,305 | 7 | 98,610 |
Tags: dp
Correct Solution:
```
def main():
n, m, k = map(int, input().split())
c, *cc = (map(int, input().split()))
pp, *ppp = (list(map(float, input().split())) for _ in range(n))
inf = 2. ** 47
nxt = [[0. if i == c - 1 else inf for i in range(m)] if c else pp]
for c, pp in zip(cc, ppp):
... | output | 1 | 49,305 | 7 | 98,611 |
Provide tags and a correct Python 3 solution for this coding contest problem.
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initiall... | instruction | 0 | 49,306 | 7 | 98,612 |
Tags: dp
Correct Solution:
```
n, m, k = map(int, input().split())
arr = list(map(int, input().split()))
paint = [list(map(int, input().split())) for i in range(n)]
if ((0 not in arr) and (len(set(arr)) > k)) or (len(set(arr)) - 1 > k):
print(-1)
exit()
#DP(index, color of index, current beauty)
dp = [0 for n_idx i... | output | 1 | 49,306 | 7 | 98,613 |
Provide tags and a correct Python 3 solution for this coding contest problem.
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initiall... | instruction | 0 | 49,307 | 7 | 98,614 |
Tags: dp
Correct Solution:
```
import math
dp=[[[math.inf for i in range(105)] for i in range(105)] for i in range(105)]
#dp[x][y][z] denote index x , beauty y , using paint z
#dp[x][y][z] denotes cost of it
n,m,k=map(int,input().split())
k+=1
z=list(map(int,input().split()))
matrix=[]
for i in range(n):
ans=lis... | output | 1 | 49,307 | 7 | 98,615 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.