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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-...
instruction
0
84,861
7
169,722
No
output
1
84,861
7
169,723
Provide a correct Python 3 solution for this coding contest problem. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator. Figure 1 is an e...
instruction
0
84,950
7
169,900
"Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 998244353 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.rea...
output
1
84,950
7
169,901
Provide a correct Python 3 solution for this coding contest problem. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator. Figure 1 is an e...
instruction
0
84,951
7
169,902
"Correct Solution: ``` while True: n, w = map(int, input().split()) if n is 0 and w is 0: break l = [int(input()) for i in range(n)] max_num = 0 for i in range(n): max_num = max(max_num, l[i]) hist_size = int((max_num/w) + 1) hist = [0.0] * int(hist_size) for i in r...
output
1
84,951
7
169,903
Provide a correct Python 3 solution for this coding contest problem. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator. Figure 1 is an e...
instruction
0
84,952
7
169,904
"Correct Solution: ``` # coding: utf-8 while 1: n,w=map(int,input().split()) if n==0: break dic={} mx=-1 max_section=-1 for i in range(1+100//w): dic[i]=0 for i in range(n): x=int(input()) dic[x//w]+=1 mx=max(mx,dic[x//w]) max_section=max(max_s...
output
1
84,952
7
169,905
Provide a correct Python 3 solution for this coding contest problem. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator. Figure 1 is an e...
instruction
0
84,953
7
169,906
"Correct Solution: ``` while True: n, w = list(map(int, input().split())) if n==0: break v = [int(input()) for i in range(n)] h = [0 for i in range(100)] ma = 0 mi = 1e9 for i in range(n): h[v[i]//w] += 1 ma = max(ma, v[i]//w) mi = min(mi, v[i]//w) sm = ma-mi h = [h[i]/max(h) for i in ...
output
1
84,953
7
169,907
Provide a correct Python 3 solution for this coding contest problem. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator. Figure 1 is an e...
instruction
0
84,954
7
169,908
"Correct Solution: ``` while True: N,W = map(int,input().split()) if N == 0: break src = [int(input()) for i in range(N)] highest = max(src) bands = highest//W + 1 hist = [0 for i in range(bands)] for i in range(N): hist[src[i] // W] += 1 ans = maxn = 0 for i,n in enumerate(h...
output
1
84,954
7
169,909
Provide a correct Python 3 solution for this coding contest problem. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator. Figure 1 is an e...
instruction
0
84,955
7
169,910
"Correct Solution: ``` while True: N, W = map(int, input().split()) if not N: break s = list(sorted([int(input()) for i in range(N)])) m = s[-1] // W + 1 ss = [0] * m for c in s: ss[c // W] += 1 unit = max(ss) a = 0 for i, c in enumerate(ss): a += (1 - i / (m ...
output
1
84,955
7
169,911
Provide a correct Python 3 solution for this coding contest problem. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator. Figure 1 is an e...
instruction
0
84,956
7
169,912
"Correct Solution: ``` while 1: n,w=map(int,input().split()) if n==w==0:break a=[0]*100 s=h=int(0) while n: b=int(input()) a[b//w]+=1 s=max(s,b//w) h=max(h,a[b//w]) n-=1 ans=0.01 for i in range(int(s)+1): ans+=a[i]/h*(s-i)/s print(ans) ```
output
1
84,956
7
169,913
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a...
instruction
0
84,957
7
169,914
No
output
1
84,957
7
169,915
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a...
instruction
0
84,958
7
169,916
No
output
1
84,958
7
169,917
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a...
instruction
0
84,959
7
169,918
No
output
1
84,959
7
169,919
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a...
instruction
0
84,960
7
169,920
No
output
1
84,960
7
169,921
Provide tags and a correct Python 3 solution for this coding contest problem. There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1). You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ...
instruction
0
85,812
7
171,624
Tags: dfs and similar, dsu, graphs Correct Solution: ``` from sys import stdin input = stdin.readline n , k = [int(i) for i in input().split()] pairs = [i + k for i in range(k)] + [i for i in range(k)] initial_condition = list(map(lambda x: x == '1',input().strip())) data = [i for i in range(2*k)] constrain = [-1] * ...
output
1
85,812
7
171,625
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1). You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any thr...
instruction
0
85,813
7
171,626
No
output
1
85,813
7
171,627
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it tur...
instruction
0
86,131
7
172,262
Tags: implementation Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] d...
output
1
86,131
7
172,263
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it tur...
instruction
0
86,132
7
172,264
Tags: implementation Correct Solution: ``` n,m=map(int,input().split()) yy=[] for i in range(n): x=list(map(int,input().split())) x=x[1:] yy.append(x) main=[] for i in yy: for j in i: main.append(j) main=set(main) gg={0} for i in range(1,m+1): gg.add(i) gg.remove(0) if(gg==main): print("YES") else: print(...
output
1
86,132
7
172,265
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it tur...
instruction
0
86,133
7
172,266
Tags: implementation Correct Solution: ``` n,m=map(int,input().split(" ")) L=[0]*(m) for k in range(n): i=0 for j in map(int,input().split(" ")): if(i!=0): L[j-1]=1 i+=1 if(sum(L)==m): print("YES") else: print("NO") ```
output
1
86,133
7
172,267
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it tur...
instruction
0
86,134
7
172,268
Tags: implementation Correct Solution: ``` if __name__ == '__main__': n, m = map(int, input().split()) s = set() for _ in range(n): s.update(map(int, input().split()[1:])) print('YES' if len(s) == m else 'NO') ```
output
1
86,134
7
172,269
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it tur...
instruction
0
86,135
7
172,270
Tags: implementation Correct Solution: ``` a,b=map(int,input().split()) y=[] k=0 for i in range(0,a): x=list(map(int,input().split())) y.extend(x[1:]) for i in range(1,b+1): if(y.count(i)<1): k=-1 print("NO") break if(k==0): print("YES") ```
output
1
86,135
7
172,271
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it tur...
instruction
0
86,136
7
172,272
Tags: implementation Correct Solution: ``` n , m = list(map(int,input().split())) p = [] for i in range(n): l = list(map(int,input().split())) for k in range(1,len(l)): p.append(l[k]) setp = set(p) o = [] for i in range(1,m+1): o.append(i) seto = set(o) if len(seto)==len(setp): print("YES") else: print("NO") `...
output
1
86,136
7
172,273
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it tur...
instruction
0
86,137
7
172,274
Tags: implementation Correct Solution: ``` def main(): n, m = map(int, input().split()) a = set({}) for i in range(n): b = list(map(int, input().split())) a.update(b[1:]) print("YES" if(len(a) == m) else "NO") if __name__ == "__main__": main() ```
output
1
86,137
7
172,275
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it tur...
instruction
0
86,138
7
172,276
Tags: implementation Correct Solution: ``` (n, m) = map(int, input().split()) a = [] for i in range(n): a += list(map(int, input().split()))[1:] print( 'YES' if len(set(a)) == m else 'NO') ```
output
1
86,138
7
172,277
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of th...
instruction
0
86,139
7
172,278
Yes
output
1
86,139
7
172,279
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of th...
instruction
0
86,140
7
172,280
Yes
output
1
86,140
7
172,281
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of th...
instruction
0
86,141
7
172,282
Yes
output
1
86,141
7
172,283
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of th...
instruction
0
86,142
7
172,284
Yes
output
1
86,142
7
172,285
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of th...
instruction
0
86,143
7
172,286
No
output
1
86,143
7
172,287
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of th...
instruction
0
86,144
7
172,288
No
output
1
86,144
7
172,289
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of th...
instruction
0
86,145
7
172,290
No
output
1
86,145
7
172,291
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of th...
instruction
0
86,146
7
172,292
No
output
1
86,146
7
172,293
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. * The ...
instruction
0
87,110
7
174,220
Tags: brute force, constructive algorithms, math Correct Solution: ``` n,a,b,c,d = map(int, input().split()) num = 0 i = 0 while n > i: i += 1 if i + b - c < 1 or i + b - c > n: continue if i + a - d < 1 or i + a - d > n: continue if i + a - d + b - c < 1 or i + a - d + b - c > n: ...
output
1
87,110
7
174,221
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. * The ...
instruction
0
87,111
7
174,222
Tags: brute force, constructive algorithms, math Correct Solution: ``` import sys sys.stderr = sys.stdout def painting(n, a, b, c, d): lo = min(a+b, c+d, a+c, b+d) hi = max(a+b, c+d, a+c, b+d) delta = hi - lo return max(n - delta, 0) * n def main(): n, a, b, c, d = readinti() print(painting(...
output
1
87,111
7
174,223
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. * The ...
instruction
0
87,112
7
174,224
Tags: brute force, constructive algorithms, math Correct Solution: ``` n, a, b, c, d = map(int, input().split()) k = 0 for u in range(1, n + 1): v = u + b - c if (v >= 1) and (v <= n): z = a + v - d if (z >= 1) and (z <= n): y = c + z - b if (y >= 1) and (y <= n): u = d + y - a if (u >= 1) and (u <...
output
1
87,112
7
174,225
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. * The ...
instruction
0
87,113
7
174,226
Tags: brute force, constructive algorithms, math Correct Solution: ``` n, a, b, c, d = map(int, input().split()) lo = min(a+b, a+c, c+d, b+d) hi = max(a+b, a+c, c+d, b+d) ans = 0 for x in range(1, n+1): ans += max(0, n-(hi-lo)) print(ans) ```
output
1
87,113
7
174,227
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. * The ...
instruction
0
87,114
7
174,228
Tags: brute force, constructive algorithms, math Correct Solution: ``` from re import * from sys import stderr def readint(): return int(input()) def readfloat(): return float(input()) def readarray(N, foo=input): return [foo() for i in range(N)] def readlinearray(foo=int): return map(foo, input().split...
output
1
87,114
7
174,229
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. * The ...
instruction
0
87,115
7
174,230
Tags: brute force, constructive algorithms, math Correct Solution: ``` import math as m n,a,b,c,d=(map(int,input().split())) ans=0 for i in range(n): x=i+1 t=x+b-c curr=1 if t>=1 and t<=n: curr=1 else: curr=0 t=x+a-d if t>=1 and t<=n and curr!=0: curr=1 else: curr*=0 t=x+a+b-d-c if t>=1 and t<=n and c...
output
1
87,115
7
174,231
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. * The ...
instruction
0
87,116
7
174,232
Tags: brute force, constructive algorithms, math Correct Solution: ``` from collections import * n,a,b,c,d = list(map(int,input().split())) print((n-min(n,max(abs(a+b-c-d),abs(b-c),abs(a-d),abs(a+c-b-d))))*n) ```
output
1
87,116
7
174,233
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts about it. * The ...
instruction
0
87,117
7
174,234
Tags: brute force, constructive algorithms, math Correct Solution: ``` n, a, b, c, d = map(int, input().split()) count = 0 for x in range(1, n + 1): w = x + c - b if w >= 1 and w <= n: y = a + w - d if y >= 1 and y <= n: z = a + x - d if z >= 1 and z <= n: count = count + 1 print(count * n) ```
output
1
87,117
7
174,235
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painti...
instruction
0
87,118
7
174,236
Yes
output
1
87,118
7
174,237
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painti...
instruction
0
87,119
7
174,238
Yes
output
1
87,119
7
174,239
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painti...
instruction
0
87,120
7
174,240
Yes
output
1
87,120
7
174,241
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painti...
instruction
0
87,121
7
174,242
Yes
output
1
87,121
7
174,243
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painti...
instruction
0
87,122
7
174,244
No
output
1
87,122
7
174,245
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painti...
instruction
0
87,123
7
174,246
No
output
1
87,123
7
174,247
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painti...
instruction
0
87,124
7
174,248
No
output
1
87,124
7
174,249
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painti...
instruction
0
87,125
7
174,250
No
output
1
87,125
7
174,251
Provide a correct Python 3 solution for this coding contest problem. We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue balls....
instruction
0
87,336
7
174,672
"Correct Solution: ``` """ Writer: SPD_9X2 https://atcoder.jp/contests/agc037/tasks/agc037_b 最適な配り方とは何かを考えるべき そうすれば自然なdpに落ちるんだろうな RGBが出たら合体させないといけない? →これは正しそう RGGRBB 112212 →4+3=7 112221 →5+2=7 121212 →4+4=8 なので、RGBが出たらランダムに合わせればいいわけではない 2つでたら合体しなければいけない説 RG→合体 GR→合体 B →2通り B →1通り なので2通り? それっぽいぞ BBRGRRGRGGRBBGB ...
output
1
87,336
7
174,673
Provide a correct Python 3 solution for this coding contest problem. We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue balls....
instruction
0
87,337
7
174,674
"Correct Solution: ``` from bisect import* e=enumerate M=998244353 R,G,B=[],[],[] n=int(input()) for i,c in e(input()): if c=='R':R+=i, elif c=='G':G+=i, else:B+=i, l,m,r=[],[],[] for i,t in e(zip(R,G,B)): a,b,c=sorted(t) l+=a, m+=b, r+=c, s=1 for i,b in e(m): s=s*(bisect(l,b)-i)*(i-bisect(r,b)+1)*(i+1)...
output
1
87,337
7
174,675
Provide a correct Python 3 solution for this coding contest problem. We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue balls....
instruction
0
87,338
7
174,676
"Correct Solution: ``` #!/usr/bin/env python3 MOD = 998244353 n = int(input()) s = input() ans = 1 for i in range(n): ans *= i + 1 ans %= MOD cnt = [0] * 3 dic = {'R': 0, 'G': 1, 'B': 2} for c in s: p = dic[c] m = min(cnt[p - 1], cnt[p - 2]) if m > 0: ans *= m cnt[p - 1] -= 1 ...
output
1
87,338
7
174,677
Provide a correct Python 3 solution for this coding contest problem. We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue balls....
instruction
0
87,339
7
174,678
"Correct Solution: ``` from functools import reduce N = int(input()) S = input() MOD = 998244353 class ModInt: def __init__(self, x): self.x = x % MOD def __str__(self): return str(self.x) __repr__ = __str__ def __add__(self, other): return ( ModInt(self.x + ot...
output
1
87,339
7
174,679