output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print `YES` or `NO`. * * *
s189148398
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
s=input().split();a=int(s[0]);b=int(s[1]);c=int(s[2]);pd=0 for i in range(0,1000): if a*i%b=c: print('YES') pd=1 break if pd=0: print('NO')
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s813619827
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
a,b,c = [int(i) for i in input().split()] arr = set() ret = "NO" r = a%b if r==0: if c==0: ret="YES" else: pass elif r==1: ret = "YES" else: rr = r while not(rr in arr): # print(arr,rr) if rr <= c and (c-rr)%r == 0: ret = "YES" break else: arr.add(rr) n = int(b-rr)/r n += 1 if (b-rr)%r != 0 rr = (n*r + rr)%b print(ret)
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s575887419
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
a, b, c = [int(x) for x in input().split()] from math import gcd def foo(a, b, c): if a == 1: return "YES" elif b == 1: return "NO" elif gcd(a, b) ==1: return "NO: else: return "YES"
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s054320591
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
A,B,C = map(int,input().split()) found = False for i in range(1,B+1): if A * i % B == C: found = True if found = True: print("YES") else: print("NO")
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s982063111
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
A, B, C = map(int,input().split()) n = 100 * B for i in range(1, n, B): if A * i % B = C: print("YES") flag == True: break else: continue if flag != True: print("No")
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s964271907
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
a, b, c = map(int, input().split()) flg = 0 for i in range(100000000): if (i*a)%b = c: flg+=1 break if flg==0: print("NO") else: print("YES")
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s445702055
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
a, _, c = map(int, input()).split() print(["YES", "NO"][a & 1 == 0 and c & 1])
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s542464422
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
#ABC060B A, B, C = map(int, input().split() if A % 2 == (2 * B + 1) % 2: print("YES") else: print("NO")
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s376252371
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
A,B,C=(int(i) for i in input().split()) if (C-A%B)%((2*A)%B))-(A%B)==0: print(YES) else: print(NO)
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s338633535
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
a,b,c = map(int, input().split()) flag = 0 for i in range(1,b+1): if (a*1-c)%b==0: flag = 1 break print('YES' if flag = 1 else 'NO')
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s864086994
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
,b,c = map(int,input().split()) for i in range(1,b+1): if a*i%b == c: print('YES') break else: print('NO')
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s865895774
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) x=0 for i in range(1,b+1): if i*a%==c: x+=1 if x==0: print('NO') else: print('YES')
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s272501484
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
A,B,C = map(int,input().split()) D = A % B M = D ok = False for _ in range(B+1): if M == C: ok = True break M = (M + D) % B if ok: print('YES') else: print('NO')
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print `YES` or `NO`. * * *
s120335981
Runtime Error
p03730
Input is given from Standard Input in the following format: A B C
a, b, c = map(int, input().split()) while a != 0: a, b = b%a, a if c % b = 0: print("YES") else: print("NO")
Statement We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
[{"input": "7 5 1", "output": "YES\n \n\nFor example, if you select 7 and 14, the sum 21 is congruent to 1 modulo 5.\n\n* * *"}, {"input": "2 2 1", "output": "NO\n \n\nThe sum of even numbers, no matter how many, is never odd.\n\n* * *"}, {"input": "1 100 97", "output": "YES\n \n\nYou can select 97, since you may select multiples of 1, that is, all integers.\n\n* * *"}, {"input": "40 98 58", "output": "YES\n \n\n* * *"}, {"input": "77 42 36", "output": "NO"}]
Print the minimum number of characters in S that need to be changed. * * *
s749716915
Wrong Answer
p02571
Input is given from Standard Input in the following format: S T
s=input() t=input() t_substrings=[] for i in range(len(t)+1): for j in range(i): t_substrings.append(t[j:i]) t_substrings=list(set(t_substrings)) #print(t_substrings) ans=len(t) for str in t_substrings: num=s.rfind(str) num_t=t.rfind(str) #print("str",str) #print("num",num) if num==-1: pass elif num+len(str)-1>=len(s): pass elif num_t-num>=0: pass else: # print("##") ans=min(len(t)-len(str),ans) #print(ans) #print("----------------") print(ans)
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s789340453
Accepted
p02571
Input is given from Standard Input in the following format: S T
sta=list(input()) stb=list(input()) max=0 for a in range(len(sta)-len(stb)+1): max1=0 for b in range(len(stb)): if sta[a+b]==stb[b]: max1+=1 if max1>max: max=max1 print(len(stb)-max)
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s251143585
Wrong Answer
p02571
Input is given from Standard Input in the following format: S T
S = input() subS = input() max_common = 0 for idx in range(len(S)): curr_idx = idx sub_idx = 0 curr_max = 0 while sub_idx < len(subS) and curr_idx < len(S): if subS[sub_idx] == S[curr_idx]: curr_max += 1 sub_idx += 1 curr_idx += 1 if curr_max > max_common: max_common = curr_max print(len(subS) - max_common)
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s046656463
Accepted
p02571
Input is given from Standard Input in the following format: S T
s1 = str(input()) s2 = str(input()) diff = [] for i in range(0, len(s1) - len(s2) + 1): str1 = s1[i : i + len(s2)] # print(str1) val = 0 for i in range(len(str1)): if abs(ord(str1[i]) - ord(s2[i])) > 0: val += 1 diff.append(val) print(min(diff))
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s864855663
Accepted
p02571
Input is given from Standard Input in the following format: S T
S=input() T=input() a=[] for i in range(len(S)-len(T)+1) : count=0 for j in range(len(T)) : if S[i:i+len(T)][j]==T[j] : count+=1 a.append(count) print(len(T)-max(a))
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s981603888
Accepted
p02571
Input is given from Standard Input in the following format: S T
s1 = input() s2 = input() list_s1 = list(s1) list_s2 = list(s2) len_s1 = len(s1) len_s2 = len(s2) change_count_min = len_s2 for i in range(len_s1 - len_s2 + 1): change_count = len_s2 for j in range(len_s2): if list_s1[j + i] == list_s2[j]: change_count -= 1 if change_count < change_count_min: change_count_min = change_count print(change_count_min)
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s397287782
Wrong Answer
p02571
Input is given from Standard Input in the following format: S T
S = input() t = input() neq = len(t) for i in range(len(S) - len(t) + 1): if S[i] == t[0]: neq_temp = 0 for j in range(1, len(t)): if S[i + j] != t[j]: neq += 1 neq = min(neq, neq_temp) print(neq)
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s727226489
Accepted
p02571
Input is given from Standard Input in the following format: S T
s, (*t, _) = open(0) print(min(sum(x != y for x, y in zip(s[i:], t)) for i in range(len(s) - len(t))))
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s959145349
Accepted
p02571
Input is given from Standard Input in the following format: S T
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def SI(): return sys.stdin.readline()[:-1] s = SI() t = SI() sn = len(s) tn = len(t) ans = 100000 for i in range(sn - tn + 1): cur = 0 for j in range(tn): cur += s[i + j] != t[j] ans = min(ans, cur) print(ans)
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s136473666
Accepted
p02571
Input is given from Standard Input in the following format: S T
import sys 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): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") sys.setrecursionlimit(10**9) INF = 10**19 MOD = 10**19 + 7 EPS = 10**-10 S = list(input()) T = list(input()) N = len(S) M = len(T) def check(S, T): res = 0 for i in range(M): if S[i] != T[i]: res += 1 return res ans = INF for i in range(N - M + 1): ans = min(ans, check(S[i : i + M], T)) print(ans)
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the minimum number of characters in S that need to be changed. * * *
s086631300
Wrong Answer
p02571
Input is given from Standard Input in the following format: S T
a = "abc" print(a[0:])
Statement Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, `xxx` is a substring of `yxxxy`, but not a substring of `xxyxx`.
[{"input": "cabacc\n abc", "output": "1\n \n\nFor example, changing the fourth character `a` in S to `c` will match the\nsecond through fourth characters in S to T.\n\nSince S itself does not have T as its substring, this number of changes - one\n- is the minimum needed.\n\n* * *"}, {"input": "codeforces\n atcoder", "output": "6"}]
Print the number of cards that face down after all the operations. * * *
s200644993
Wrong Answer
p03419
Input is given from Standard Input in the following format: N M
# n,m = map(int,input().split()) n, m = 5, 5 lis = [[0] * n for _ in range(m)] for i in range(n): for j in range(m): if i == 0: if j == 0: lis[i][j] += 1 lis[i][j + 1] += 1 lis[i + 1][j] += 1 lis[i + 1][j + 1] += 1 elif j == m - 1: lis[i][j] += 1 lis[i][j - 1] += 1 lis[i + 1][j] += 1 lis[i + 1][j - 1] += 1 else: lis[i][j] += 1 lis[i][j - 1] += 1 lis[i + 1][j] += 1 lis[i + 1][j - 1] += 1 lis[i][j + 1] += 1 lis[i + 1][j + 1] += 1 elif i == n - 1: if j == 0: lis[i][j] += 1 lis[i][j + 1] += 1 lis[i - 1][j] += 1 lis[i - 1][j + 1] += 1 elif j == m - 1: lis[i][j] += 1 lis[i][j - 1] += 1 lis[i - 1][j] += 1 lis[i - 1][j - 1] += 1 else: lis[i][j] += 1 lis[i][j - 1] += 1 lis[i - 1][j] += 1 lis[i - 1][j - 1] += 1 lis[i][j + 1] += 1 lis[i - 1][j + 1] += 1 else: if j == 0: lis[i][j] += 1 lis[i][j + 1] += 1 lis[i + 1][j] += 1 lis[i + 1][j + 1] += 1 lis[i - 1][j] += 1 lis[i - 1][j + 1] += 1 elif j == m - 1: lis[i][j] += 1 lis[i][j - 1] += 1 lis[i - 1][j] += 1 lis[i - 1][j - 1] += 1 lis[i + 1][j] += 1 lis[i + 1][j - 1] += 1 else: lis[i][j] += 1 lis[i][j - 1] += 1 lis[i][j + 1] += 1 lis[i - 1][j] += 1 lis[i - 1][j - 1] += 1 lis[i - 1][j + 1] += 1 lis[i + 1][j] += 1 lis[i + 1][j - 1] += 1 lis[i + 1][j + 1] += 1 # print(lis) cnt = 0 for i in range(n): for j in range(m): if lis[i][j] % 2 == 1: cnt += 1 print(cnt)
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s014256015
Runtime Error
p03419
Input is given from Standard Input in the following format: N M
n,m = map(int,input().split()) elif(n==1)or(m==1): if(n==1)and(m==1): print(1) else: print(max(0,max(n,m)-2)) else: print((n-2)*(m-2))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s323701660
Accepted
p03419
Input is given from Standard Input in the following format: N M
import sys sys.setrecursionlimit(1 << 25) read = sys.stdin.readline ra = range enu = enumerate def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_tuple(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(tuple(map(int, read().split()))) return ret def read_col(H): """ H is number of rows A列、B列が与えられるようなとき ex1)A,B=read_col(H) ex2) A,=read_col(H) #一列の場合 """ ret = [] for _ in range(H): ret.append(list(map(int, read().split()))) return tuple(map(list, zip(*ret))) def read_matrix(H): """ H is number of rows """ ret = [] for _ in range(H): ret.append(list(map(int, read().split()))) return ret # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため MOD = 10**9 + 7 INF = 2**31 # 2147483648 > 10**9 # default import from collections import defaultdict, Counter, deque from operator import itemgetter from itertools import product, permutations, combinations from bisect import bisect_left, bisect_right # , insort_left, insort_right # https://atcoder.jp/contests/arc091/tasks/arc091_a # 角に存在するのは4回→表になる # 端にあるのは6回→表になる # 内側に存在するカードは9回フリップする→全部裏になる # よって答えは基本的にN-2 * M-2 ただし(N,M>=2) # コーナーケース N and M ==1のとき→1 # N == 1のとき M-2が答え N, M = read_ints() N, M = (N, M) if N < M else (M, N) if N == 1 and M == 1: print(1) exit() if N == 1: print(M - 2) exit() print((N - 2) * (M - 2))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s462813231
Runtime Error
p03419
Input is given from Standard Input in the following format: N M
def initBoard(rowSize, colSize): board = list() for i in range(rowSize): col = [1] * colSize board.append(col) return board def canFlip(i, j): return i >= 0 and i < rowSize and j >= 0 and j < colSize def flip(board, i, j): if board[i][j] == 0: board[i][j] = 1 elif board[i][j] == 1: board[i][j] = 0 def process(board, i, j): if canFlip(i, j): flip(board, i, j) if canFlip(i - 1, j + 1): flip(board, i - 1, j + 1) if canFlip(i, j + 1): flip(board, i, j + 1) if canFlip(i + 1, j + 1): flip(board, i + 1, j + 1) if canFlip(i - 1, j): flip(board, i - 1, j) if canFlip(i + 1, j): flip(board, i + 1, j) if canFlip(i - 1, j - 1): flip(board, i - 1, j - 1) if canFlip(i, j - 1): flip(board, i, j - 1) if canFlip(i + 1, j - 1): flip(board, i + 1, j - 1) def countBack(board): count = 0 for i in range(len(board)): for j in range(len(board[0])): if board[i][j] == 0: count += 1 return count N, M = map(int, input().split(" ")) rowSize = N colSize = M board = initBoard(rowSize, colSize) for i in range(N): for j in range(M): process(board, i, j) print(countBack(board))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s010142207
Wrong Answer
p03419
Input is given from Standard Input in the following format: N M
a = str(input()).split() n = int(a[0]) m = int(a[1]) k = [] l = [] answer = 0 for i in range(0, m + 2): l.append(1) for i in range(0, n + 2): k.append(l) for i in range(1, n + 1): for j in range(1, m + 1): k[i - 1][j - 1] = -k[i - 1][j - 1] k[i - 1][j] = -k[i - 1][j] k[i - 1][j + 1] = -k[i - 1][j + 1] k[i][j - 1] = -k[i][j - 1] k[i][j] = -k[i][j] k[i][j + 1] = -k[i][j + 1] k[i + 1][j - 1] = -k[i + 1][j - 1] k[i + 1][j] = -k[i + 1][j] k[i + 1][j + 1] = -k[i + 1][j + 1] for i in range(1, n + 1): for j in range(1, m + 1): if k[i][j] < 0: answer += 1 print(answer)
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s986071232
Accepted
p03419
Input is given from Standard Input in the following format: N M
N, M = list(map(int, input().split(" "))) print(abs((N * M - 2 * (N + M) + 4)))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s917431085
Wrong Answer
p03419
Input is given from Standard Input in the following format: N M
n, m = input().split() print((int(n) - 2) * (int(m) - 2))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s434926955
Wrong Answer
p03419
Input is given from Standard Input in the following format: N M
# 書けばわかる 裏になるのは奇数回訪れる場所 n, w = map(int, input().split()) print(n * w - (2 * n + 2 * w - 4))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s287692980
Runtime Error
p03419
Input is given from Standard Input in the following format: N M
import math from operator import itemgetter import re import sys from itertools import accumulate from collections import defaultdict from collections import deque from bisect import bisect_left,bisect from heapq import heappop,heappush from fractions import gcd from copy import deepcopy input = sys.stdin.readline N,M = map(int,input().split()) if N > 1 and M > 1: print((N-2)*(M-2)) elif N==1 and M == 1: print(1) else: print(N+M-3))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s869534965
Runtime Error
p03419
Input is given from Standard Input in the following format: N M
H,W =[int(i) for i in input().split()] if H*W=1: print(1) elif H==1 and W!=1: print(max(0, W-2)) elif W==1 and H!=1: print(max(0, H-2)) else: print(max(H-2, 0)*max(W-2, 0))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s055289900
Runtime Error
p03419
Input is given from Standard Input in the following format: N M
N,M = map(int, input().split()) if M==1 and N==1: print(1) elif M==1: print(N-2) elif N==1: print(M-2) else: print((N-2)*(M-2))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the number of cards that face down after all the operations. * * *
s212602174
Runtime Error
p03419
Input is given from Standard Input in the following format: N M
H, W =[int(i) for i in input().split()] if H*W=1: print(1) elif H==1 and W!=1: print(max(0, W-2)) elif W==1 and H!=1: print(max(0, H-2)) else: print(max(H-2, 0)*max(W-2, 0))
Statement There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
[{"input": "2 2", "output": "0\n \n\nWe will flip every card in any of the four operations. Thus, after all the\noperations, all cards face up.\n\n* * *"}, {"input": "1 7", "output": "5\n \n\nAfter all the operations, all cards except at both ends face down.\n\n* * *"}, {"input": "314 1592", "output": "496080"}]
Print the answer. * * *
s120883347
Runtime Error
p03049
Input is given from Standard Input in the following format: N s_1 \vdots s_N
import math n = int(input()) s = [input() for i in range(n)] ans = 0 b_pre = [] a_suf = [] ab = [] for st in s: if st.startswith("B") and st.endswith("A"): ans += st.count("AB") ab.append(st) elif st.startswith("B"): ans += st.count("AB") b_pre.append(st) elif st.endswith("A"): ans += st.count("AB") a_suf.append(st) else: ans += st.count("AB") if len(b_pre) - len(a_suf) > 1: while len(b_pre) - len(a_suf) > 1: for b in b_pre: if b.endswith("A"): a_suf.append(b) b_pre.remove(b) if len(b_pre) - len(a_suf) <= 1: break elif len(a_suf) - len(b_pre) > 1: while len(a_suf) - len(b_pre) > 1: for a in a_suf: if b.startswith("B"): b_pre.append(b) a_suf.remove(b) if len(a_suf) - len(b_pre) > 1: break ans += math.ceil(len(ab) / 2) if len(b_pre) < len(a_suf): ans += len(b_pre) ans += len(a_suf) - len(b_pre) else: ans += len(a_suf) ans += len(b_pre) - len(a_suf) print(ans)
Statement Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
[{"input": "3\n ABCA\n XBAZ\n BAD", "output": "2\n \n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the\nresulting string `ABCABADXBAZ` has two occurrences of `AB`.\n\n* * *"}, {"input": "9\n BEWPVCRWH\n ZZNQYIJX\n BAVREA\n PA\n HJMYITEOX\n BCJHMRMNK\n BP\n QVFABZ\n PRGKSPUNA", "output": "4\n \n\n* * *"}, {"input": "7\n RABYBBE\n JOZ\n BMHQUVA\n BPA\n ISU\n MCMABAOBHZ\n SZMEHMA", "output": "4"}]
Print the answer. * * *
s597800705
Accepted
p03049
Input is given from Standard Input in the following format: N s_1 \vdots s_N
# C問題 N = int(input()) B = 0 A = 0 BA = 0 count = 0 for i in range(N): s = str(input()) slist = list(s) slen = len(slist) flag = 0 abflag = 0 j = 0 for j in range(slen): if j == 0: if slist[0] == "B": flag = 1 elif slist[0] == "A": abflag = 1 else: pass elif j == slen - 1: if slist[-1] == "A": if flag == 1: flag = 3 else: flag = 2 elif slist[-1] == "B": if abflag == 1: count += 1 else: pass else: if slist[j] == "A": abflag = 1 elif slist[j] == "B": if abflag == 1: count += 1 abflag = 0 else: abflag = 0 else: abflag = 0 if flag == 1: B += 1 elif flag == 2: A += 1 elif flag == 3: BA += 1 if BA >= 1: count += BA - 1 if B >= 1 and BA >= 1: count += 1 if A >= 1: count += 1 count += min((A - 1), (B - 1)) elif A >= 1 and BA >= 1: count += 1 elif A >= 1 and B >= 1: count += min(A, B) print(count)
Statement Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
[{"input": "3\n ABCA\n XBAZ\n BAD", "output": "2\n \n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the\nresulting string `ABCABADXBAZ` has two occurrences of `AB`.\n\n* * *"}, {"input": "9\n BEWPVCRWH\n ZZNQYIJX\n BAVREA\n PA\n HJMYITEOX\n BCJHMRMNK\n BP\n QVFABZ\n PRGKSPUNA", "output": "4\n \n\n* * *"}, {"input": "7\n RABYBBE\n JOZ\n BMHQUVA\n BPA\n ISU\n MCMABAOBHZ\n SZMEHMA", "output": "4"}]
Print the answer. * * *
s802150115
Wrong Answer
p03049
Input is given from Standard Input in the following format: N s_1 \vdots s_N
N = int(input()) A = [] for i in range(N): A.append(input()) X = 0 W = 0 for i in A: i = "".join(i) Q = i.count("AB") if Q == 1: W += 1 # B="".join(A) # print(B) # Y=B.count("AB") # print(Y) Z1 = 0 Z3 = 0 z = 0 for i in A: # print(i[-1]) i = "".join(i) C = A.index(i) if C != 0: z += 1 C = C - z D = A[C] # print(D)#取り出したやつ A.pop(C) # print(A) # print(C) # print(A) Z1 = 0 if i[-1] == "A": for j in A: if j[0] == "B": Z1 += 1 # print(Z1) A.append(D) # print(A) # print(A) if Z3 < Z1: Z3 = Z1 W += Z3 print(W)
Statement Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
[{"input": "3\n ABCA\n XBAZ\n BAD", "output": "2\n \n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the\nresulting string `ABCABADXBAZ` has two occurrences of `AB`.\n\n* * *"}, {"input": "9\n BEWPVCRWH\n ZZNQYIJX\n BAVREA\n PA\n HJMYITEOX\n BCJHMRMNK\n BP\n QVFABZ\n PRGKSPUNA", "output": "4\n \n\n* * *"}, {"input": "7\n RABYBBE\n JOZ\n BMHQUVA\n BPA\n ISU\n MCMABAOBHZ\n SZMEHMA", "output": "4"}]
Print the answer. * * *
s499536963
Wrong Answer
p03049
Input is given from Standard Input in the following format: N s_1 \vdots s_N
N = int(input()) word = [] num = [] a = [] count = 0 type_A = 0 type_B = 0 type_C = 0 for i in range(N): word.append(input()) for i in range(len(word)): text = word[i] AB = word[i].count("AB") count += AB if text[0] == "B" and text[-1] == "A": type_C += 1 elif text[-1] == "A": type_A += 1 elif text[0] == "B": type_B += 1 num.append(type_A) num.append(type_B) num.append(type_C) a = sorted(num) if a[0] == type_C: print(a[0] * 2 + a[1] - a[0] + count) else: k = type_C - a[0] m = max(type_A - a[0], type_B - a[0]) if k > m and m != 0: print(a[0] * 2 + k + count) elif k > m and m == 0: print(a[0] * 2 + k - 1 + count) elif k < m or k == m: print(a[0] * 2 + k + count)
Statement Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
[{"input": "3\n ABCA\n XBAZ\n BAD", "output": "2\n \n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the\nresulting string `ABCABADXBAZ` has two occurrences of `AB`.\n\n* * *"}, {"input": "9\n BEWPVCRWH\n ZZNQYIJX\n BAVREA\n PA\n HJMYITEOX\n BCJHMRMNK\n BP\n QVFABZ\n PRGKSPUNA", "output": "4\n \n\n* * *"}, {"input": "7\n RABYBBE\n JOZ\n BMHQUVA\n BPA\n ISU\n MCMABAOBHZ\n SZMEHMA", "output": "4"}]
Print the answer. * * *
s271843508
Wrong Answer
p03049
Input is given from Standard Input in the following format: N s_1 \vdots s_N
N = int(input()) count = 0 LastA = 0 FirstB = 0 LA = 0 for i in range(0, N): f = input() count = count + f.count("AB") if f[0] == "B" and f[-1] == "A": LA = LA + 1 elif f[0] == "B": FirstB = FirstB + 1 elif f[-1] == "A": LastA = LastA + 1 count = count + LA if LastA == 0 and FirstB == 0: count = count - 1 elif FirstB >= LastA: count = count + LastA else: count = count + FirstB print(count)
Statement Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
[{"input": "3\n ABCA\n XBAZ\n BAD", "output": "2\n \n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the\nresulting string `ABCABADXBAZ` has two occurrences of `AB`.\n\n* * *"}, {"input": "9\n BEWPVCRWH\n ZZNQYIJX\n BAVREA\n PA\n HJMYITEOX\n BCJHMRMNK\n BP\n QVFABZ\n PRGKSPUNA", "output": "4\n \n\n* * *"}, {"input": "7\n RABYBBE\n JOZ\n BMHQUVA\n BPA\n ISU\n MCMABAOBHZ\n SZMEHMA", "output": "4"}]
Print the answer. * * *
s259935988
Accepted
p03049
Input is given from Standard Input in the following format: N s_1 \vdots s_N
import re pattern = "AB" num_input = int(input()) total_ab = 0 num_ab = 0 num_end_with_a = 0 num_start_with_b = 0 num_both = 0 prints = [] for i in range(0, num_input): input_string = input() num_ab += len(re.findall(pattern, input_string)) start_with_b = input_string[0] == "B" end_with_a = input_string[-1] == "A" if start_with_b and end_with_a: num_both += 1 elif start_with_b: num_start_with_b += 1 elif end_with_a: num_end_with_a += 1 # print(num_ab, num_both, num_start_with_b, num_end_with_a) # add in-string 'AB' total_ab += num_ab # consume both first # do setup, for case of '--A's or 'B--'s not exist if num_end_with_a == 0 and num_start_with_b == 0: if num_both >= 2: num_both -= 2 num_end_with_a += 1 num_start_with_b += 1 elif min(num_end_with_a, num_start_with_b) == 0: if num_both >= 1: if num_end_with_a == 0: num_both -= 1 num_end_with_a += 1 if num_start_with_b == 0: num_both -= 1 num_start_with_b += 1 # then consume if num_both > 0: total_ab += num_both + 1 num_end_with_a -= 1 num_start_with_b -= 1 # then consume other '--A's and 'B--'s total_ab += min(num_start_with_b, num_end_with_a) print(total_ab) exit(0)
Statement Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
[{"input": "3\n ABCA\n XBAZ\n BAD", "output": "2\n \n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the\nresulting string `ABCABADXBAZ` has two occurrences of `AB`.\n\n* * *"}, {"input": "9\n BEWPVCRWH\n ZZNQYIJX\n BAVREA\n PA\n HJMYITEOX\n BCJHMRMNK\n BP\n QVFABZ\n PRGKSPUNA", "output": "4\n \n\n* * *"}, {"input": "7\n RABYBBE\n JOZ\n BMHQUVA\n BPA\n ISU\n MCMABAOBHZ\n SZMEHMA", "output": "4"}]
Print the answer. * * *
s030735937
Accepted
p03049
Input is given from Standard Input in the following format: N s_1 \vdots s_N
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def diverta19_c(): _ = int(readline()) S = [ln.strip().decode("UTF-8") for ln in read().split()] # _AB_ , B_A , B_ , _A の個数をそれぞれ数える inner, st, ed, sted = 0, 0, 0, 0 for si in S: inner += si.count("AB") if si[0] == "B" and si[-1] == "A": sted += 1 elif si[0] == "B": st += 1 elif si[-1] == "A": ed += 1 ans = inner # これは確定 if sted > 0: ans += sted - 1 # x個でx-1組のABができる if st > 0: ans += 1 # B_A + B_ で1組 st -= 1 if ed > 0: ans += 1 # _A + B_A で1組 ed -= 1 ans += min(st, ed) # _A + B_ で1組 print(ans) diverta19_c()
Statement Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
[{"input": "3\n ABCA\n XBAZ\n BAD", "output": "2\n \n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the\nresulting string `ABCABADXBAZ` has two occurrences of `AB`.\n\n* * *"}, {"input": "9\n BEWPVCRWH\n ZZNQYIJX\n BAVREA\n PA\n HJMYITEOX\n BCJHMRMNK\n BP\n QVFABZ\n PRGKSPUNA", "output": "4\n \n\n* * *"}, {"input": "7\n RABYBBE\n JOZ\n BMHQUVA\n BPA\n ISU\n MCMABAOBHZ\n SZMEHMA", "output": "4"}]
Print the answer. * * *
s322398386
Wrong Answer
p03049
Input is given from Standard Input in the following format: N s_1 \vdots s_N
n, *s = map(str, open(0).read().split()) b = sum([c.startswith("B") for c in s]) a = sum([c.endswith("A") for c in s]) e = a if b >= a else b if e == int(n): e -= 1 if any([c.startswith("B") and c.endswith("A") for c in s]): e -= 1 print(sum([c.count("AB") for c in s]) + e)
Statement Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
[{"input": "3\n ABCA\n XBAZ\n BAD", "output": "2\n \n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the\nresulting string `ABCABADXBAZ` has two occurrences of `AB`.\n\n* * *"}, {"input": "9\n BEWPVCRWH\n ZZNQYIJX\n BAVREA\n PA\n HJMYITEOX\n BCJHMRMNK\n BP\n QVFABZ\n PRGKSPUNA", "output": "4\n \n\n* * *"}, {"input": "7\n RABYBBE\n JOZ\n BMHQUVA\n BPA\n ISU\n MCMABAOBHZ\n SZMEHMA", "output": "4"}]
Print the answer. * * *
s318045911
Accepted
p03049
Input is given from Standard Input in the following format: N s_1 \vdots s_N
X = [input() for _ in range(int(input()))] a, b, e, s = 0, 0, 0, 0 for x in X: a += x.count("AB") if x.endswith("A") and x.startswith("B"): b += 1 elif x.endswith("A"): e += 1 elif x.startswith("B"): s += 1 if b > 0: a += b - 1 if e > 0: e -= 1 a += 1 if s > 0: s -= 1 a += 1 a += min(e, s) print(a)
Statement Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
[{"input": "3\n ABCA\n XBAZ\n BAD", "output": "2\n \n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the\nresulting string `ABCABADXBAZ` has two occurrences of `AB`.\n\n* * *"}, {"input": "9\n BEWPVCRWH\n ZZNQYIJX\n BAVREA\n PA\n HJMYITEOX\n BCJHMRMNK\n BP\n QVFABZ\n PRGKSPUNA", "output": "4\n \n\n* * *"}, {"input": "7\n RABYBBE\n JOZ\n BMHQUVA\n BPA\n ISU\n MCMABAOBHZ\n SZMEHMA", "output": "4"}]
Print the value A_1 \times ... \times A_N as an integer, or `-1` if the value exceeds 10^{18}. * * *
s140361098
Wrong Answer
p02658
Input is given from Standard Input in the following format: N A_1 ... A_N
N = input() Ai = input().split() Ai = [int(Ai[k]) for k in range(int(N))] K = Ai[0] for i in range(1, int(N)): K = K * Ai[i] if K > 1000000000000000000: K = -1 break print(K)
Statement Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N. However, if the result exceeds 10^{18}, print `-1` instead.
[{"input": "2\n 1000000000 1000000000", "output": "1000000000000000000\n \n\nWe have 1000000000 \\times 1000000000 = 1000000000000000000.\n\n* * *"}, {"input": "3\n 101 9901 999999000001", "output": "-1\n \n\nWe have 101 \\times 9901 \\times 999999000001 = 1000000000000000001, which\nexceeds 10^{18}, so we should print `-1` instead.\n\n* * *"}, {"input": "31\n 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0", "output": "0"}]
Print the value A_1 \times ... \times A_N as an integer, or `-1` if the value exceeds 10^{18}. * * *
s021155227
Runtime Error
p02658
Input is given from Standard Input in the following format: N A_1 ... A_N
A, B = input().split() A = int(A) fb = float(B) B100 = int(fb * 100) ans = A * B100 print(int(ans / 100))
Statement Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N. However, if the result exceeds 10^{18}, print `-1` instead.
[{"input": "2\n 1000000000 1000000000", "output": "1000000000000000000\n \n\nWe have 1000000000 \\times 1000000000 = 1000000000000000000.\n\n* * *"}, {"input": "3\n 101 9901 999999000001", "output": "-1\n \n\nWe have 101 \\times 9901 \\times 999999000001 = 1000000000000000001, which\nexceeds 10^{18}, so we should print `-1` instead.\n\n* * *"}, {"input": "31\n 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0", "output": "0"}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s586201652
Wrong Answer
p02930
Input is given from Standard Input in the following format: N
print((int(input()) + 1) // 2)
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s505331676
Wrong Answer
p02930
Input is given from Standard Input in the following format: N
n = int(input()) print(2)
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s693212739
Accepted
p02930
Input is given from Standard Input in the following format: N
N = int(input()) ans = [[0 for _ in range(N + 1)] for _ in range(N + 1)] L = 1 def f(i, j): global L if i == j: return mid = (i + j) // 2 for k in range(i, mid + 1): for r in range(mid + 1, j + 1): ans[k][r] = L ans[r][k] = L L += 1 f(i, mid) f(mid + 1, j) L -= 1 f(1, N) for i in range(1, N): print(" ".join(str(ans[i][j]) for j in range(i + 1, N + 1)))
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s023873255
Wrong Answer
p02930
Input is given from Standard Input in the following format: N
n = int(input()) if n == 3: print(1, 2) print(1) else: pass
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s257571682
Wrong Answer
p02930
Input is given from Standard Input in the following format: N
n = int(input()) l = [ 1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, 11, 10, 9, ] for i in range(n): print(*l[: n - i - 1])
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s231357802
Accepted
p02930
Input is given from Standard Input in the following format: N
N, j = int(input()), 0 exec("print(*[9-format(i+1,'09b').rfind('1')for i in range(N)][:N-j-1]);j+=1;" * N)
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s244404467
Accepted
p02930
Input is given from Standard Input in the following format: N
N = int(input()) ANS = [[0] * N for i in range(N)] def line(L, i): if len(L) <= 1: return for k in range(len(L)): for l in range(k + 1, len(L)): if k % 2 != l % 2: ANS[L[k]][L[l]] = i M = [L[i] for i in range(0, len(L), 2)] N = [L[i] for i in range(1, len(L), 2)] line(M, i + 1) line(N, i + 1) line(list(range(N)), 1) for i in range(N - 1): print(*ANS[i][i + 1 :])
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s863102780
Accepted
p02930
Input is given from Standard Input in the following format: N
def main(): n = int(input()) g = [{i for i in range(j + 1, n)} for j in range(n)] matrix = [[0] * (n - i - 1) for i in range(n - 1)] def dfs(i, now): for j in g[i]: if visit[j] == False: visit[j] = True if now % 2 == 0: white.add(j) else: black.add(j) dfs(j, now + 1) break cnt = 0 cnt2 = 0 while cnt < (n * (n - 1)) // 2: cnt2 += 1 visit = [False] * n black = set() white = set() for i in range(n): if visit[i] == False: visit[i] = True black.add(i) dfs(i, 0) for i in black: for j in white: ii, jj = min(i, j), max(i, j) if jj in g[ii]: cnt += 1 g[ii].remove(jj) matrix[ii][jj - ii - 1] = cnt2 for i in matrix: print(*i) main()
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s668724099
Wrong Answer
p02930
Input is given from Standard Input in the following format: N
n = int(input()) even = [[1]] odd = [[2, 2], [1]] if n % 2 == 0: for i in range(n // 2 - 1): last = even even = [] for x in last: even.append(x + [i + 2, i + 2]) even.append([i + 2, i + 2]) even.append([1]) for x in even: print(" ".join(list(map(str, x)))) else: for i in range(n // 2 - 1): last = odd odd = [] for x in last: odd.append(x + [i + 3, i + 3]) odd.append([i + 3, i + 3]) odd.append([1]) for x in odd: print(" ".join(list(map(str, x))))
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s453729704
Wrong Answer
p02930
Input is given from Standard Input in the following format: N
n = int(input()) if n == 2: print(1) exit() if n == 3: print(1, 1) print(2) exit() a = [[0] * n for _ in range(n)] for i in range(n): a[i] = [i * 2 + 1] * n for i in range(n): for j in range(i + 1, n): a[j][i] = (i + 1) * 2 for i in range(n): if n // 2 == i: print(*a[i][: -i - 1], end=" ") if n % 2 == 0: print(a[i - 1][-i - 1]) else: print(a[i][-i - 2]) elif i != 0: print(*a[i][:-i]) else: print(*a[i])
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s857475628
Accepted
p02930
Input is given from Standard Input in the following format: N
r = range n = int(input()) for i in r(n): for j in r(i + 1, n): d = i ^ j & -(i ^ j) print(d.bit_length())
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s271092866
Wrong Answer
p02930
Input is given from Standard Input in the following format: N
r = range(int(input())) for _ in r: print(*[bin(j + 1)[::-1].find("1") + 1 for j in r])
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Print one way to set levels to the passages so that the objective is achieved, as follows: a_{1,2} a_{1,3} ... a_{1,N} a_{2,3} ... a_{2,N} . . . a_{N-1,N} Here a_{i,j} is the level of the passage connecting Room i and Room j. If there are multiple solutions, any of them will be accepted. * * *
s447758986
Wrong Answer
p02930
Input is given from Standard Input in the following format: N
N = int(input()) ans = [] for i in range(N - 1): ans.append([0] * (N - i - 1)) flag = 0 for step in range(1, N // 2 + 1): i = 0 i_start = 0 counter = 0 visited = [0] * N while True: if visited[i] == 1: break if i + step <= N - 1: ans[i][step - 1] = step i_new = i + step else: i_new = (i + step) % N ans[i_new][i - i_new - 1] = step counter += 1 if i_new == i_start: if counter % 2 == 1: ans[i_new][i - i_new - 1] = 0 if step == N // 2: flag = 1 i_start += 1 i = i_start counter = 0 else: visited[i] = 1 i = i_new for i in range(N - 1): for j in range(N - i - 1): if ans[i][j] == 0: ans[i][j] = N // 2 if flag == 0 else N // 2 + 1 for i in range(N - 1): ans_i = ans[i] print(*ans_i)
Statement AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a **level** for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even. Your task is to set levels to the passages so that the highest level of a passage is minimized.
[{"input": "3", "output": "1 2\n 1\n \n\nThe following image describes this output:\n\n![](https://img.atcoder.jp/jsc2019-qual/D-sample.png)\n\nFor example, if we leave Room 2, traverse the path 2 \\to 3 \\to 2 \\to 3 \\to 2\n\\to 1 \\to 2 while only passing passages of level 1 and get back to Room 2, we\npass through a passage six times."}]
Let P/Q be the expected number of correct answers you give if you follow an optimal strategy, represented as an irreducible fraction. Print P \times Q^{-1} modulo 998244353. * * *
s751177082
Accepted
p03622
Input is given from Standard Input in the following format: N M
M = 8**7 m, f, g, i = M * 476 + 1, [j := 1], [k := 1] * M, 0 while i < M: i += 1 f += (f[-1] * i % m,) g += (pow(f[-1], m - 2, m),) while i: g[i - 1] = g[i] * i % m i -= 1 A, B = map(int, input().split()) if A < B: A, B = B, A while j <= B: i += k * f[A + B - j] * g[B - j] k = k * 2 % m j += 1 print((i * f[B] * g[A + B] + A) % m)
Statement You are participating in a quiz with N + M questions and Yes/No answers. It's known in advance that there are N questions with answer Yes and M questions with answer No, but the questions are given to you in random order. You have no idea about correct answers to any of the questions. You answer questions one by one, and for each question you answer, you get to know the correct answer immediately after answering. Suppose you follow a strategy maximizing the expected number of correct answers you give. Let this expected number be P/Q, an irreducible fraction. Let M = 998244353. It can be proven that a unique integer R between 0 and M - 1 exists such that P = Q \times R modulo M, and it is equal to P \times Q^{-1} modulo M, where Q^{-1} is the modular inverse of Q. Find R.
[{"input": "1 1", "output": "499122178\n \n\nThere are two questions. You may answer randomly to the first question, and\nyou'll succeed with 50% probability. Then, since you know the second answer is\ndifferent from the first one, you'll succeed with 100% probability.\n\nThe expected number of your correct answers is 3 / 2. Thus, P = 3, Q = 2,\nQ^{-1} = 499122177 (modulo 998244353), and P \\times Q^{-1} = 499122178 (again,\nmodulo 998244353).\n\n* * *"}, {"input": "2 2", "output": "831870297\n \n\nThe expected number of your correct answers is 17 / 6.\n\n* * *"}, {"input": "3 4", "output": "770074220\n \n\nThe expected number of your correct answers is 169 / 35.\n\n* * *"}, {"input": "10 10", "output": "208827570\n \n\n* * *"}, {"input": "42 23", "output": "362936761"}]
Let P/Q be the expected number of correct answers you give if you follow an optimal strategy, represented as an irreducible fraction. Print P \times Q^{-1} modulo 998244353. * * *
s371677826
Runtime Error
p03622
Input is given from Standard Input in the following format: N M
import sys from fractions import Fraction import json sys.setrecursionlimit(10000) memo = {} def e(m, n): if m < n: m, n = n, m if (m, n) in memo: return memo[(m, n)] if m == 0: return n if n == 0: return m if m == n: memo[(m, n)] = e(m - 1, n) + Fraction(1, 2) else: memo[(m, n)] = (e(m - 1, n) + 1) * Fraction(m, m + n) + e(m, n - 1) * Fraction( n, m + n ) return memo[(m, n)] def main(): n, m = list(map(int, input().split())) mod = 998244353 res = e(n, m) p = res.numerator q = res.denominator print((p * pow(q, mod - 2, mod)) % mod) if __name__ == "__main__": main()
Statement You are participating in a quiz with N + M questions and Yes/No answers. It's known in advance that there are N questions with answer Yes and M questions with answer No, but the questions are given to you in random order. You have no idea about correct answers to any of the questions. You answer questions one by one, and for each question you answer, you get to know the correct answer immediately after answering. Suppose you follow a strategy maximizing the expected number of correct answers you give. Let this expected number be P/Q, an irreducible fraction. Let M = 998244353. It can be proven that a unique integer R between 0 and M - 1 exists such that P = Q \times R modulo M, and it is equal to P \times Q^{-1} modulo M, where Q^{-1} is the modular inverse of Q. Find R.
[{"input": "1 1", "output": "499122178\n \n\nThere are two questions. You may answer randomly to the first question, and\nyou'll succeed with 50% probability. Then, since you know the second answer is\ndifferent from the first one, you'll succeed with 100% probability.\n\nThe expected number of your correct answers is 3 / 2. Thus, P = 3, Q = 2,\nQ^{-1} = 499122177 (modulo 998244353), and P \\times Q^{-1} = 499122178 (again,\nmodulo 998244353).\n\n* * *"}, {"input": "2 2", "output": "831870297\n \n\nThe expected number of your correct answers is 17 / 6.\n\n* * *"}, {"input": "3 4", "output": "770074220\n \n\nThe expected number of your correct answers is 169 / 35.\n\n* * *"}, {"input": "10 10", "output": "208827570\n \n\n* * *"}, {"input": "42 23", "output": "362936761"}]
Let P/Q be the expected number of correct answers you give if you follow an optimal strategy, represented as an irreducible fraction. Print P \times Q^{-1} modulo 998244353. * * *
s955761820
Runtime Error
p03622
Input is given from Standard Input in the following format: N M
M=8**7 m,f,g,i=M*476+1,[j:=1],[k:=1]*M,0 while i<M:i+=1;f+=f[-1]*i%m, g+=pow(f[-1],m-2,m), while i:g[i-1]=g[i]*i%m;i-=1 A,B=map(int,input().split()) if A<B:A,B=B,A while j<=B:i+=k*f[A+B-j]*g[B-j];k=k*2%m;j+=1 print((i*f[B]*g[A+B]+A)%m))
Statement You are participating in a quiz with N + M questions and Yes/No answers. It's known in advance that there are N questions with answer Yes and M questions with answer No, but the questions are given to you in random order. You have no idea about correct answers to any of the questions. You answer questions one by one, and for each question you answer, you get to know the correct answer immediately after answering. Suppose you follow a strategy maximizing the expected number of correct answers you give. Let this expected number be P/Q, an irreducible fraction. Let M = 998244353. It can be proven that a unique integer R between 0 and M - 1 exists such that P = Q \times R modulo M, and it is equal to P \times Q^{-1} modulo M, where Q^{-1} is the modular inverse of Q. Find R.
[{"input": "1 1", "output": "499122178\n \n\nThere are two questions. You may answer randomly to the first question, and\nyou'll succeed with 50% probability. Then, since you know the second answer is\ndifferent from the first one, you'll succeed with 100% probability.\n\nThe expected number of your correct answers is 3 / 2. Thus, P = 3, Q = 2,\nQ^{-1} = 499122177 (modulo 998244353), and P \\times Q^{-1} = 499122178 (again,\nmodulo 998244353).\n\n* * *"}, {"input": "2 2", "output": "831870297\n \n\nThe expected number of your correct answers is 17 / 6.\n\n* * *"}, {"input": "3 4", "output": "770074220\n \n\nThe expected number of your correct answers is 169 / 35.\n\n* * *"}, {"input": "10 10", "output": "208827570\n \n\n* * *"}, {"input": "42 23", "output": "362936761"}]
Print a string that represents the state of each device after K balls are processed. The string must be N characters long, and the i-th character must correspond to the state of the i-th device from the left. * * *
s603667293
Accepted
p03788
The input is given from Standard Input in the following format: N K S
n, k = map(int, input().split()) s = list(input()) * 3 p = ["A" if s[i] == "B" else "B" for i in range(n)] * 3 head, tail = 0, n if k > 2 * n: k = 2 * n + k % 2 for i in range(k): if s[head] == "A": s[head], p[head] = "B", "A" else: s, p = p, s head += 1 s[tail], p[tail] = "A", "B" tail += 1 print("".join(s[head:tail]))
Statement Takahashi has a lot of peculiar devices. These cylindrical devices receive balls from left and right. Each device is in one of the two states A and B, and for each state, the device operates as follows: * When a device in state A receives a ball from either side (left or right), the device throws out the ball from the same side, then immediately goes into state B. * When a device in state B receives a ball from either side, the device throws out the ball from the other side, then immediately goes into state A. The transition of the state of a device happens momentarily and always completes before it receives another ball. Takahashi built a contraption by concatenating N of these devices. In this contraption, * A ball that was thrown out from the right side of the i-th device from the left (1 \leq i \leq N-1) immediately enters the (i+1)-th device from the left side. * A ball that was thrown out from the left side of the i-th device from the left (2 \leq i \leq N) immediately enters the (i-1)-th device from the right side. The initial state of the i-th device from the left is represented by the i-th character in a string S. From this situation, Takahashi performed the following K times: put a ball into the leftmost device from the left side, then wait until the ball comes out of the contraption from either end. Here, it can be proved that the ball always comes out of the contraption after a finite time. Find the state of each device after K balls are processed.
[{"input": "5 1\n ABAAA", "output": "BBAAA\n \n\nIn this input, we put a ball into the leftmost device from the left side, then\nit is returned from the same place.\n\n* * *"}, {"input": "5 2\n ABAAA", "output": "ABBBA\n \n\n* * *"}, {"input": "4 123456789\n AABB", "output": "BABA"}]
Print a string that represents the state of each device after K balls are processed. The string must be N characters long, and the i-th character must correspond to the state of the i-th device from the left. * * *
s748080528
Wrong Answer
p03788
The input is given from Standard Input in the following format: N K S
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10**7) from collections import deque # f(AX) = XB # f(BX) = flip(X) + A = flip(XB) N, K = map(int, readline().split()) S = read().rstrip() S = deque(0 if x == b"A"[0] else 1 for x in S) # Kが大きいときは、周期で減らせる if K > 20100 + 100: K = 20100 + (K & 1) flip = 0 for _ in range(K): top = S[0] ^ flip if top == 0: # A S[0] ^= 1 else: # B flip ^= 1 S.popleft() S.append(flip) if flip == 0: A = "A" B = "B" else: A = "B" B = "A" answer = "".join(A if x == 0 else B for x in S) print(answer)
Statement Takahashi has a lot of peculiar devices. These cylindrical devices receive balls from left and right. Each device is in one of the two states A and B, and for each state, the device operates as follows: * When a device in state A receives a ball from either side (left or right), the device throws out the ball from the same side, then immediately goes into state B. * When a device in state B receives a ball from either side, the device throws out the ball from the other side, then immediately goes into state A. The transition of the state of a device happens momentarily and always completes before it receives another ball. Takahashi built a contraption by concatenating N of these devices. In this contraption, * A ball that was thrown out from the right side of the i-th device from the left (1 \leq i \leq N-1) immediately enters the (i+1)-th device from the left side. * A ball that was thrown out from the left side of the i-th device from the left (2 \leq i \leq N) immediately enters the (i-1)-th device from the right side. The initial state of the i-th device from the left is represented by the i-th character in a string S. From this situation, Takahashi performed the following K times: put a ball into the leftmost device from the left side, then wait until the ball comes out of the contraption from either end. Here, it can be proved that the ball always comes out of the contraption after a finite time. Find the state of each device after K balls are processed.
[{"input": "5 1\n ABAAA", "output": "BBAAA\n \n\nIn this input, we put a ball into the leftmost device from the left side, then\nit is returned from the same place.\n\n* * *"}, {"input": "5 2\n ABAAA", "output": "ABBBA\n \n\n* * *"}, {"input": "4 123456789\n AABB", "output": "BABA"}]
Print a string that represents the state of each device after K balls are processed. The string must be N characters long, and the i-th character must correspond to the state of the i-th device from the left. * * *
s574646261
Wrong Answer
p03788
The input is given from Standard Input in the following format: N K S
import numpy as np Inp = list(map(int, input().split())) N = Inp[0] K = Inp[1] s = input() a = [] for i in range(0, len(s)): if s[i] == "A": a.append(1) else: a.append(-1) r_arr = np.array(a) if K < 2 * N: for i in range(0, K): if r_arr[0] == 1: r_arr[0] = -1 continue r_arr = np.delete(r_arr, 0) r_arr *= -1 r_arr = np.append(r_arr, 1) else: if len(r_arr) % 2 == 0: for i in range(0, N): if i % 2 == 0: r_arr[i] = -1 else: r_arr[i] = 1 else: r_arr[0] = -1 for i in range(1, N): if i % 2 == 1: r_arr[i] = -1 else: r_arr[i] = 1 if (K - 2 * N) % 2 == 1: r_arr[0] *= -1 res = "" for i in range(0, len(r_arr)): if r_arr[i] == 1: res += "A" else: res += "B" print(res)
Statement Takahashi has a lot of peculiar devices. These cylindrical devices receive balls from left and right. Each device is in one of the two states A and B, and for each state, the device operates as follows: * When a device in state A receives a ball from either side (left or right), the device throws out the ball from the same side, then immediately goes into state B. * When a device in state B receives a ball from either side, the device throws out the ball from the other side, then immediately goes into state A. The transition of the state of a device happens momentarily and always completes before it receives another ball. Takahashi built a contraption by concatenating N of these devices. In this contraption, * A ball that was thrown out from the right side of the i-th device from the left (1 \leq i \leq N-1) immediately enters the (i+1)-th device from the left side. * A ball that was thrown out from the left side of the i-th device from the left (2 \leq i \leq N) immediately enters the (i-1)-th device from the right side. The initial state of the i-th device from the left is represented by the i-th character in a string S. From this situation, Takahashi performed the following K times: put a ball into the leftmost device from the left side, then wait until the ball comes out of the contraption from either end. Here, it can be proved that the ball always comes out of the contraption after a finite time. Find the state of each device after K balls are processed.
[{"input": "5 1\n ABAAA", "output": "BBAAA\n \n\nIn this input, we put a ball into the leftmost device from the left side, then\nit is returned from the same place.\n\n* * *"}, {"input": "5 2\n ABAAA", "output": "ABBBA\n \n\n* * *"}, {"input": "4 123456789\n AABB", "output": "BABA"}]
Print the answer. * * *
s082818584
Accepted
p03272
Input is given from Standard Input in the following format: N i
print(eval(input().replace(" ", "+1-")))
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s030807258
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
print(int(input) + 1 - int(input()))
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s200265914
Wrong Answer
p03272
Input is given from Standard Input in the following format: N i
print(1 - eval(input().replace(" ", "-")))
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s745315346
Wrong Answer
p03272
Input is given from Standard Input in the following format: N i
print(eval("-".join(input()) + "+1"))
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s149240920
Accepted
p03272
Input is given from Standard Input in the following format: N i
val1, val2 = input().split(" ") val3 = int(val1) - int(val2) + 1 print(val3)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s812128284
Accepted
p03272
Input is given from Standard Input in the following format: N i
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()} print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] def li_input(): return [int(_) for _ in sys.stdin.readline().split()] def gcd(n, m): if n % m == 0: return m else: return gcd(m, n % m) def gcd_list(L): v = L[0] for i in range(1, len(L)): v = gcd(v, L[i]) return v def lcm(n, m): return (n * m) // gcd(n, m) def lcm_list(L): v = L[0] for i in range(1, len(L)): v = lcm(v, L[i]) return v # Width First Search (+ Distance) def wfs_d(D, N, K): """ D: 隣接行列(距離付き) N: ノード数 K: 始点ノード """ dfk = [-1] * (N + 1) dfk[K] = 0 cps = [(K, 0)] r = [False] * (N + 1) r[K] = True while len(cps) != 0: n_cps = [] for cp, cd in cps: for i, dfcp in enumerate(D[cp]): if dfcp != -1 and not r[i]: dfk[i] = cd + dfcp n_cps.append((i, cd + dfcp)) r[i] = True cps = n_cps[:] return dfk # Depth First Search (+Distance) def dfs_d(v, pre, dist): """ v: 現在のノード pre: 1つ前のノード dist: 現在の距離 以下は別途用意する D: 隣接リスト(行列ではない) D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト """ global D global D_dfs_d D_dfs_d[v] = dist for next_v, d in D[v]: if next_v != pre: dfs_d(next_v, v, dist + d) return def sigma(N): ans = 0 for i in range(1, N + 1): ans += i return ans def comb(n, r): if n - r < r: r = n - r if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2, r + 1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p - 1, r, p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result def bisearch(L, target): low = 0 high = len(L) - 1 while low <= high: mid = (low + high) // 2 guess = L[mid] if guess == target: return True elif guess < target: low = mid + 1 elif guess > target: high = mid - 1 if guess != target: return False # -------------------------------------------- dp = None def main(): N, i = li_input() print(N - i + 1) main()
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s663197098
Accepted
p03272
Input is given from Standard Input in the following format: N i
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math from collections import deque from fractions import gcd from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") ############# # Functions # ############# ######INPUT###### def inputI(): return int(input().strip()) def inputS(): return input().strip() def inputIL(): return list(map(int, input().split())) def inputSL(): return list(map(str, input().split())) def inputILs(n): return list(int(input()) for _ in range(n)) def inputSLs(n): return list(input().strip() for _ in range(n)) def inputILL(n): return [list(map(int, input().split())) for _ in range(n)] def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)] #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####LCM##### def lcm(a, b): return a * b // gcd(a, b) ############# # Main Code # ############# N, i = inputIL() print(N - i + 1)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s514328663
Accepted
p03272
Input is given from Standard Input in the following format: N i
N, i = list(map(int, input().split(" "))) ran = list(range(1, N + 1))[::-1] print(ran[i - 1])
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s720540635
Accepted
p03272
Input is given from Standard Input in the following format: N i
# abc107_a.py # https://atcoder.jp/contests/abc107/tasks/abc107_a # 問題文 # N両編成の列車があります。 この列車の前から i両目は、後ろから何両目でしょうか? # 制約 # 1≤N≤100 # 1≤i≤N # 入力 # 入力は以下の形式で標準入力から与えられる。 # N i # 出力 # 答えを出力せよ。 # 入力例 1 # 4 2 # 出力例 1 # 3 # 4両編成の列車において、前から 2 両目の車両は、後ろから 3両目です。 # 入力例 2 # 1 1 # 出力例 2 # 1 # 入力例 3 # 15 11 # 出力例 3 # 5 def calculation(lines): N, i = list(map(int, lines[0].split())) # K = int(lines[1]) return [N - i + 1] # 引数を取得 def get_input_lines(lines_count): lines = list() for _ in range(lines_count): lines.append(input()) return lines # テストデータ def get_testdata(pattern): if pattern == 1: lines_input = ["4 2"] lines_export = [3] if pattern == 2: lines_input = ["1 1"] lines_export = [1] if pattern == 3: lines_input = ["15 11"] lines_export = [5] return lines_input, lines_export # 動作モード判別 def get_mode(): import sys args = sys.argv if len(args) == 1: mode = 0 else: mode = int(args[1]) return mode # 主処理 def main(): mode = get_mode() if mode == 0: lines_input = get_input_lines(1) else: lines_input, lines_export = get_testdata(mode) lines_result = calculation(lines_input) for line_result in lines_result: print(line_result) # if mode > 0: # print(f'lines_input=[{lines_input}]') # print(f'lines_export=[{lines_export}]') # print(f'lines_result=[{lines_result}]') # if lines_result == lines_export: # print('OK') # else: # print('NG') # 起動処理 if __name__ == "__main__": main()
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s266257590
Wrong Answer
p03272
Input is given from Standard Input in the following format: N i
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random import itertools sys.setrecursionlimit(10**5) stdin = sys.stdin def LI(): return list(map(int, stdin.readline().split())) def LF(): return list(map(float, stdin.readline().split())) def LI_(): return list(map(lambda x: int(x) - 1, stdin.readline().split())) def II(): return int(stdin.readline()) def IF(): return float(stdin.readline()) def LS(): return list(map(list, stdin.readline().split())) def S(): return list(stdin.readline().rstrip()) def IR(n): return [II() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] def FR(n): return [IF() for _ in range(n)] def LFR(n): return [LI() for _ in range(n)] def LIR_(n): return [LI_() for _ in range(n)] def SR(n): return [S() for _ in range(n)] def LSR(n): return [LS() for _ in range(n)] mod = 1000000007 # A def A(): n, i = LI() print(n - i + 1) return # B def B(): x1, y1, x2, y2 = LI() a = x2 - x1 b = y2 - y1 print(x2 - b, y2 + a, x1 - b, y1 + a) return # C def C(): n, k = LI() if k % 2: print((n // k) ** 3) else: print(int((n // k) ** 3 + ((n - k / 2) // k + 1) ** 3)) return # D def D(): return # E def E(): return # F def F(): return # G def G(): return # H def H(): return # Solve if __name__ == "__main__": C()
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s198858605
Accepted
p03272
Input is given from Standard Input in the following format: N i
x, y = input().split(" ") x = int(x) y = int(y) print(x + 1 - y)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s090516954
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
N, i = map(int, input().split()) print(N-(i-1)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s756183979
Accepted
p03272
Input is given from Standard Input in the following format: N i
m, n = map(int, input().split()) print(m - n + 1)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s746515923
Accepted
p03272
Input is given from Standard Input in the following format: N i
print(1 + eval(input().replace(" ", "-")))
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s347769998
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
print(eval(input().replace(" ", "-") + 1))
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s033773124
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
N,I=map(int,input().split()) print(N-I+
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s576279866
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
i, j = map(int, input()) print(i - j + 1)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s695083733
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
a
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s523872296
Wrong Answer
p03272
Input is given from Standard Input in the following format: N i
def solve(a, b): c = a - b + 1 return c
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s898684959
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
N, i = map(int, input().split()) print(N-i+1))
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s010413257
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
n i = map(int,input().split()) print(n - i + 1)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s516706222
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
N i = map(int, input().split()) print(N-i+1)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s895493791
Accepted
p03272
Input is given from Standard Input in the following format: N i
l = list(map(int, input().split())) print(l[0] + 1 - l[1])
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s003444460
Accepted
p03272
Input is given from Standard Input in the following format: N i
li = list(map(int, input().split())) n = li[0] k = li[1] i = n - k + 1 print(i)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s155535741
Accepted
p03272
Input is given from Standard Input in the following format: N i
#!/usr/bin/env python3 import sys # import math # from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from copy import deepcopy # to copy multi-dimentional matrix without reference # from fractions import gcd # for Python 3.4 (previous contest @AtCoder) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79...e+308 # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) n, i = mi() print(n + 1 - i) if __name__ == "__main__": main()
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s045230526
Accepted
p03272
Input is given from Standard Input in the following format: N i
inp = input() num = inp.split(" ") N = int(num[0]) i = int(num[1]) result = N - i + 1 print(result)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s544799896
Accepted
p03272
Input is given from Standard Input in the following format: N i
N = list(map(int, input().split())) print(N[0] - N[1] + 1)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s514269839
Accepted
p03272
Input is given from Standard Input in the following format: N i
a = list(map(int, input().split(" "))) print(a[0] - a[1] + 1)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s371812147
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
n, i = int(input("enter the numbers")) x = n - i + 1 Print("the result") print(x)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s440790854
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
n = int(input()) nums = [int(x) for x in input().split()] def findMedian(nums): size = len(nums) mIndex = (size * (size + 1) // 2) + 1 gap = 0 mValue = 0 while mIndex > 0 and gap < size: start = 0 end = start + gap while end < size and mIndex > 0: mIndex -= 1 mValue = nums[(start + end + 1) // 2] start += 1 end += 1 gap += 1 return mValue print(findMedian(nums))
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s889160007
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
N , i = map( int input( ) ) x = (N - i) + 1 print ( x )
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s795736424
Runtime Error
p03272
Input is given from Standard Input in the following format: N i
There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]
Print the answer. * * *
s086155166
Wrong Answer
p03272
Input is given from Standard Input in the following format: N i
info = input() info = info.split() print(info) backward = int(info[0]) - int(info[1]) + 1 print(backward)
Statement There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back."
[{"input": "4 2", "output": "3\n \n\nThe second car from the front of a 4-car train is the third car from the back.\n\n* * *"}, {"input": "1 1", "output": "1\n \n\n* * *"}, {"input": "15 11", "output": "5"}]