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. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the H_i bottommost squares and will not paint the other squ...
instruction
0
63,772
7
127,544
"Correct Solution: ``` import sys input = sys.stdin.readline N, K = map(int, input().split()) a = [0] + list(map(int, input().split())) inf = 10 ** 12 dp = [[[inf] * (N + 1) for _ in range(K + 1)] for _ in range(N + 1)] dp[0][0][0] = 0 for i in range(N): for j in range(K + 1): for k in range(N + 1): if dp[i...
output
1
63,772
7
127,545
Provide a correct Python 3 solution for this coding contest problem. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the H_i bottommost squares and will not paint the other squ...
instruction
0
63,773
7
127,546
"Correct Solution: ``` N,K = map(int, input().split()) H = [int(h) for h in input().split()] dp = [[10**13]*N for _ in range(N)] dp[0][0] = H[0] for i in range(1, N): for j in range(i+1): if j == 0: dp[i][j] = H[i] continue for k in range(i): dp[i][j] = min(...
output
1
63,773
7
127,547
Provide a correct Python 3 solution for this coding contest problem. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the H_i bottommost squares and will not paint the other squ...
instruction
0
63,774
7
127,548
"Correct Solution: ``` N, K = map(int, input().split()) H = list(map(int, input().split())) N += 1 H = [0] + H DP = [[float('inf')] * N for _ in range(N)] DP[0][0] = 0 for i in range(1, N): DP[i][1] = H[i] for j in range(2, i + 1): for k in range(1, i): DP[i][j] = min(DP[i][j], DP[k][j - 1] + max(0, H[...
output
1
63,774
7
127,549
Provide a correct Python 3 solution for this coding contest problem. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the H_i bottommost squares and will not paint the other squ...
instruction
0
63,775
7
127,550
"Correct Solution: ``` # -*- coding: utf-8 -*- N,K=map(int, input().split()) H=list(map(int, input().split())) G=[0] G.extend(H[:]) dp=[[0]*(N+1) for i in range(N-K+1)] tempa=0 if K<N-1: for jtemp in range(N): j=jtemp+1 dp[1][j]=G[j]#min(dp[1][j-1],G[j]) for itemp in range(N-K-1): i...
output
1
63,775
7
127,551
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the...
instruction
0
63,776
7
127,552
Yes
output
1
63,776
7
127,553
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the...
instruction
0
63,777
7
127,554
Yes
output
1
63,777
7
127,555
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the...
instruction
0
63,778
7
127,556
Yes
output
1
63,778
7
127,557
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the...
instruction
0
63,779
7
127,558
Yes
output
1
63,779
7
127,559
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the...
instruction
0
63,780
7
127,560
No
output
1
63,780
7
127,561
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the...
instruction
0
63,781
7
127,562
No
output
1
63,781
7
127,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the...
instruction
0
63,782
7
127,564
No
output
1
63,782
7
127,565
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. We will create an artwork by painting black some squares in a white square grid with 10^9 rows and N columns. The current plan is as follows: for the i-th column from the left, we will paint the...
instruction
0
63,783
7
127,566
No
output
1
63,783
7
127,567
Provide tags and a correct Python 3 solution for this coding contest problem. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painte...
instruction
0
64,288
7
128,576
Tags: brute force, implementation Correct Solution: ``` # IQ Test from collections import Counter def calculate(lines): """ """ row = 0 col = 0 row_char = 0 col_char = 0 black = "#" whitee = "." while(row <= 2 and col <= 2 and row_char <= 2 and col_char <= 2): c1 = lines[row...
output
1
64,288
7
128,577
Provide tags and a correct Python 3 solution for this coding contest problem. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painte...
instruction
0
64,289
7
128,578
Tags: brute force, implementation Correct Solution: ``` __copyright__ = '' __author__ = 'Son-Huy TRAN' __email__ = "sonhuytran@gmail.com" __doc__ = '' __version__ = '1.0' def can_paint(wall: list) -> bool: for i in range(3): for j in range(3): temp = wall[i][j] + wall[i + 1][j] + wall[i][j + 1...
output
1
64,289
7
128,579
Provide tags and a correct Python 3 solution for this coding contest problem. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painte...
instruction
0
64,290
7
128,580
Tags: brute force, implementation Correct Solution: ``` values = [] yes = False for i in range(4): line = list(input()) seg1 = line[:2] seg2 = line[1:3] seg3 = line[2:4] arr = [0, 0, 0] if seg1.count("#") == 1: arr[0] = 1 elif seg1.count("#") == 2: arr[0] = 2 if seg2...
output
1
64,290
7
128,581
Provide tags and a correct Python 3 solution for this coding contest problem. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painte...
instruction
0
64,291
7
128,582
Tags: brute force, implementation Correct Solution: ``` a = [] for i in range(4): a.append(input()) for i in range(3): for j in range(3): k = 0 if a[i][j] == '#': k += 1 if a[i][j+1] == '#': k += 1 if a[i+1][j] == '#': k += 1 if a[i+1...
output
1
64,291
7
128,583
Provide tags and a correct Python 3 solution for this coding contest problem. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painte...
instruction
0
64,292
7
128,584
Tags: brute force, implementation Correct Solution: ``` a = [input() for _ in range(4)] flag=0 for i in range(0,3): for j in range(0,3): s=a[i][j]+a[i][j+1]+a[i+1][j]+a[i+1][j+1] if s.count('#')==0 or s.count('#')==1 or s.count('#')==3 or s.count('#')==4: print("YES") flag=1 ...
output
1
64,292
7
128,585
Provide tags and a correct Python 3 solution for this coding contest problem. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painte...
instruction
0
64,293
7
128,586
Tags: brute force, implementation Correct Solution: ``` square = [] for i in range(4): square.append(list(input())) testPassed = False for i in range(3): for j in range(3): if testPassed: break smallSquare = square[i][j] + square[i+1][j] + square[i][j+1] + square[i+1][j+1] whiteCount = smallSquare.cou...
output
1
64,293
7
128,587
Provide tags and a correct Python 3 solution for this coding contest problem. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painte...
instruction
0
64,294
7
128,588
Tags: brute force, implementation Correct Solution: ``` matriz = [list(map(str, input())) for i in range(4)] flag = False for i in range(4): for j in range(4): try: m = matriz sqr = [m[i][j], m[i][j+1], m[i+1][j], m[i+1][j+1]] if sqr.count('#') >= 3 or sqr.count('.') >= 3: flag = True except: cont...
output
1
64,294
7
128,589
Provide tags and a correct Python 3 solution for this coding contest problem. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painte...
instruction
0
64,295
7
128,590
Tags: brute force, implementation Correct Solution: ``` matrix =[] for i in range(4): matrix.append([]) a =input() for char in a: matrix[i].append(char) def a(): e =0 g =0 if (matrix[0][0] == '.' and matrix[0][1] == '.' and matrix[1][0] == '.' and matrix[1][1] == '.'): e =1 #print ('11') elif (matrix[0][2...
output
1
64,295
7
128,591
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square'...
instruction
0
64,296
7
128,592
Yes
output
1
64,296
7
128,593
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square'...
instruction
0
64,297
7
128,594
Yes
output
1
64,297
7
128,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square'...
instruction
0
64,298
7
128,596
Yes
output
1
64,298
7
128,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square'...
instruction
0
64,299
7
128,598
Yes
output
1
64,299
7
128,599
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square'...
instruction
0
64,300
7
128,600
No
output
1
64,300
7
128,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square'...
instruction
0
64,301
7
128,602
No
output
1
64,301
7
128,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square'...
instruction
0
64,302
7
128,604
No
output
1
64,302
7
128,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square'...
instruction
0
64,303
7
128,606
No
output
1
64,303
7
128,607
Provide a correct Python 3 solution for this coding contest problem. Problem There is a grid of $ N \ times N $ cells. Initially all cells are white. Follow the steps below to increase the number of black squares. Select one white cell from the cells that are even-numbered from the top and even-numbered from the lef...
instruction
0
66,423
7
132,846
"Correct Solution: ``` from collections import deque n = int(input()) A = [input() for i in range(n)] cnt = 0 dd = [[-1, 0], [0, -1], [1, 0], [0, 1]] used = {} for i in range(n): for j in range(n): if A[i][j] == 'x' or (i, j) in used: continue deq = deque([(j, i)]) used[i, j] = ...
output
1
66,423
7
132,847
Provide a correct Python 3 solution for this coding contest problem. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red. Chai...
instruction
0
67,166
7
134,332
"Correct Solution: ``` h,w=[int(s)for s in input().split(" ")] flag=[input()for i in range(h)] mincnt=1145141919810 for i in range(1,h-1): for j in range(1,h-i): cnt=0 wr=flag[:i] br=flag[i:i+j] rr=flag[i+j:] for l in wr: for c in l: if c!='W':cnt+...
output
1
67,166
7
134,333
Provide a correct Python 3 solution for this coding contest problem. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red. Chai...
instruction
0
67,167
7
134,334
"Correct Solution: ``` inf = 10**20 n,m = map(int, input().split()) flist = [] wbrnum = {} for i in range(n): a = list(str(input())) flist.append(a) b = [] b.append(a.count('W')) b.append(a.count('B')) b.append(a.count('R')) wbrnum[i] = b cnt = inf for i in range(n-2): cnti = 0 for l...
output
1
67,167
7
134,335
Provide a correct Python 3 solution for this coding contest problem. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red. Chai...
instruction
0
67,168
7
134,336
"Correct Solution: ``` h, w = map(int, input().split()) f = [0 for _ in range(h)] for i in range(h): f[i] = input() cw = [f[i].count("W") for i in range(h)] cb = [f[i].count("B") for i in range(h)] cr = [f[i].count("R") for i in range(h)] count = h * w for i in range(1, h - 1): for j in range(i, h): cou...
output
1
67,168
7
134,337
Provide a correct Python 3 solution for this coding contest problem. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red. Chai...
instruction
0
67,169
7
134,338
"Correct Solution: ``` # coding: utf-8 N, M = list(map(int, input().split(' '))) colors = [] for i in range(N): row = list(input()) row_color = [0, 0, 0] for c in row: if c == 'W': row_color[0] += 1 elif c == 'B': row_color[1] += 1 elif c == 'R': row_color[2] += 1 colors.append(...
output
1
67,169
7
134,339
Provide a correct Python 3 solution for this coding contest problem. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red. Chai...
instruction
0
67,170
7
134,340
"Correct Solution: ``` n,m=map(int,input().split()) flag=[list(input()) for _ in range(n)] w=[] b=[] r=[] for i in flag: w.append(i.count('W')) b.append(i.count('B')) r.append(i.count('R')) ans=10**18 for x in range(1,n-1): for y in range(x+1,n): ans=min(ans,sum(b[:x])+sum(r[:x])+sum(w[x:y])+sum...
output
1
67,170
7
134,341
Provide a correct Python 3 solution for this coding contest problem. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red. Chai...
instruction
0
67,171
7
134,342
"Correct Solution: ``` n, m = map(int, input().split()) w = [] b = [] r = [] for i in range(n): s = input() w.append(m - s.count("W")) b.append(m - s.count("B")) r.append(m - s.count("R")) ans = 3000 for i in range(1, n - 1): for j in range(i, n - 1): ans = min(ans, sum(w[:i]) + sum(b[i:j+1]) + sum(r[j + ...
output
1
67,171
7
134,343
Provide a correct Python 3 solution for this coding contest problem. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red. Chai...
instruction
0
67,172
7
134,344
"Correct Solution: ``` n,m = map(int,input().split()) f_lis = [] for i in range(n): f_lis.append(list(str(input()))) ans_lis = [] W_num = [] W_cou = 0 B_num = [] B_cou = 0 R_num = [] R_cou = 0 for k in range(0,n): W_cou += f_lis[k].count('B') + f_lis[k].count('R') W_num.append(W_cou) for k in range(0,n):...
output
1
67,172
7
134,345
Provide a correct Python 3 solution for this coding contest problem. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red. Chai...
instruction
0
67,173
7
134,346
"Correct Solution: ``` def getPaintCount(string, color): return len(string)-string.count(color) N, M = map(int, input().split()) A = [] cnt = 0 for i in range(N): s = input().strip() if i==0: #1行目は白 cnt += getPaintCount(s, 'W') elif i==N-1: #最終行は赤 cnt += getPaintCount(s, 'R') else: A.append(s) #N-2行のリスト...
output
1
67,173
7
134,347
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each...
instruction
0
67,174
7
134,348
Yes
output
1
67,174
7
134,349
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each...
instruction
0
67,175
7
134,350
Yes
output
1
67,175
7
134,351
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each...
instruction
0
67,176
7
134,352
Yes
output
1
67,176
7
134,353
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each...
instruction
0
67,177
7
134,354
Yes
output
1
67,177
7
134,355
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. problem President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each...
instruction
0
67,178
7
134,356
No
output
1
67,178
7
134,357
Provide tags and a correct Python 3 solution for this coding contest problem. You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The color of the i-th lamp is s_i ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp mean...
instruction
0
67,291
7
134,582
Tags: constructive algorithms, dp, greedy Correct Solution: ``` n=int(input()) m=list(input()) i=0 k=0 q=["R","G","B"] if n==1: print(0) print(*m) exit() if n==2: if m[1]==m[0]: print(1) if q.index(m[0])==1: print(m[0]+q[2]) else: print(m[0...
output
1
67,291
7
134,583
Provide tags and a correct Python 3 solution for this coding contest problem. You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The color of the i-th lamp is s_i ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp mean...
instruction
0
67,292
7
134,584
Tags: constructive algorithms, dp, greedy Correct Solution: ``` def divGar(s, n): s = list(s) i = 0 c = 0 while (i < n-1): g = ['R', 'G', 'B'] if s[i] == s[i+1]: if i+2 < n: g.remove(s[i+2]) if s[i] in g: g.remove(s[i]) ...
output
1
67,292
7
134,585
Provide tags and a correct Python 3 solution for this coding contest problem. You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The color of the i-th lamp is s_i ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp mean...
instruction
0
67,293
7
134,586
Tags: constructive algorithms, dp, greedy Correct Solution: ``` # -*- coding: utf-8 -*- """ Created on Wed Jan 23 20:08:55 2019 @author: Himanshu Gwalani """ n=int(input()) ss=input() l=ss s=[] s.append('&') for i in l: s.append(i) s.append('&') count=0 for i in range(n): if s[i]==s[i+1]: if 'B'!=s[i]...
output
1
67,293
7
134,587
Provide tags and a correct Python 3 solution for this coding contest problem. You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The color of the i-th lamp is s_i ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp mean...
instruction
0
67,294
7
134,588
Tags: constructive algorithms, dp, greedy Correct Solution: ``` n= int(input()) s = input() l = len(s) color = ['R','B','G'] count = 0 col = list(s) # handle case for length less than 3 if l == 1: print(0) print(s) exit(0) if l == 2: if col[0] != col[1]: print(1) color.remove(col[1]) ...
output
1
67,294
7
134,589
Provide tags and a correct Python 3 solution for this coding contest problem. You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The color of the i-th lamp is s_i ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp mean...
instruction
0
67,295
7
134,590
Tags: constructive algorithms, dp, greedy Correct Solution: ``` input() lamps = list(input()) res = 0 for i in range(len(lamps)-1): if lamps[i] == lamps[i+1]: if i == len(lamps)-2: if lamps[i] != "B": lamps[i+1] = "B" else: lamps[i+1] = "R" el...
output
1
67,295
7
134,591
Provide tags and a correct Python 3 solution for this coding contest problem. You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The color of the i-th lamp is s_i ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp mean...
instruction
0
67,296
7
134,592
Tags: constructive algorithms, dp, greedy Correct Solution: ``` c=0 n=int(input()) s=list(input()) posible=['B','G','R'] if n!=1: for i in range(1,n-1): if s[i]==s[i-1]: if s[i]=='R' and s[i+1]!='B': s[i]='B' elif s[i]=='R' and s[i+1]!='G': s[i]='G' ...
output
1
67,296
7
134,593
Provide tags and a correct Python 3 solution for this coding contest problem. You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The color of the i-th lamp is s_i ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp mean...
instruction
0
67,297
7
134,594
Tags: constructive algorithms, dp, greedy Correct Solution: ``` n = int(input()) s = input() t = 0 li = ["G", "R", "B"] ans = s[0] for i in range(1, n): x = s[i] if x == ans[i - 1]: t += 1 if i < n - 1: z = s[i + 1] for y in li: if y != x and y != z: ...
output
1
67,297
7
134,595
Provide tags and a correct Python 3 solution for this coding contest problem. You have a garland consisting of n lamps. Each lamp is colored red, green or blue. The color of the i-th lamp is s_i ('R', 'G' and 'B' — colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp mean...
instruction
0
67,298
7
134,596
Tags: constructive algorithms, dp, greedy Correct Solution: ``` n=int(input()) s=input() ss=s[0] def ans(a,b): if a=='R': if b=='G': return 'B' else: return 'G' elif a=='G': if b=='R': return 'B' else: return 'R' else: ...
output
1
67,298
7
134,597