message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Provide a correct Python 3 solution for this coding contest problem. There are 2N people numbered 1 through 2N. The height of Person i is h_i. How many ways are there to make N pairs of people such that the following conditions are satisfied? Compute the answer modulo 998,244,353. * Each person is contained in exact...
instruction
0
45,933
14
91,866
"Correct Solution: ``` ROOT = 3 MOD = 998244353 roots = [pow(ROOT,(MOD-1)>>i,MOD) for i in range(24)] # 1 の 2^i 乗根 iroots = [pow(x,MOD-2,MOD) for x in roots] # 1 の 2^i 乗根の逆元 def untt(a,n): for i in range(n): m = 1<<(n-i-1) for s in range(1<<i): w_N = 1 s *= m*2 ...
output
1
45,933
14
91,867
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are 2N people numbered 1 through 2N. The height of Person i is h_i. How many ways are there to make N pairs of people such that the following conditions are satisfied? Compute the answer ...
instruction
0
45,938
14
91,876
Yes
output
1
45,938
14
91,877
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are 2N people numbered 1 through 2N. The height of Person i is h_i. How many ways are there to make N pairs of people such that the following conditions are satisfied? Compute the answer ...
instruction
0
45,941
14
91,882
No
output
1
45,941
14
91,883
Provide a correct Python 3 solution for this coding contest problem. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right...
instruction
0
45,944
14
91,888
"Correct Solution: ``` N = int(input()) P = list(map(int, input().split())) dp = [[min(i, N - i - 1, j, N - j - 1) for j in range(N)] for i in range(N)] presence = [[1 for j in range(N)] for i in range(N)] ans = 0 for i in range(len(P)): P[i] -= 1 x, y = divmod(P[i], N) ans += dp[x][y] presence[x][y]...
output
1
45,944
14
91,889
Provide a correct Python 3 solution for this coding contest problem. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right...
instruction
0
45,945
14
91,890
"Correct Solution: ``` N=int(input()) plist=list(map(int,input().split())) sit=[[1]*N for _ in range(N)] dist=[[min(i,j,N-1-i,N-1-j) for j in range(N)] for i in range(N)] answer=0 for p in plist: i=(p-1)//N j=(p-1)%N #print(i,j) sit[i][j]=0 answer+=dist[i][j] queue=[(i,j,dist[i][j])] d=0 while queu...
output
1
45,945
14
91,891
Provide a correct Python 3 solution for this coding contest problem. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right...
instruction
0
45,946
14
91,892
"Correct Solution: ``` import sys input = sys.stdin.readline from collections import deque n = int(input()) a = list(map(int,input().split())) n += 2 ls = [0 for i in range(n*n)] for i in range(n): for j in range(n): ls[i*n+j] = min(i,j,n-1-i,n-1-j)-1 ans = 0 st = [0]*(n*n) for i in a: x,y = divmod(i-1,n-2) i...
output
1
45,946
14
91,893
Provide a correct Python 3 solution for this coding contest problem. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right...
instruction
0
45,947
14
91,894
"Correct Solution: ``` from collections import deque n=int(input()) *p,=map(int, input().split()) for i in range(n*n):p[i]-=1 seats=[min(i//n,i%n,n-(i//n)-1,n-(i%n)-1) for i in range(n*n)] exist=[1]*(n*n) dxy=(n,-n,1,-1) ans=0 q=deque() for pi in p: ans+=seats[pi] exist[pi]=0 q.append(pi) while q: ...
output
1
45,947
14
91,895
Provide a correct Python 3 solution for this coding contest problem. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right...
instruction
0
45,948
14
91,896
"Correct Solution: ``` def main(): import sys input = sys.stdin.readline n = int(input()) l = list(map(int,input().split())) l = [((i-1)//n, (i-1) % n) for i in l] check = [[1 for j in range(n)] for i in range(n)] d = [[min(i, n-i-1, j, n-j-1) for j in range(n)] for i in range(n)] ans ...
output
1
45,948
14
91,897
Provide a correct Python 3 solution for this coding contest problem. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right...
instruction
0
45,949
14
91,898
"Correct Solution: ``` import sys input = sys.stdin.readline n = int(input()) p = list(map(int, input().split())) distance = [[min(i, j, n - i - 1, n - j - 1) for i in range(n)] for j in range(n)] check = [[1] * n for i in range(n)] p = [((i - 1) // n, (i - 1) % n) for i in p] def move(x,y,nx,ny): if distance[nx...
output
1
45,949
14
91,899
Provide a correct Python 3 solution for this coding contest problem. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right...
instruction
0
45,950
14
91,900
"Correct Solution: ``` cin = open(0).read().strip().split('\n') n = int(cin[0]) p = list(map(int, cin[1].split(' '))) space = [1]*(n*n) dist = [0]*(n*n) for r in range(n): for c in range(n): dist[r*n+c] = min(r, (n-1)-r, c, (n-1)-c) ans = 0 for pi in p: pi -= 1 q = [pi] ans += dist[pi] sp...
output
1
45,950
14
91,901
Provide a correct Python 3 solution for this coding contest problem. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right...
instruction
0
45,951
14
91,902
"Correct Solution: ``` N, = map(int, input().split()) R = [0] * (N**2+1) V = [0] * (N**2+1) X = list(map(int, input().split())) for ai in range(N**2): i, j = divmod(ai, N) R[ai+1] = min([i, N-i-1, j, N-j-1]) r = 0 for a in X: r += R[a] V[a] = 1 stack=[a] while stack: v = stack.pop() ...
output
1
45,951
14
91,903
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\...
instruction
0
45,952
14
91,904
Yes
output
1
45,952
14
91,905
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\...
instruction
0
45,953
14
91,906
Yes
output
1
45,953
14
91,907
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\...
instruction
0
45,954
14
91,908
Yes
output
1
45,954
14
91,909
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\...
instruction
0
45,955
14
91,910
Yes
output
1
45,955
14
91,911
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\...
instruction
0
45,956
14
91,912
No
output
1
45,956
14
91,913
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\...
instruction
0
45,957
14
91,914
No
output
1
45,957
14
91,915
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\...
instruction
0
45,958
14
91,916
No
output
1
45,958
14
91,917
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\...
instruction
0
45,959
14
91,918
No
output
1
45,959
14
91,919
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. is a startup company whose main business is the development and operation of the programming competition site "ButCoder". There are N members of the company including the presiden...
instruction
0
46,040
14
92,080
No
output
1
46,040
14
92,081
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. is a startup company whose main business is the development and operation of the programming competition site "ButCoder". There are N members of the company including the presiden...
instruction
0
46,041
14
92,082
No
output
1
46,041
14
92,083
Provide a correct Python 3 solution for this coding contest problem. There are M chairs arranged in a line. The coordinate of the i-th chair (1 ≤ i ≤ M) is i. N people of the Takahashi clan played too much games, and they are all suffering from backaches. They need to sit in chairs and rest, but they are particular a...
instruction
0
46,045
14
92,090
"Correct Solution: ``` class LazySegmentTree(): def __init__(self,n,init,merge_func=min,ide_ele=10**18): self.n=(n-1).bit_length() self.merge_func=merge_func self.ide_ele=ide_ele self.data=[0 for i in range(1<<(self.n+1))] self.lazy=[0 for i in range(1<<(self.n+1))] f...
output
1
46,045
14
92,091
Provide a correct Python 3 solution for this coding contest problem. There are M chairs arranged in a line. The coordinate of the i-th chair (1 ≤ i ≤ M) is i. N people of the Takahashi clan played too much games, and they are all suffering from backaches. They need to sit in chairs and rest, but they are particular a...
instruction
0
46,049
14
92,098
"Correct Solution: ``` import sys input=sys.stdin.readline N,M=map(int,input().split()) # N: 処理する区間の長さ INF = 2**31-1 LV = (M+2-1).bit_length() N0 = 2**LV data = [0]*(2*N0) lazy = [0]*(2*N0) def gindex(l, r): L = (l + N0) >> 1; R = (r + N0) >> 1 lc = 0 if l & 1 else (L & -L).bit_length() rc = 0 if r & 1...
output
1
46,049
14
92,099
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are M chairs arranged in a line. The coordinate of the i-th chair (1 ≤ i ≤ M) is i. N people of the Takahashi clan played too much games, and they are all suffering from backaches. They n...
instruction
0
46,051
14
92,102
Yes
output
1
46,051
14
92,103
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are M chairs arranged in a line. The coordinate of the i-th chair (1 ≤ i ≤ M) is i. N people of the Takahashi clan played too much games, and they are all suffering from backaches. They n...
instruction
0
46,055
14
92,110
No
output
1
46,055
14
92,111
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are M chairs arranged in a line. The coordinate of the i-th chair (1 ≤ i ≤ M) is i. N people of the Takahashi clan played too much games, and they are all suffering from backaches. They n...
instruction
0
46,056
14
92,112
No
output
1
46,056
14
92,113
Provide a correct Python 3 solution for this coding contest problem. I have a lot of friends. Every friend is very small. I often go out with my friends. Put some friends in your backpack and go out together. Every morning I decide which friends to go out with that day. Put friends one by one in an empty backpack. I'm...
instruction
0
46,130
14
92,260
"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**13 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)] def LI(): return [int...
output
1
46,130
14
92,261
Provide a correct Python 3 solution for this coding contest problem. I have a lot of friends. Every friend is very small. I often go out with my friends. Put some friends in your backpack and go out together. Every morning I decide which friends to go out with that day. Put friends one by one in an empty backpack. I'm...
instruction
0
46,131
14
92,262
"Correct Solution: ``` N, W = map(int, input().split()) w = [] for i in range(N): w.append(int(input())) w.sort() summ = 0 ans = 0 for num, wi in enumerate(w): if num == N - 1: if sum(w) - w[-1] <= W and W - sum(w) - w[-1] < w[-1]: ans += 1 break dp = [[0] * (W + 1) for i in rang...
output
1
46,131
14
92,263
Provide a correct Python 3 solution for this coding contest problem. I have a lot of friends. Every friend is very small. I often go out with my friends. Put some friends in your backpack and go out together. Every morning I decide which friends to go out with that day. Put friends one by one in an empty backpack. I'm...
instruction
0
46,132
14
92,264
"Correct Solution: ``` N, W = map(int, input().split()) MOD = 10**9 + 7 ws = [int(input()) for i in range(N)] ws.sort(reverse=1) su = sum(ws) dp = [0]*(W+1) dp[0] = 1 ans = 0 if su <= W: ans += 1 for i in range(N): w = ws[i] su -= w ans += sum(dp[max(W+1-w-su, 0):max(W+1-su, 0)]) % MOD for j in rang...
output
1
46,132
14
92,265
Provide tags and a correct Python 3 solution for this coding contest problem. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Creatnx asks the mirrors one b...
instruction
0
46,350
14
92,700
Tags: data structures, dp, math, probabilities Correct Solution: ``` # by the authority of GOD author: manhar singh sachdev # import os,sys from io import BytesIO, IOBase def main(): mod = 998244353 div = pow(100,mod-2,mod) n = int(input()) p = list(map(lambda xx:(int(xx)*div)%mod,input().split()...
output
1
46,350
14
92,701
Provide tags and a correct Python 3 solution for this coding contest problem. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Creatnx asks the mirrors one b...
instruction
0
46,351
14
92,702
Tags: data structures, dp, math, probabilities Correct Solution: ``` n = int(input()) exp = 0 M = 998244353 for pi in map(int, input().split()): exp = (exp+1)*100*pow(pi, M-2, M) %M print(int(exp%M)) ```
output
1
46,351
14
92,703
Provide tags and a correct Python 3 solution for this coding contest problem. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Creatnx asks the mirrors one b...
instruction
0
46,352
14
92,704
Tags: data structures, dp, math, probabilities Correct Solution: ``` prime=998244353 def power(x, y, prime): b = bin(y)[2:] start = x answer = 1 for i in range(len(b)): b2 = b[len(b)-1-i] if b2=='1': answer = (answer*start) % prime start = (start*start) % prime r...
output
1
46,352
14
92,705
Provide tags and a correct Python 3 solution for this coding contest problem. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Creatnx asks the mirrors one b...
instruction
0
46,353
14
92,706
Tags: data structures, dp, math, probabilities Correct Solution: ``` def solve(): s = input() if 'aa' in s or 'bb' in s or 'cc' in s: print(-1) return syms = s + '@' ans = ['@'] for i, sym in enumerate(s): if sym != '?': ans.append(sym) continue ...
output
1
46,353
14
92,707
Provide tags and a correct Python 3 solution for this coding contest problem. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Creatnx asks the mirrors one b...
instruction
0
46,354
14
92,708
Tags: data structures, dp, math, probabilities Correct Solution: ``` n = int(input()) p = list(map(int, input().split())) ans = 0 size = 998244353 for p in p: ans = (ans+1) % size ans = (((ans*100) % size)*pow(p, size-2, size)) % size print(ans) ```
output
1
46,354
14
92,709
Provide tags and a correct Python 3 solution for this coding contest problem. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Creatnx asks the mirrors one b...
instruction
0
46,355
14
92,710
Tags: data structures, dp, math, probabilities Correct Solution: ``` # import random import time import sys # random.seed(a=3742967) # f = open('test.txt', 'w+') # f.write("200000\n") # for i in range(0, 200000): # f.write(f'{random.randint(1, 99)} ') # f.write('\n') # f.seek(0) f = sys.stdin t1 = time.time() n ...
output
1
46,355
14
92,711
Provide tags and a correct Python 3 solution for this coding contest problem. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Creatnx asks the mirrors one b...
instruction
0
46,356
14
92,712
Tags: data structures, dp, math, probabilities Correct Solution: ``` mod=998244353 n=int(input()) ar=list(map(int,input().split())) m,mul=1,[1] div=pow(100,mod-2,mod) for i in ar: mul.append((mul[-1]*i*div)%mod) num=0 den=pow(mul[n],mod-2,mod) for i in mul: num+=i num%=mod print((num*den-1)%mod) ```
output
1
46,356
14
92,713
Provide tags and a correct Python 3 solution for this coding contest problem. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n. Creatnx asks the mirrors one b...
instruction
0
46,357
14
92,714
Tags: data structures, dp, math, probabilities Correct Solution: ``` input() p=list(map(int,input().split())) mod=998244353 f=0 for i in p: f=100*(f+1)*pow(i,mod-2,mod)%mod print(f) ```
output
1
46,357
14
92,715
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for...
instruction
0
46,358
14
92,716
Yes
output
1
46,358
14
92,717
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for...
instruction
0
46,359
14
92,718
Yes
output
1
46,359
14
92,719
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for...
instruction
0
46,360
14
92,720
Yes
output
1
46,360
14
92,721
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for...
instruction
0
46,361
14
92,722
Yes
output
1
46,361
14
92,723
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for...
instruction
0
46,362
14
92,724
No
output
1
46,362
14
92,725
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for...
instruction
0
46,363
14
92,726
No
output
1
46,363
14
92,727
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for...
instruction
0
46,364
14
92,728
No
output
1
46,364
14
92,729
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for...
instruction
0
46,365
14
92,730
No
output
1
46,365
14
92,731
Provide tags and a correct Python 3 solution for this coding contest problem. It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students are angry. Let's describe a group of student...
instruction
0
46,366
14
92,732
Tags: greedy, implementation Correct Solution: ``` for i in range(int(input())): n = int(input()) a = list(input()) ans, flag, j, pointer = 0, 0, 0, 0 freq = [0]*len(a) for i in range(len(a)): if (a[i] == "A"): pointer = 1 if (a[i] == "P" and i != 0 and pointer == 1): ...
output
1
46,366
14
92,733
Provide tags and a correct Python 3 solution for this coding contest problem. It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students are angry. Let's describe a group of student...
instruction
0
46,367
14
92,734
Tags: greedy, implementation Correct Solution: ``` I=input exec(int(I())*"I();print(max(0,0,*map(len,I().split('A')[1:])));") #JSR ```
output
1
46,367
14
92,735
Provide tags and a correct Python 3 solution for this coding contest problem. It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students are angry. Let's describe a group of student...
instruction
0
46,368
14
92,736
Tags: greedy, implementation Correct Solution: ``` for _ in range(int(input())): n=int(input()) a=list(input()) t=[] f=0 c=0 while(a!=t): t=a[:] c+=1 for i in range(n-1,0,-1): if(a[i-1]=='A'): a[i]='A' #print(i) print(c-1) ```
output
1
46,368
14
92,737
Provide tags and a correct Python 3 solution for this coding contest problem. It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students are angry. Let's describe a group of student...
instruction
0
46,369
14
92,738
Tags: greedy, implementation Correct Solution: ``` import math class Read: @staticmethod def string(): return input() @staticmethod def int(): return int(input()) @staticmethod def list(sep=' '): return input().split(sep) @staticmethod def list_int(sep=' '): ...
output
1
46,369
14
92,739
Provide tags and a correct Python 3 solution for this coding contest problem. It's a walking tour day in SIS.Winter, so t groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students are angry. Let's describe a group of student...
instruction
0
46,370
14
92,740
Tags: greedy, implementation Correct Solution: ``` T = int(input()) for test in range(T): n = int(input()) s = input() ans = 0 tans = 0 if 'A' not in s: print(0) continue j = s.index('A') for i in range(j, n): if s[i] == 'P': tans += 1 else: ...
output
1
46,370
14
92,741