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 the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s895281555
Runtime Error
p02677
Input is given from Standard Input in the following format: A B H M
import math A,B,H,M = map(int, input().split()) a = 360*H/12+30*M/60 b = 360*M/60 c = abs(a-b) if c < 90: sin(c) = math.sin(math.radians(c)) cos(c) = math.sin(math.radians(c)) d = B-A*cos(c) e = (d**2+(A*sin(c))**2)**0.5 print(e) elif c == 90: e = (A**2+B**2)**0.5 print(e) elif c > 90: sin(c) = math.sin(math.radians(180-c)) cos(c) = math.sin(math.radians(180-c)) d = B+A*cos(c) e = (d**2+(A*sin(c)**2)**0.5 print(e)
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s799709310
Accepted
p02677
Input is given from Standard Input in the following format: A B H M
# abc168_c.py # https://atcoder.jp/contests/abc168/tasks/abc168_c # C - : (Colon) / # 実行時間制限: 2 sec / メモリ制限: 1024 MB # 配点: 300点 # 問題文 # 時針と分針の長さがそれぞれ Aセンチメートル、Bセンチメートルであるアナログ時計を考えます。 # 時針と分針それぞれの片方の端点は同じ定点に固定されており、この点を中心としてそれぞれの針は一定の角速度で時計回りに回転します。 # 時針は 12時間で、分針は 1 時間で 1周します。 # 0時ちょうどに時針と分針は重なっていました。 # ちょうど H 時 M 分になったとき、2本の針の固定されていない方の端点は何センチメートル離れているでしょうか。 # 制約 # 入力はすべて整数 # 1≤A,B≤1000 # 0≤H≤11 # 0≤M≤59 # 入力 # 入力は以下の形式で標準入力から与えられる。 # A B H M # 出力 # 答えを、単位を除いて出力せよ。正しい値との絶対誤差または相対誤差が 10−9以下であれば正解とみなされる。 # 入力例 1 # 3 4 9 0 # 出力例 1 # 5.00000000000000000000 # 2本の針は図のようになるので、答えは 5センチメートルです。 # 9時0分のアナログ時計 # 入力例 2 # 3 4 10 40 # 出力例 2 # 4.56425719433005567605 # 2本の針は図のようになります。各針は常に一定の角速度で回ることに注意してください。 global FLAG_LOG FLAG_LOG = False def log(value): # FLAG_LOG = True FLAG_LOG = False if FLAG_LOG: print(str(value)) def calculation(lines): # S = lines[0] # N = int(lines[0]) A, B, H, M = list(map(int, lines[0].split())) # values = list(map(int, lines[1].split())) # values = list(map(int, lines[2].split())) # values = list() # for i in range(N): # values.append(int(lines[i])) # valueses = list() # for i in range(N): # valueses.append(list(map(int, lines[i+1].split()))) h = 360 / 12 * (H + (M / 60)) m = 360 / 60 * M a = abs(h - m) log(f"h=[{h}], m=[{m}], a=[{a}]") # H軸をX扱いで、(3, 0) ※この座標は固定 # x, y = 3.0, 0 # M軸の座標を計算 import math x = math.cos(a / 180 * math.pi) * B y = math.sin(a / 180 * math.pi) * B log(f"x=[{x}], y=[{y}]") result = ((x - A) ** 2 + y**2) ** 0.5 return [result] # 引数を取得 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 = ["3 4 9 0"] lines_export = [5.00000000000000000000] if pattern == 2: lines_input = ["3 4 10 40"] lines_export = [4.56425719433005567605] return lines_input, lines_export # 動作モード判別 def get_mode(): import sys args = sys.argv global FLAG_LOG if len(args) == 1: mode = 0 FLAG_LOG = False else: mode = int(args[1]) FLAG_LOG = True return mode # 主処理 def main(): import time started = time.time() 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') # finished = time.time() # duration = finished - started # print(f'duration=[{duration}]') # 起動処理 if __name__ == "__main__": main()
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s895284059
Runtime Error
p02677
Input is given from Standard Input in the following format: A B H M
import math inputs = input().split() A, B, H, M = int(inputs[0]), int(inputs[1]), int(inputs[2]), int(inputs[3]) num_diff = H*5+M/12 - M ans = math.sqrt(A**2 + B**2 - 2 * A * B * math.cos(2 * math.pi( num_diff / 60 )) print(ans)
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s455095555
Accepted
p02677
Input is given from Standard Input in the following format: A B H M
import math A,B,H,M=map(int,input().split()) H=((H+(M/60))/12)*360; M=(M/60)*360 C=abs(H-M) C=math.cos(math.radians(C)) print(math.sqrt((A**2)+(B**2)+(-2*A*B*C)))
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s929757588
Runtime Error
p02677
Input is given from Standard Input in the following format: A B H M
import math A,B,H,M=map(int,input().split()) c=abs(H*15-M*6) k=A*A+B*B-2*A*B*math.cos(c) l=math.sqrt(k) print(l:df)
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s699629088
Runtime Error
p02677
Input is given from Standard Input in the following format: A B H M
import math A,B,H,M=map(int, input.split()) a=math.pi b=math.cos(a*((48H+M)/360)) Z=A**2+B**2-2ABb print(Z**(1/2))
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s458920300
Wrong Answer
p02677
Input is given from Standard Input in the following format: A B H M
import math A, B, H, M = map(int, input().split(" ")) print(A, B, H, M) # c²=a²+b²−2abcosΘ # 角度さえ求まればいける # Aは1分で0.5度づつ # Bは1分で6度づつ # AとBのどっちが左側にあるかもポイント angle_a = (H * 30) + (M * 0.5) angle_b = M * 6 # print("angle_a", angle_a) # print("angle_b", angle_b) cos = 0 ret = 0 if angle_a == angle_b: # print("ぴったり") ret = abs(A - B) else: if angle_a > angle_b: cos = math.cos(math.radians(angle_a - angle_b)) # print("時針のほうが先いってる", cos) else: cos = math.cos(math.radians(angle_b - angle_a)) # print("分針のほうが先いってる", cos) ret = math.sqrt(A**2 + B**2 - 2 * A * B * cos) print(ret)
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s746787351
Accepted
p02677
Input is given from Standard Input in the following format: A B H M
import math def calc_minutes(h, m): return 60 * h + m def to_angle_minutes(h, m): minutes = calc_minutes(h, m) minutes_角度 = minutes / 60 shousu = math.modf(minutes_角度)[0] angle_minutes = 360 * shousu return angle_minutes def to_angle_hours(h, m): minutes = calc_minutes(h, m) hours_角度 = minutes / 720 shousu = math.modf(hours_角度)[0] angle_hours = 360 * shousu return angle_hours def to_cosC(angle_hours, angle_minutes): C = abs(angle_hours - angle_minutes) C_rad = math.radians(C) cosC = math.cos(C_rad) return cosC def actual(a, b, h, m): angle_hours = to_angle_hours(h, m) angle_minutes = to_angle_minutes(h, m) cosC = to_cosC(angle_hours, angle_minutes) c = math.sqrt(a**2 + b**2 - 2 * a * b * cosC) return c a, b, h, m = map(int, input().split()) print(actual(a, b, h, m))
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s909179368
Runtime Error
p02677
Input is given from Standard Input in the following format: A B H M
import math a, b, h, m = map(int,input().split) fine = math.cos((5h - m) * math.pi / 60) c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * fine) print(c)
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s569967941
Accepted
p02677
Input is given from Standard Input in the following format: A B H M
import math class Watch: """ This is a class to calculate angle and distance between two hands. Attributes: length_of_hour_hand(int): Length of the hour hand. length_of_minute_hand(int): Length of the minute hand. hours(int): Hours. minutes(int): Minutes. """ def __init__(self, length_of_hour_hand, length_of_minute_hand, hours, minutes): """ The constructor for Watch class. Attributes: length_of_hour_hand(int): Length of the hour hand. length_of_minute_hand(int): Length of the minute hand. hours(int): Hours. minutes(int): Minutes. angle_between_two_hands(float): Angle between the hour hand and the minute one. distance_between_two_hands(float): Distance between the tip of hour hand and that of minute one. """ self.length_of_hour_hand = length_of_hour_hand self.length_of_minute_hand = length_of_minute_hand self.hours = hours self.minutes = minutes self.angle_between_two_hands = None self.distance_between_two_hands = None def calculate_angle_between_two_hands(self): """ Calculate angle between the hour hand and the minute one. """ # degrees_of_hour_hand: float, radian degrees_of_hour_hand = ( ((self.hours + self.minutes / 60.0) / 12.0) * 2.0 * math.pi ) # degrees_of_minute_hand: float, radian degrees_of_minute_hand = (self.minutes / 60.0) * 2.0 * math.pi # angle_between_two_hands: float, radian angle_between_two_hands = degrees_of_hour_hand - degrees_of_minute_hand self.angle_between_two_hands = angle_between_two_hands def calculate_distance_between_two_hands(self): """ Calculate distance between the tip of hour hand and that of minute hand. """ self.distance_between_two_hands = math.sqrt( self.length_of_hour_hand**2 + self.length_of_minute_hand**2 - 2 * self.length_of_hour_hand * self.length_of_minute_hand * math.cos(self.angle_between_two_hands) ) # A, B, H, M: ints, A: the length of the hour hand, # B: the length of the minute hand, H: hours, M: minutes A, B, H, M = [int(s) for s in input().split(" ")] watch = Watch(A, B, H, M) watch.calculate_angle_between_two_hands() watch.calculate_distance_between_two_hands() print(watch.distance_between_two_hands)
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s492082074
Runtime Error
p02677
Input is given from Standard Input in the following format: A B H M
import math def yo(a, b, th): thr = math.radians(th) cosa = math.cos(thr) kk = 4.56425719433005567605 ttt = (a**2 + b**2 - kk**2) / (2 * a * b) acosa = math.acos(ttt) ttt = math.degrees(acosa) tmp = float(a**2) + float(b**2) - float(2 * b * a * cosa) re = float(math.sqrt(tmp)) return re A, B, h, m = map(int, input().split()) longdig = ((h * 60 + m) % 360) * 6 shortdig = (h * 60 + m) * 0.5 theta = abs(longdig - shortdig) print(yo(A, B, theta))
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s787786703
Accepted
p02677
Input is given from Standard Input in the following format: A B H M
def c_colon_dist(): from math import pi, sin, cos, dist A, B, H, M = [int(i) for i in input().split()] hour_hand_rad = (60 * H + M) * pi / 360 minute_hand_rad = M * pi / 30 hour_hand_pos = (sin(hour_hand_rad) * A, cos(hour_hand_rad) * A) minute_hand_pos = (sin(minute_hand_rad) * B, cos(minute_hand_rad) * B) return dist(hour_hand_pos, minute_hand_pos) print(c_colon_dist())
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s972720025
Accepted
p02677
Input is given from Standard Input in the following format: A B H M
import sys from math import sin, cos, atan pi = atan(1) * 4 A, B, H, M = [int(x) for x in sys.stdin.readline().rstrip().split(" ")] yukati = H + M / 60.0 theta_zi = 2 * pi * yukati / 12 theta_fun = 2 * pi * yukati zix = A * sin(theta_zi) ziy = A * cos(theta_zi) funx = B * sin(theta_fun) funy = B * cos(theta_fun) print("%.15f" % (((zix - funx) * (zix - funx) + (ziy - funy) * (ziy - funy)) ** 0.5))
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s493850274
Accepted
p02677
Input is given from Standard Input in the following format: A B H M
""" ・なんとか自力AC。大変だった。これ本当に300点か。。 ・三角形、角度、三角関数、余弦定理 ・2辺の長さが分かっていてもう1辺を知りたいので、角度が分かればいいなーって気持ちになる。 ・時刻が与えられるが、短針の微妙な位置とか分からんだろ、ってなる。 ・ここで先にD解いたり、Eしばらく考えたりして、E厳し目っぽかったので戻ってきた。 ・もう1回、300点でそんな高度な要求がある訳ないという前提の元、考え直してみる。 ・ここでやっと、1分毎に動く量を出せば経過時間から割り出せると分かる。 ・ちょっとゴニョゴニョして無事角度が出て、さて、2辺と角度が揃ったらどうするんだっけな、とググる。 ・余弦定理の公式が出てきて、あぁこんなんあったな、と当てはめる。無事AC。 ・こういうのを300点っていう低難度で出せちゃうのは、やっぱり競プロは数学ゲーなんだな、と改めて思わされる所。 """ import sys from math import sin, cos, radians, hypot 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**18 MOD = 10**9 + 7 a, b, h, m = MAP() hm = h * 60 + m heach = hm / 720 meach = m / 60 hdig = heach * 360 mdig = meach * 360 hx = a * cos(radians(hdig)) hy = a * sin(radians(hdig)) mx = b * cos(radians(mdig)) my = b * sin(radians(mdig)) ans = hypot(hx - mx, hy - my) print(ans)
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s708062002
Accepted
p02677
Input is given from Standard Input in the following format: A B H M
import math a,b,h,m=map(int,input().split()) ad=30*h+6*m/12 bd=6*m ca=abs(ad-bd) if 360-ca < ca: ca=360-ca ans=a**2+b**2-(2*a*b)*math.cos(math.radians(ca)) print(math.sqrt(ans))
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
Print the answer without units. Your output will be accepted when its absolute or relative error from the correct value is at most 10^{-9}. * * *
s898943907
Runtime Error
p02677
Input is given from Standard Input in the following format: A B H M
k = int(input()) s = input() if len(s) > k: s = s[:k] + "..." print(s)
Statement Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively. At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?
[{"input": "3 4 9 0", "output": "5.00000000000000000000\n \n\nThe two hands will be in the positions shown in the figure below, so the\nanswer is 5 centimeters.\n\n![The clock at <var>9</var>\no'clock](https://img.atcoder.jp/ghi/when_a_nameless_star_falls_into_the_sky.png)\n\n* * *"}, {"input": "3 4 10 40", "output": "4.56425719433005567605\n \n\nThe two hands will be in the positions shown in the figure below. Note that\neach hand always rotates at constant angular velocity.\n\n![The clock at\n<var>10:40</var>](https://img.atcoder.jp/ghi/when_flower_petals_flutter.png)"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s918067650
Accepted
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N = int(input()) nums = list(map(int, input().split())) counts = [0 for _ in range(N + 1)] for num in nums: counts[num] += 1 combination = 0 for count in counts: if count >= 2: combination += (count * (count - 1)) // 2 for num in nums: print(combination - counts[num] + 1)
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s981166797
Accepted
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N = int(input()) A = list(map(int, input().split())) CNT = [0] * (N + 1) # IND = list(set(A)) # CNT = [A.count(x) for x in IND] for i in A: CNT[i] += 1 # print(IND) # print(CNT) # CONB = [A.count(x)*(A.count(x)-1)//2 for x in IND] CONB = [CNT[x] * (CNT[x] - 1) // 2 for x in range(len(CNT))] # print(CONB) SUM = sum(CONB) for i in A: ans = SUM - CNT[i] + 1 print(ans)
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s276054427
Wrong Answer
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n = int(input()) for i in range(n): print(i)
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s585571731
Runtime Error
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
import itertools h, w, k = map(int, input().split()) li_hw = [list(f) for f in [input() for _ in range(h)]] all_h = [] score = [] # for l in range(2**(h-1)): # ind = [] # pre = 0 # cut_list=[] # hline_num = 0 # for n,yn in enumerate(reversed(list(bin(l))[2:])): # if yn == "1": # cut_list.append(li_hw[pre:n+1]) # pre = n+1 # cut_list.append(li_hw[pre:h]) for i in itertools.product([0, 1], repeat=h - 1): cut_list = [] hline_num = 0 pre = 0 cut_list = [] for n, i2 in enumerate(i): if i2 == 1: cut_list.append(li_hw[pre : n + 1]) pre = n + 1 cut_list.append(li_hw[pre:h]) hline_num = i.count(1) pred = 0 wline_num = 0 # print("list is {}".format(cut_list)) for y in range(w): wcounter_list = [] for c in cut_list: wcounter = 0 for c2 in c: wcounter += c2[pred : y + 1].count("1") wcounter_list.append(wcounter) # print("wcounter{}".format(wcounter_list)) if max(wcounter_list) > k: pred = y wline_num += 1 # print("line between{}and{}".format(y-1, y)) # print("wline{}, hline{}".format(wline_num, hline_num)) score.append(wline_num + hline_num) print(min(score))
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s857995708
Runtime Error
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
def check_block(comb, K): block = 0 pre = (comb & 1) > 0 mapping = {0: 0} cut_num = 0 for i in range(1, K): cur = ((1 << i) & comb) > 0 if pre != cur: block += 1 pre = cur cut_num += 1 mapping[i] = block return mapping, cut_num H, W, K = map(int, input().split()) graph = [input() for ele in range(H)] # ans = 1319203291031903 for comb in range(1 << (H - 1)): mapping, cut_num = check_block(comb, K) pre = [0] * (cut_num + 1) gg = False # preprocess for j in range(H): pre[mapping[j]] += graph[j][0] == "1" for ele in pre: if ele > K: gg = True break if gg: continue for i in range(1, W): cum = pre[:] for j in range(H): cum[mapping[j]] += graph[j][i] == "1" for ii in range(len(cum)): if cum[ii] - pre[ii] > K: gg = True break if cum[ii] > K: cut_num += 1 for idx in range(len(cum)): cum[idx] -= pre[idx] break pre = cum if gg: break if not gg: ans = min(ans, cut_num) print(ans)
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s848309958
Runtime Error
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N = int(input()) A = [int(a) for a in input().split()] Acnt = [A.count(n) for n in range(N)] Aprob = [Acnt[n] * (Acnt[n] - 1) // 2 for n in range(N)] sumA = sum(Aprob) for a in A: """ ai=[] ai=A[:n]+A[n+1:] #print(ai) Adic[A[n]]-=1 ans=0 for i,v in Adic.items(): ans+=v*(v-1)//2 """ ans = (Acnt[a] - 1) * (Acnt[a] - 2) // 2 print(ans + sumA - Aprob[a])
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s968499786
Runtime Error
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N = int(input()) A = list(map(int, input().split())) a = sorted(A) answer = [0] * N r, l = 0, 0 for i in range(N): b = a.pop(A[i]) A.remove(A[i]) ans = 0 con = 0 while r < N - 1: if r == l: r += 1 elif a[r] == a[l]: con += 1 r += 1 if r == N - 1: ans += con * (con + 1) // 2 else: l += 1 ans += con * (con + 1) // 2 con = 0 r, l = 0, 0 answer[i] = ans A.insert(i, b) a.append(b) a.sort() for i in range(N): print(answer[i])
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s220043573
Accepted
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N = int(input()) alist = list(map(int, input().split())) # print(alist) dic_a = {} for a in alist: if not a in dic_a: dic_a[a] = 1 else: dic_a[a] += 1 all_pair = 0 for val in dic_a.values(): all_pair += val * (val - 1) // 2 # print(dic_a,all_pair) dic_answer = {} for a in alist: if a in dic_answer: print(dic_answer[a]) continue now = dic_a[a] kill = now * (now - 1) // 2 - (now - 1) * (now - 2) // 2 answer = all_pair - kill print(answer) dic_answer[a] = answer
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s480977437
Accepted
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
def z(z_dic, v: int): if v in z_dic: return z_dic[v] z = 0 if v == 2: z = 1 elif v > 2: z = int(v * (v - 1) / 2) z_dic.setdefault(v, z) return z def main(): n = int(input()) ar = [0] * (n + 1) ls = [] for x in map(int, input().split()): ls.append(x) ar[x] += 1 zls = [] zls2 = [] z_dic = {} for i in range(1, n + 1): v = ar[i] zls.append(z(z_dic, v)) zls2.append(z(z_dic, v - 1)) ss = sum(zls) for i in range(1, n + 1): aa = ls[i - 1] print(ss - zls[aa - 1] + zls2[aa - 1]) # # itr = map(int, input().split()) # dic = {} # for num in itr: # dic.setdefault(num, 0) # dic[num] += 1 # ls.append(num) # # for i in range(n): # # ls[i]を除く # a = ls[i] # dic[a] -= 1 # res = 0 # for k, v in dic.items(): # if v < 2: # continue # elif v == 2: # res += 1 # else: # res += int(v*(v-1)/2) # print(res) # dic[a] += 1 main()
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s849083429
Accepted
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
n = int(input()) a = [0 for i in range(n)] b = [0 for i in range(n)] c = [0 for i in range(n)] r = 0 count = 0 for i in input().split(): a[int(i) - 1] += 1 b[count] = int(i) count += 1 for i in range(n): m = a[b[i] - 1] c[i] = 2 * m - 2 for i in range(n): r += a[i] * (a[i] - 1) for i in range(n): print((r - c[i]) // 2)
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s506182413
Wrong Answer
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
M = int(input()) N = list(input().split()) print(N) check = [0] * M for i in range(M): check[int(N[i]) - 1] += 1 num = 0 for i in range(M): num += check[i] * (check[i] - 1) // 2 for i in range(M): print(num - (check[int(N[i]) - 1] - 1))
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s904370951
Accepted
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N = int(input()) As = list(map(int, input().split())) num_count = {} count_comb = {} num_ans = {} sum_combs = 0 def comb2(n): if n not in count_comb: count_comb[n] = (n * (n - 1)) // 2 return count_comb[n] def ans(ex_num): ex_count = num_count[ex_num] return sum_combs + comb2(ex_count - 1) - comb2(ex_count) # if ex_num in num_ans: # return num_ans[ex_num] # result = 0 # for n, c in num_count.items(): # if n == ex_num: # result += comb2(c - 1) # else: # result += comb2(c) # num_ans[ex_num] = result # return result for a in As: if a not in num_count: num_count[a] = 0 num_count[a] += 1 for _, c in num_count.items(): sum_combs += comb2(c) for a in As: print(ans(a))
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
For each k=1,2,...,N, print a line containing the answer. * * *
s862276187
Wrong Answer
p02732
Input is given from Standard Input in the following format: N A_1 A_2 ... A_N
N = int(input()) A = list(map(int, input().split())) B = sorted(A) B.append(0) p = B[0] y = dict() u = 0 for k in range(N + 1): q = B[k] if p != q: y[p] = u u = 0 u += 1 p = q All = 0 for l in y.values(): All += l * (l - 1) // 2 print(All) for j in range(N): x = A[j] print(All + (y[x] - 1) * (y[x] - 2) // 2 - y[x] * (y[x] - 1) // 2)
Statement We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
[{"input": "5\n 1 1 2 1 2", "output": "2\n 2\n 3\n 2\n 3\n \n\nConsider the case k=1 for example. The numbers written on the remaining balls\nare 1,2,1,2. \nFrom these balls, there are two ways to choose two distinct balls so that the\nintegers written on them are equal. \nThus, the answer for k=1 is 2.\n\n* * *"}, {"input": "4\n 1 2 3 4", "output": "0\n 0\n 0\n 0\n \n\nNo two balls have equal numbers written on them.\n\n* * *"}, {"input": "5\n 3 3 3 3 3", "output": "6\n 6\n 6\n 6\n 6\n \n\nAny two balls have equal numbers written on them.\n\n* * *"}, {"input": "8\n 1 2 1 4 2 1 4 1", "output": "5\n 7\n 5\n 7\n 7\n 5\n 7\n 5"}]
Print N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k. * * *
s676491444
Accepted
p02698
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
#!/usr/bin/env python import os import sys from io import BytesIO, IOBase def lb(a, x): l, r = 0, len(a) while r - l > 1: m = (l + r) // 2 if a[m] < x: l = m else: r = m return r class FenwickTree: def __init__(self, n): """transform list into BIT""" self.bit = [[0] for _ in range(n)] def update(self, idx, fl, x): """updates bit[idx] += x""" while idx < len(self.bit): if fl: self.bit[idx].append(max(x, self.bit[idx][-1])) else: self.bit[idx].pop() idx |= idx + 1 def query(self, end): """calc sum(bit[:end])""" x = 0 while end: x = max(x, self.bit[end - 1][-1]) end &= end - 1 return x def dfs(graph, start, a): n = len(graph) dp = [0] * n visited, finished = [False] * n, [False] * n tree = FenwickTree(n + 5) b = [] stack = [start] while stack: start = stack[-1] # push unvisited children into stack if not visited[start]: tree.update(a[start], True, 1 + tree.query(a[start])) dp[start] = tree.query(n + 1) b += [a[start]] # print(start,b,dp[start]) visited[start] = True for child in graph[start]: if not visited[child]: stack.append(child) else: stack.pop() b.pop() # pop start. tree.update(a[start], False, 0) finished[start] = True return dp def main(): n = int(input()) a = [int(x) for x in input().split()] b = [x for x in a] b.append(-1) b.append(10**9 + 1) b.sort() for i in range(len(a)): a[i] = lb(b, a[i]) e = [[] for _ in range(n)] # print(e) for _ in range(n - 1): u, v = map(int, input().split()) e[u - 1].append(v - 1) e[v - 1].append(u - 1) # print(e) print(*dfs(e, 0, a)) # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") # endregion if __name__ == "__main__": main()
Statement We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem: * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence. Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.
[{"input": "10\n 1 2 5 3 4 6 7 3 2 4\n 1 2\n 2 3\n 3 4\n 4 5\n 3 6\n 6 7\n 1 8\n 8 9\n 9 10", "output": "1\n 2\n 3\n 3\n 4\n 4\n 5\n 2\n 2\n 3\n \n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to\nVertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4,\nA_5, with the length of 4."}]
Print N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k. * * *
s677643023
Runtime Error
p02698
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
# coding: utf-8 import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() # ignore trailing spaces def dfs(now): checked[now] = 1 sequences[now] += [As[now]] ans[now] = LIS(sequences[now]) for i in tree[now]: if checked[i] == 0: sequences[i] = [i for i in sequences[now]] dfs(i) def BinarySearch(num, nums): if len(nums) == 0: print("Erorr : list has no element") return left, right = 0, len(nums) while left < right: mid = (left + right) // 2 if num < nums[mid]: right = mid else: left = mid + 1 return right def LIS(seq): LISs = [seq[0]] for i in range(1, len(seq)): if seq[i] > LISs[-1]: LISs.append(seq[i]) else: right = BinarySearch(seq[i], LISs) if LISs[right - 1] != seq[i]: LISs[right] = seq[i] return len(LISs) tree = [] checked = [] As = [] sequences = [] ans = [] def main(): global tree, checked, As, sequences, ans n = ni() As = na() tree = [[] for _ in range(n)] # tree[i] = The children of vertex i sequences = [ [] for _ in range(n) ] # sequences[i] = The sequence of a's values that is shortest path to vertex i sequences[0] = [As[0]] checked = [0 for _ in range(n)] ans = [-1 for _ in range(n)] for _ in range(n - 1): u, v = na() tree[u - 1] += [v - 1] tree[v - 1] += [u - 1] dfs(0) for i in range(n): print(ans[i]) return if __name__ == "__main__": main()
Statement We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem: * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence. Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.
[{"input": "10\n 1 2 5 3 4 6 7 3 2 4\n 1 2\n 2 3\n 3 4\n 4 5\n 3 6\n 6 7\n 1 8\n 8 9\n 9 10", "output": "1\n 2\n 3\n 3\n 4\n 4\n 5\n 2\n 2\n 3\n \n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to\nVertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4,\nA_5, with the length of 4."}]
Print N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k. * * *
s016360767
Wrong Answer
p02698
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
# from collections import deque,defaultdict printn = lambda x: print(x, end="") inn = lambda: int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda: input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 # R = 998244353 def ddprint(x): if DBG: print(x) import sys, resource, bisect def setrlim(): sys.setrecursionlimit(250000) soft, hard = resource.getrlimit(resource.RLIMIT_STACK) # setrlimit works on ubuntu (and atcoder), but not on WSL resource.setrlimit(resource.RLIMIT_STACK, (128 * 1024 * 1024, hard)) def dfs(u, j, dp): ans[u] = j for v in dst[u]: if ans[v] >= 0: continue x = bisect.bisect_left(dp, a[v]) tmp = dp[x] dp[x] = a[v] dfs(v, j + (1 if tmp == BIG else 0), dp) dp[x] = tmp setrlim() n = inn() a = inl() a[0:0] = [0] dst = [{} for i in range(n + 1)] for i in range(n - 1): u, v = inm() dst[u][v] = dst[v][u] = 1 ans = [-1] * (n + 1) dp = [BIG] * (n + 1) dp[1] = a[1] dfs(1, 1, dp) for i in range(1, n + 1): print(ans[i])
Statement We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem: * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence. Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.
[{"input": "10\n 1 2 5 3 4 6 7 3 2 4\n 1 2\n 2 3\n 3 4\n 4 5\n 3 6\n 6 7\n 1 8\n 8 9\n 9 10", "output": "1\n 2\n 3\n 3\n 4\n 4\n 5\n 2\n 2\n 3\n \n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to\nVertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4,\nA_5, with the length of 4."}]
Print N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k. * * *
s937900525
Runtime Error
p02698
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
def n0(): return int(input()) def n1(): return [int(x) for x in input().split()] def n2(n): return [int(input()) for _ in range(n)] def n3(n): return [tuple([int(x) for x in input().split()]) for _ in range(n)] n = n0() a = [0] a.extend(n1()) s = n3(n - 1) import networkx as nx G = nx.Graph() G.add_edges_from(s) last_node = [[0, 0, 0] for i in range(0, n + 1)] # 頂点名、パスの前の頂点、パスの長さ for i in range(2, n + 1): path = nx.dijkstra_path(G, 1, i) last_node[i] = [i, path[-2], len(path)] last_node.sort(key=lambda x: x[2]) info = {i: [0, 0] for i in range(1, n + 1)} # 現在の最長列、今までの最長列 info[1] = [1, 1] for line in last_node[2:]: now = line[0] last = line[1] if a[last] < a[now]: info[now] = [info[last][0] + 1, max(info[last][0] + 1, info[last][1] + 1)] else: info[now] = [1, info[last][1]] for line in info.values(): print(line[1])
Statement We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem: * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence. Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.
[{"input": "10\n 1 2 5 3 4 6 7 3 2 4\n 1 2\n 2 3\n 3 4\n 4 5\n 3 6\n 6 7\n 1 8\n 8 9\n 9 10", "output": "1\n 2\n 3\n 3\n 4\n 4\n 5\n 2\n 2\n 3\n \n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to\nVertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4,\nA_5, with the length of 4."}]
Print N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k. * * *
s310278279
Runtime Error
p02698
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
n, a, b, c = [int(i) for i in input().split(" ")] s = [] # AB,BC,AC=0 for i in range(n): s.append(input()) # if s[i]=="AB": # AB+=1 # # elif s[i]=="AC": # AC+=1 # # elif s[i] == "BC": # BC+=1 for str in s: if str == "AB": if a > b: a -= 1 b += 1 print("B") else: b -= 1 a += 1 print("A") if str == "AC": if a > c: a -= 1 c += 1 print("C") else: a += 1 c -= 1 print("A") if str == "BC": if b > c: b -= 1 c += 1 print("C") else: b += 1 c -= 1 print("B")
Statement We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem: * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence. Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.
[{"input": "10\n 1 2 5 3 4 6 7 3 2 4\n 1 2\n 2 3\n 3 4\n 4 5\n 3 6\n 6 7\n 1 8\n 8 9\n 9 10", "output": "1\n 2\n 3\n 3\n 4\n 4\n 5\n 2\n 2\n 3\n \n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to\nVertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4,\nA_5, with the length of 4."}]
Print N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k. * * *
s572990253
Runtime Error
p02698
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
import numpy as np print(np.nan)
Statement We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem: * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence. Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.
[{"input": "10\n 1 2 5 3 4 6 7 3 2 4\n 1 2\n 2 3\n 3 4\n 4 5\n 3 6\n 6 7\n 1 8\n 8 9\n 9 10", "output": "1\n 2\n 3\n 3\n 4\n 4\n 5\n 2\n 2\n 3\n \n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to\nVertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4,\nA_5, with the length of 4."}]
Print N lines. The k-th line, print the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k. * * *
s984949702
Runtime Error
p02698
Input is given from Standard Input in the following format: N a_1 a_2 ... a_N u_1 v_1 u_2 v_2 : u_{N-1} v_{N-1}
import sys def input(): return sys.stdin.readline().strip() n, a, b, c = map(int, input().split()) s = [] for _ in range(n): s.append(input()) # 0 <= i < n-1 ans = [] for i in range(n - 1): if s[i] == "BC": if b > c: ans.append("C") b -= 1 c += 1 elif b < c: ans.append("B") b += 1 c -= 1 elif s[i + 1] == "AB": ans.append("B") b += 1 c -= 1 else: ans.append("C") b -= 1 c += 1 elif s[i] == "AC": if a > c: ans.append("C") a -= 1 c += 1 elif a < c: ans.append("A") a += 1 c -= 1 elif s[i + 1] == "BC": ans.append("C") a -= 1 c += 1 else: ans.append("A") a += 1 c -= 1 else: if a > b: ans.append("B") a -= 1 b += 1 elif a < b: ans.append("A") a += 1 b -= 1 elif s[i + 1] == "AC": ans.append("A") a += 1 b -= 1 else: ans.append("B") a -= 1 b += 1 if a < 0 or b < 0 or c < 0: print("No") exit() # i = n-1 if s[n - 1] == "BC": if b > c: ans.append("C") b -= 1 c += 1 else: ans.append("B") b += 1 c -= 1 elif s[n - 1] == "AC": if a > c: ans.append("C") a -= 1 c += 1 else: ans.append("A") a += 1 c -= 1 else: if a > b: ans.append("B") a -= 1 b += 1 else: ans.append("A") a += 1 b -= 1 if a < 0 or b < 0 or c < 0: print("No") exit() print("Yes") for i in ans: print(i)
Statement We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem: * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k, in the order they appear. Find the length of the longest increasing subsequence of this sequence. Here, the longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1} , A_{i_2} , ... , A_{i_M} with the greatest possible value of M such that 1 \leq i_1 < i_2 < ... < i_M \leq L and A_{i_1} < A_{i_2} < ... < A_{i_M}.
[{"input": "10\n 1 2 5 3 4 6 7 3 2 4\n 1 2\n 2 3\n 3 4\n 4 5\n 3 6\n 6 7\n 1 8\n 8 9\n 9 10", "output": "1\n 2\n 3\n 3\n 4\n 4\n 5\n 2\n 2\n 3\n \n\nFor example, the sequence A obtained from the shortest path from Vertex 1 to\nVertex 5 is 1,2,5,3,4. Its longest increasing subsequence is A_1, A_2, A_4,\nA_5, with the length of 4."}]
If the graph contains a negative cycle (a cycle whose sum of edge costs is a negative value) which is reachable from the source r, print NEGATIVE CYCLE in a line. Otherwise, print c0 c1 : c|V|-1 The output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print "INF".
s869443811
Accepted
p02362
An edge-weighted graph G (V, E) and the source r. |V| |E| r s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.
# Edige Weighted Digraph from collections import namedtuple WEIGHT_MAX = 10**10 WeightedEdge = namedtuple("WeightedEdge", ("src", "dest", "weight")) class Digraph: def __init__(self, v): self.v = v self.edges = [[] for _ in range(v)] def add(self, edge): self.edges[edge.src].append(edge) def adj(self, v): return self.edges[v] def sp_bellmanford(graph, s): def relax(edge): s, t, w = edge if dists[t] > dists[s] + w: dists[t] = dists[s] + w srcs[t] = s _nodes.append(t) dists = [WEIGHT_MAX] * graph.v dists[s] = 0 srcs = [-1] * graph.v nodes = [] nodes.append(s) for _ in range(graph.v): _nodes = [] for v in nodes: for e in graph.adj(v): relax(e) nodes = _nodes if len(nodes) > 0: return None else: return [None if dists[v] == WEIGHT_MAX else dists[v] for v in range(graph.v)] def run(): v, e, r = [int(i) for i in input().split()] graph = Digraph(v) for _ in range(e): edge = WeightedEdge(*[int(i) for i in input().split()]) graph.add(edge) ws = sp_bellmanford(graph, r) if ws is None: print("NEGATIVE CYCLE") else: for w in ws: if w is None: print("INF") else: print("{:d}".format(w)) if __name__ == "__main__": run()
Single Source Shortest Path (Negative Edges)
[{"input": "4 5 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "0\n 2\n -3\n -1"}, {"input": "4 6 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2\n 3 1 0", "output": "NEGATIVE CYCLE"}, {"input": "4 5 1\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "INF\n 0\n -5\n -3"}]
If the graph contains a negative cycle (a cycle whose sum of edge costs is a negative value) which is reachable from the source r, print NEGATIVE CYCLE in a line. Otherwise, print c0 c1 : c|V|-1 The output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print "INF".
s091024208
Wrong Answer
p02362
An edge-weighted graph G (V, E) and the source r. |V| |E| r s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.
# Input acceptance import sys file_input = sys.stdin V, E, r = map(int, file_input.readline().split()) edges = [] for line in file_input: edges.append(tuple(map(int, line.split()))) # Bellman???Ford algorithm distance = [float("inf")] * V distance[r] = 0 for i in range(V): notUpdated = True for e in edges: t = e[1] temp_d = distance[e[0]] + e[2] if temp_d < distance[t]: distance[t] = temp_d notUpdated = False if notUpdated: break # Output if i == V - 1: print("NEGATICE CYCLE") else: print(*map(lambda x: str(x).upper(), distance), sep="\n")
Single Source Shortest Path (Negative Edges)
[{"input": "4 5 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "0\n 2\n -3\n -1"}, {"input": "4 6 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2\n 3 1 0", "output": "NEGATIVE CYCLE"}, {"input": "4 5 1\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "INF\n 0\n -5\n -3"}]
If the graph contains a negative cycle (a cycle whose sum of edge costs is a negative value) which is reachable from the source r, print NEGATIVE CYCLE in a line. Otherwise, print c0 c1 : c|V|-1 The output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print "INF".
s978874552
Accepted
p02362
An edge-weighted graph G (V, E) and the source r. |V| |E| r s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.
#!/usr/bin/python3 import os import sys def main(): V, E, R = read_ints() D = [tuple(read_ints()) for _ in range(E)] print(*solve(V, E, R, D), sep="\n") def solve(V, E, R, D): INF = 10001 * 1000 dists = [INF] * V dists[R] = 0 for _ in range(V - 1): for s, t, d in D: if dists[s] != INF and dists[t] > dists[s] + d: dists[t] = dists[s] + d for s, t, d in D: if dists[s] != INF and dists[s] + d < dists[t]: return ["NEGATIVE CYCLE"] return ["INF" if d == INF else d for d in dists] ############################################################################### # AUXILIARY FUNCTIONS DEBUG = "DEBUG" in os.environ def inp(): return sys.stdin.readline().rstrip() def read_int(): return int(inp()) def read_ints(): return [int(e) for e in inp().split()] def dprint(*value, sep=" ", end="\n"): if DEBUG: print(*value, sep=sep, end=end) if __name__ == "__main__": main()
Single Source Shortest Path (Negative Edges)
[{"input": "4 5 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "0\n 2\n -3\n -1"}, {"input": "4 6 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2\n 3 1 0", "output": "NEGATIVE CYCLE"}, {"input": "4 5 1\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "INF\n 0\n -5\n -3"}]
If the graph contains a negative cycle (a cycle whose sum of edge costs is a negative value) which is reachable from the source r, print NEGATIVE CYCLE in a line. Otherwise, print c0 c1 : c|V|-1 The output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print "INF".
s358146439
Accepted
p02362
An edge-weighted graph G (V, E) and the source r. |V| |E| r s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) INF = float("inf") # ベルマンフォード(頂点数, 辺集合(0-indexed), 始点) def bellman_ford(N: int, edges: list, src: int) -> list: # 頂点[ある始点からの最短距離] # (経路自体を知りたい時はここに前の頂点も持たせる) res = [INF] * N res[src] = 0 # 各辺によるコストの置き換えを頂点数N-1回繰り返す for i in range(N - 1): for src, dest, cost in edges: if res[dest] > res[src] + cost: res[dest] = res[src] + cost # 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする for src, dest, cost in edges: if res[dest] > res[src] + cost: # あったら空リストを返却 return [] # 問題なければ頂点リストを返却 return res N, M, r = MAP() edges = [None] * M for i in range(M): s, t, d = MAP() edges[i] = (s, t, d) ans = bellman_ford(N, edges, r) if not len(ans): print("NEGATIVE CYCLE") exit() for i in range(N): if ans[i] == INF: ans[i] = "INF" for i in range(N): print(ans[i])
Single Source Shortest Path (Negative Edges)
[{"input": "4 5 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "0\n 2\n -3\n -1"}, {"input": "4 6 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2\n 3 1 0", "output": "NEGATIVE CYCLE"}, {"input": "4 5 1\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "INF\n 0\n -5\n -3"}]
If the graph contains a negative cycle (a cycle whose sum of edge costs is a negative value) which is reachable from the source r, print NEGATIVE CYCLE in a line. Otherwise, print c0 c1 : c|V|-1 The output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print "INF".
s139077178
Accepted
p02362
An edge-weighted graph G (V, E) and the source r. |V| |E| r s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.
""" Verified: https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_B """ from typing import List, Optional, Tuple def bellman_ford( source: int, vertices_count: int, edges: List[Tuple] ) -> Optional[List[float]]: """Bellman-Ford algorithm: O(NM) Compute the distance of the shortest path from V_source to each vertex. Relax edges in N-1 times of loops and detect negative cycles in the last loop. Args: source: V_source edges: Edges info vertices_count: Number of vertices Returns: Return None if the graph has negative cycles. If not, return a list of distance from V_source. """ inf = float("inf") dist = [inf] * (vertices_count + 1) dist[source] = 0 for i in range(vertices_count): for from_, to, weight in edges: if dist[from_] + weight < dist[to]: dist[to] = dist[from_] + weight if i == vertices_count - 1: return None return dist def main(): V, E, R, *edges = map(int, open(0).read().split()) dist = bellman_ford(R, V, list(zip(*[iter(edges)] * 3))) inf = float("inf") if dist: print("\n".join(map(str, (i if i != inf else "INF" for i in dist[:-1])))) else: print("NEGATIVE CYCLE") if __name__ == "__main__": main()
Single Source Shortest Path (Negative Edges)
[{"input": "4 5 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "0\n 2\n -3\n -1"}, {"input": "4 6 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2\n 3 1 0", "output": "NEGATIVE CYCLE"}, {"input": "4 5 1\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "INF\n 0\n -5\n -3"}]
If the graph contains a negative cycle (a cycle whose sum of edge costs is a negative value) which is reachable from the source r, print NEGATIVE CYCLE in a line. Otherwise, print c0 c1 : c|V|-1 The output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print "INF".
s860208193
Accepted
p02362
An edge-weighted graph G (V, E) and the source r. |V| |E| r s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.
V, E, r = map(int, input().split()) edges = [tuple(map(int, input().split())) for _ in range(E)] dist = [float("inf") for _ in range(V)] dist[r - 1] = 0 for i in range(V + 1): for edge in edges: if edge[0] != float("inf") and dist[edge[1] - 1] > dist[edge[0] - 1] + edge[2]: dist[edge[1] - 1] = dist[edge[0] - 1] + edge[2] if i == V - 1: print("NEGATIVE CYCLE") exit() print( "\n".join( str(dist[e - 1]) if dist[e - 1] != float("inf") else "INF" for e in range(V) ) )
Single Source Shortest Path (Negative Edges)
[{"input": "4 5 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "0\n 2\n -3\n -1"}, {"input": "4 6 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2\n 3 1 0", "output": "NEGATIVE CYCLE"}, {"input": "4 5 1\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "INF\n 0\n -5\n -3"}]
If the graph contains a negative cycle (a cycle whose sum of edge costs is a negative value) which is reachable from the source r, print NEGATIVE CYCLE in a line. Otherwise, print c0 c1 : c|V|-1 The output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print "INF".
s489318930
Accepted
p02362
An edge-weighted graph G (V, E) and the source r. |V| |E| r s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.
import sys fin = sys.stdin.readline MAX_NUM = float("inf") def initialize_int(adj, s): """ assume that all vertex in {0, 1, 2, ..., N - 1} """ N = len(adj) d = [MAX_NUM] * N d[s] = 0 parent = [None] * N return d, parent def relax(d, w, source_v, target_v, parent): new_cost = d[source_v] + w[source_v][target_v] if new_cost < d[target_v]: d[target_v] = new_cost parent[target_v] = source_v # Even if a negative weight exists, bellman-ford can find shortest paths. # it also detects negative cycles, # but not every edges that consist the negative cycles is stored. # time complexity: O(VE + (V^2)) def bellman_ford(adj, w, s): d, parent = initialize_int(adj, s) # calculate shortest paths for _ in range(len(adj)): for vertex in range(len(adj)): for neighbor in adj[vertex]: relax(d, w, vertex, neighbor, parent) # detects negative cycles if exist negative_cycle_edges = set() for vertex in range(len(adj)): for neighbor in adj[vertex]: if d[neighbor] > d[vertex] + w[vertex][neighbor]: negative_cycle_edges.add((vertex, neighbor)) return d, parent, negative_cycle_edges V, E, r = [int(elem) for elem in fin().split()] adj = [[] for _ in range(V)] w = [[None] * V for _ in range(V)] for _ in range(E): s, t, d = [int(elem) for elem in fin().split()] adj[s].append(t) w[s][t] = d d, parent, negative_cycle_edges = bellman_ford(adj, w, r) if len(negative_cycle_edges) > 0: print("NEGATIVE CYCLE") else: for i in range(V): print("INF") if d[i] == MAX_NUM else print(d[i])
Single Source Shortest Path (Negative Edges)
[{"input": "4 5 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "0\n 2\n -3\n -1"}, {"input": "4 6 0\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2\n 3 1 0", "output": "NEGATIVE CYCLE"}, {"input": "4 5 1\n 0 1 2\n 0 2 3\n 1 2 -5\n 1 3 1\n 2 3 2", "output": "INF\n 0\n -5\n -3"}]
If there is no sequence of N operations after which a would be equal to b, print `-1`. If there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted. * * *
s038498237
Wrong Answer
p03089
Input is given from Standard Input in the following format: N b_1 \dots b_N
print(-1)
Statement Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
[{"input": "3\n 1 2 1", "output": "1\n 1\n 2\n \n\nIn this sequence of operations, the sequence a changes as follows:\n\n * After the first operation: (1)\n * After the second operation: (1,1)\n * After the third operation: (1,2,1)\n\n* * *"}, {"input": "2\n 2 2", "output": "-1\n \n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\n* * *"}, {"input": "9\n 1 1 1 2 2 1 2 3 2", "output": "1\n 2\n 2\n 3\n 1\n 2\n 2\n 1\n 1"}]
If there is no sequence of N operations after which a would be equal to b, print `-1`. If there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted. * * *
s477370140
Wrong Answer
p03089
Input is given from Standard Input in the following format: N b_1 \dots b_N
print(1)
Statement Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
[{"input": "3\n 1 2 1", "output": "1\n 1\n 2\n \n\nIn this sequence of operations, the sequence a changes as follows:\n\n * After the first operation: (1)\n * After the second operation: (1,1)\n * After the third operation: (1,2,1)\n\n* * *"}, {"input": "2\n 2 2", "output": "-1\n \n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\n* * *"}, {"input": "9\n 1 1 1 2 2 1 2 3 2", "output": "1\n 2\n 2\n 3\n 1\n 2\n 2\n 1\n 1"}]
If there is no sequence of N operations after which a would be equal to b, print `-1`. If there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted. * * *
s196812064
Wrong Answer
p03089
Input is given from Standard Input in the following format: N b_1 \dots b_N
def checkJ(lst): good_jlist = [] for i in range(len(lst)): if lst[len(lst) - i - 1] == len(lst) - i: good_jlist.append(len(lst) - i - 1) return good_jlist def subJ(lst, j): return lst[:j] + lst[j + 1 :] n = int(input()) s = [int(i) for i in input().split()] stack_list = [] stack_list.append([s, checkJ(s)]) notfound = 0 applylist = [] while True: # 調べる番号がない場合 if not stack_list[0][0]: notfound = 2 break while not stack_list[0][1]: stack_list.pop(0) if not stack_list: notfound = 1 break if not stack_list[0][0]: notfound = 2 break # 調べるリストがない場合 if notfound == 1 or notfound == 2: break currentStr = stack_list[0][0] applylist = applylist[: int(int(n) - len(currentStr))] currentCheckNum = stack_list[0][1].pop(0) if currentCheckNum == 0 and len(currentStr) > 1: continue nextStr = subJ(currentStr, currentCheckNum) if checkJ(s): stack_list.insert(0, [nextStr, checkJ(nextStr)]) applylist.append(currentCheckNum + 1) # print("current list") # print(stack_list) if notfound == 1: print("-1") elif notfound == 2: for i in range(len(applylist)): print(applylist[int(n) - i - 1])
Statement Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
[{"input": "3\n 1 2 1", "output": "1\n 1\n 2\n \n\nIn this sequence of operations, the sequence a changes as follows:\n\n * After the first operation: (1)\n * After the second operation: (1,1)\n * After the third operation: (1,2,1)\n\n* * *"}, {"input": "2\n 2 2", "output": "-1\n \n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\n* * *"}, {"input": "9\n 1 1 1 2 2 1 2 3 2", "output": "1\n 2\n 2\n 3\n 1\n 2\n 2\n 1\n 1"}]
If there is no sequence of N operations after which a would be equal to b, print `-1`. If there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted. * * *
s534137012
Runtime Error
p03089
Input is given from Standard Input in the following format: N b_1 \dots b_N
N = int(input()) b = input() def func(a, n): if not a: return n for i in range(1, len(a)+1): if a[i-1] == i: func(a[:i-1]+a[i:], n+1) return -1 print(func(n, 0)
Statement Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
[{"input": "3\n 1 2 1", "output": "1\n 1\n 2\n \n\nIn this sequence of operations, the sequence a changes as follows:\n\n * After the first operation: (1)\n * After the second operation: (1,1)\n * After the third operation: (1,2,1)\n\n* * *"}, {"input": "2\n 2 2", "output": "-1\n \n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\n* * *"}, {"input": "9\n 1 1 1 2 2 1 2 3 2", "output": "1\n 2\n 2\n 3\n 1\n 2\n 2\n 1\n 1"}]
If there is no sequence of N operations after which a would be equal to b, print `-1`. If there is, print N lines. In the i-th line, the integer chosen in the i-th operation should be printed. If there are multiple solutions, any of them is accepted. * * *
s757145393
Wrong Answer
p03089
Input is given from Standard Input in the following format: N b_1 \dots b_N
n = int(input()) A = list(map(int, input().split())) print(-1)
Statement Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
[{"input": "3\n 1 2 1", "output": "1\n 1\n 2\n \n\nIn this sequence of operations, the sequence a changes as follows:\n\n * After the first operation: (1)\n * After the second operation: (1,1)\n * After the third operation: (1,2,1)\n\n* * *"}, {"input": "2\n 2 2", "output": "-1\n \n\n2 cannot be inserted at the beginning of the sequence, so this is impossible.\n\n* * *"}, {"input": "9\n 1 1 1 2 2 1 2 3 2", "output": "1\n 2\n 2\n 3\n 1\n 2\n 2\n 1\n 1"}]
Among A, B and C, print the integer that is different from the rest. * * *
s686642630
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=list(map(int,input().split())) if a==b: print(c) elif b==c: print(a) eles: print(b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s507828362
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) if a==b: ans=c elif b==c: ans=a: else: ans=b print(a+b+c-ans)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s125338718
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a, b, c = map(int, input().split()) print(a if a not in [b, c] else b if b not in [a, c] else c if c not in [a, b])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s260285777
Accepted
p03573
Input is given from Standard Input in the following format: A B C
#!/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 bisect_left = bisect.bisect_left bisect_right = bisect.bisect_right 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 inf = float("INF") # A def A(): a, b, c = LI() if a == b: print(c) if b == c: print(a) if a == c: print(b) return # B def B(): return # C def C(): 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__": A()
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s229619763
Accepted
p03573
Input is given from Standard Input in the following format: A B C
tmp = input().split(" ") if tmp[0] == tmp[1]: print(tmp[2]) elif tmp[0] == tmp[2]: print(tmp[1]) else: print(tmp[0])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s472190759
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
import copy def set(adjacent, edge): for x in edge: adjacent[x[0]].append(x[1]) adjacent[x[1]].append(x[0]) def search(goal, path): n = path[len(path) - 1] if n == goal: print(path) else: for x in adjacent[n]: if x not in path: path.append(x) search(goal, path) path.pop() def search_loop_node(adjacent, start, path, node_loops): n = path[len(path) - 1] for x in adjacent[n]: if x == start and len(path) >= 2 and path[-2] != start: path.append(x) node_loops.append(copy.deepcopy(path)) path.pop() elif x not in path: path.append(x) search_loop_node(adjacent, start, path, node_loops) path.pop() def main(): # 入力 N, M = [int(i) for i in input().split()] edge = [] for i in range(M): a, b = [int(i) for i in input().split()] edge.append([a, b]) # 辺の生成 adjacent = [[] for i in range(N + 1)] loops = [] set(adjacent, edge) # ループの検索 for i in range(N): search_loop_node(adjacent, i, [i], loops) # ループに属する辺(橋でない辺)の検索 not_bridge = [] for loop in loops: pre_node = loop[0] for node in loop: if pre_node < node and [pre_node, node] not in not_bridge: not_bridge.append([pre_node, node]) pre_node = node # 答えは全体の辺の数からループでないものを引いた数 print(M - len(not_bridge)) if __name__ == "__main__": main()
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s806783443
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
from collections import deque h, w = map(int, input().split()) hw = [list(input()) for _ in range(h)] for i in range(h): for j in range(w): if hw[i][j] == ".": cnt = 0 for x in [-1, 0, 1]: for y in [-1, 0, 1]: if i + y in range(h) and j + x in range(w): if hw[i + y][j + x] == "#": cnt += 1 hw[i][j] = cnt for line in hw: print("".join(list(map(str, line))))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s130022794
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
n, k = map(int, input().split()) l = [list(map(int, input().split())) for i in range(n)] x = [l[i][0] for i in range(n)] x.sort() y = [l[i][1] for i in range(n)] y.sort() ans = [] for i1 in range(n): for i2 in range(n): for i3 in range(n): for i4 in range(n): ct = 0 for i5 in range(n): if min(x[i1], x[i2]) <= l[i5][0] <= max(x[i1], x[i2]) and min( y[i3], y[i4] ) <= l[i5][1] <= max(y[i3], y[i4]): ct += 1 if ct >= k: ans.append(abs(x[i1] - x[i2]) * abs(y[i3] - y[i4])) print(min(ans))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s035629097
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
N, K = map(int, input().split()) data = [list(map(int, input().split())) for _ in range(N)] ans = 10**19 for a in range(N): for b in range(N): for c in range(N): for d in range(N): x0 = data[a][0] x1 = data[b][0] y0 = data[c][1] y1 = data[d][1] if x0 < x1 and y0 < y1: count = 0 for i, j in data: if x0 <= i <= x1 and y0 <= j <= y1: count += 1 if count >= K: ans = min(ans, (x1 - x0) * (y1 - y0)) print(ans)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s721553511
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
# coding: utf-8 # hello worldと表示する # float型を許すな # numpyはpythonで import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left, bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil, pi, factorial from operator import itemgetter def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def LI2(): return [int(input()) for i in range(n)] def MXI(): return [[LI()] for i in range(n)] def SI(): return input().rstrip() def printns(x): print("\n".join(x)) def printni(x): print("\n".join(list(map(str, x)))) inf = 10**17 mod = 10**9 + 7 n, k = MI() lis = [LI() for i in range(n)] lis.sort() s = [] for i in range(n): for j in range(n): for k in range(n): for l in range(n): xl = min(lis[i][0], lis[j][0]) xu = max(lis[i][0], lis[j][0]) yl = min(lis[k][1], lis[l][1]) yu = max(lis[k][1], lis[l][1]) count = 0 for m in range(n): if xl <= lis[m][0] <= xu and yl <= lis[m][1] <= yu: count += 1 if count >= k: s.append((xu - xl) * (yu - yl)) print(max(s))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s975743526
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
def bakudanda(y, x): if y < 0 or y >= len(s): return 0 if x < 0 or x >= len(s[y]): return 0 if s[y][x] == "#": return 1 else: return 0 H, W = map(int, input().split()) s = [] for i in range(H): s.append(input()) for i in range(len(s)): a = s[i] fp = "" for j in range(len(a)): if a[j] == ".": c = 0 ds = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] for y, x in ds: c += bakudanda(i + y, j + x) fp += str(c) else: fp += "#" print(fp)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s707766832
Accepted
p03573
Input is given from Standard Input in the following format: A B C
l = sorted(list(map(int, input().split()))) print(l[0] if l[1] == l[2] else l[2])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s619705904
Accepted
p03573
Input is given from Standard Input in the following format: A B C
print(eval(input().replace(*" ^")))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s630118171
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) print(a if b=c else b if a=c else c)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s856713508
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a, b, c = map(int, input().split()) print(a if b == c else b if a == c else c if a == b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s833618918
Wrong Answer
p03573
Input is given from Standard Input in the following format: A B C
import numpy as numpy n = numpy.zeros(5, dtype="int8")
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s015416213
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) if a==b: print(c) elif b==c: print(a): else: print(b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s355084726
Wrong Answer
p03573
Input is given from Standard Input in the following format: A B C
eval(input().replace(*" ^"))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s584414719
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
# 75b H, W = map(int, input().split()) S_list = [[0 for i in range(W + 2)] for j in range(H + 2)] for i in range(1, H + 1): S = list(input()) S_list[i][1 : W + 1] = S ans = [["#" for i in range(W + 2)] for j in range(H + 2)] for i in range(1, H + 1): for j in range(1, W + 1): if S_list[i][j] != "#": ans[i][j] = ( S_list[i - 1][j - 1 : j + 2].count("#") + S_list[i][j - 1 : j + 2].count("#") + S_list[i + 1][j - 1 : j + 2].count("#") ) for i in range(1, H + 1): print("".join(map(str, ans[i][1:-1])))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s865603545
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
n, k = map(int, input().split()) x = [0 for _ in range(n)] y = [0 for _ in range(n)] for i in range(n): x[i], y[i] = map(int, input().split()) min_x = min(x) min_y = min(y) for i in range(n): x[i] -= min_x y[i] -= min_y sx = sorted(x) sy = sorted(y) if n == k: print(sx[n - 1] * sy[n - 1]) exit() d = [[0 for _ in range(n + 1)] for _ in range(n + 1)] for i in range(n): d[sx.index(x[i]) + 1][sy.index(y[i]) + 1] = 1 # for p in d: print(p) for i in range(n + 1): for j in range(1, n + 1): d[i][j] += d[i][j - 1] for i in range(n + 1): for j in range(1, n + 1): d[j][i] += d[j - 1][i] sx = [0] + sx sy = [0] + sy a = 0 b = 1 ans = sx[n] * sy[n] temp = 0 for p in range(n): for q in range(p + 1, n + 1): for a in range(n): for b in range(a + 1, n + 1): temp = d[q][b] - d[q][a] - d[p][b] + d[p][a] if temp >= k: break if temp >= k: ans = min( ans, max(1, (sx[b] - sx[a + 1])) * max(1, (sy[q] - sy[p + 1])) ) print(ans)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s375031509
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
h, w = map(int, input().split()) s = [list(input() for i in range(h))] t = s.copy() number = [] cnt = 0 for i in range(h): if 1 <= i and i <= h - 2: for j in range(w): if j >= 1 and j < w - 1: number = [ s[i - 1][j - 1], s[i - 1][j], s[i - 1][j + 1], s[i][j - 1], s[i][j + 1], s[i + 1][j - 1], s[i + 1][j], s[i + 1][j + 1], ] cnt = number.count("#") t[i][j] = cnt elif j == 0: number = [s[i - 1][0], s[i + 1][0], s[i - 1][1], s[i][1], s[i + 1][1]] cnt = number.count("#") t[i][0] = cnt elif j == w - 1: number = [ s[i - 1][w - 1], s[i + 1][w - 1], s[i - 1][w - 2], s[i][w - 2], s[i + 1][w - 2], ] cnt = number.count("#") t[i][w - 1] = cnt elif i == 0: for j in range(w): if 1 <= j and j <= w - 2: number = [s[0][j - 1], s[0][j + 1], s[1][j - 1], s[1][j], s[1][j + 1]] cnt = number.count("#") t[0][j] = cnt elif j == 0: number = [s[0][1], s[1][0], s[1][1]] cnt = number.count("#") t[0][0] = cnt elif j == w - 1: number = [s[0][w - 2], s[1][w - 2], s[1][w - 1]] cnt = number.count("#") t[0][w - 1] = cnt elif i == h - 1: for j in range(w): if 1 <= j and j <= w - 2: number = [ s[h - 1][j - 1], s[h - 1][j + 1], s[h - 2][j - 1], s[h - 2][j], s[h - 2][j + 1], ] cnt = number.count("#") t[h - 1][j] = cnt elif j == 0: number = [s[h - 1][1], s[h - 2][1], s[h - 2][0]] cnt = number.count("#") t[h - 1][0] = cnt elif j == w - 1: number = [s[h - 2][w - 1], s[h - 1][w - 2], s[h - 2][w - 2]] cnt = number.count("#") t[h - 1][w - 1] = cnt for i in range(h): for j in range(w): if s[i][j] == "#": t[i][j] = "#" a0 = map(str, t[0]) a1 = map(str, t[1]) a2 = map(str, t[2]) print("".join(a0)) print("".join(a1)) print("".join(a2))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s221676161
Accepted
p03573
Input is given from Standard Input in the following format: A B C
a, b, c = [int(x) for x in input().split()] l = sorted([a, b, c]) print(l[0]) if l[0] != l[1] else print(l[2])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s204981856
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c = map(int,input().split()) if a ==b: print(c) elif a==c: print(b) else print(a)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s860687894
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input(),split()) if a ==b: print(c) elce: if a == c: print(b) else: print(a)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s539044223
Accepted
p03573
Input is given from Standard Input in the following format: A B C
numbers = list(map(int, input().split())) for i in numbers: if numbers.count(i) == 1: print(i)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s029701645
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
# -*- coding: utf-8 -*- A,B,C =map(int,input().split()) if A == B: print(C) elif B == C: print(A) else: print()B
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s458037864
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
l=list(map(int,input().split())) if(l[0]==l[1]): print(l[2]) elif(l[1]==l[2]): print(l[0]): else:print(l[1])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s274330959
Accepted
p03573
Input is given from Standard Input in the following format: A B C
a, b, c = input().split(" ") if a == b and a != c: print(str(c)) elif a == c and a != b: print(str(b)) elif b == c and b != a: print(str(a))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s816091799
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
h, w = map(int, input().split()) s = [input() for i in range(h)] for i in range(h): l = "" for j in range(w): if s[i][j] == "#": l += "#" else: l += str( sum( [ t[max(0, j - 1) : min(w, j + 2)].count("#") for t in s[max(0, i - 1) : min(h, i + 2)] ] ) ) print(l)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s980487369
Wrong Answer
p03573
Input is given from Standard Input in the following format: A B C
s = list(input().split()) if s[0] == s[1]: print(int(s[2])) elif s[1] == s[2]: print(int(s[0])) else: print(int(s[0]))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s944114193
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c = [int(i) for i in input().split()] if ([a,b,c].count(a) = 1) : print(a) elif ([a,b,c].count(b) = 1) : print(b) else : print(c)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s986676343
Accepted
p03573
Input is given from Standard Input in the following format: A B C
s = sorted(input().split()) print([s[0], s[2]][s[0] == s[1]])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s991897667
Accepted
p03573
Input is given from Standard Input in the following format: A B C
a = sorted([int(i) for i in input().split()]) print(a[0] if a.count(a[0]) == 1 else a[2])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s999152767
Accepted
p03573
Input is given from Standard Input in the following format: A B C
n, m, k = map(int, input().split()) if n == m: print(k) elif n == k: print(m) else: print(n)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s929162966
Accepted
p03573
Input is given from Standard Input in the following format: A B C
numlist = list(input().split()) print(sorted(numlist, key=lambda x: numlist.count(x))[0])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s513541868
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) print(a if b==c else b if a==c else c if a==b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s362343782
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a = input().list() a = sorted(a) print(a[2])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s167126586
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=map(int,input().split()) if a==b: print(c) elif b==c print(a) else: print(b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s611721177
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a, b, c=map(int, input().split()) if a==b: print(c) elif b=c: print(a) else: print(b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s029665888
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c = map(int, input().split()) if a==b: print(c) elif a==c: print(b) else b==c: print(a)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s670316092
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a, b, c = map(int, input().split()) if a = b: input(c) elif b = c: input(a) else: input(b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s799197080
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c=map(jnt,input().split()) if a=b: print(c) elif b=c: print(a) else: print(b)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s091772326
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
a,b,c = map(int,input().split()) if a == b print(c) else if a == c print(b) else if b == c print(a)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s515001821
Wrong Answer
p03573
Input is given from Standard Input in the following format: A B C
lst = list(input()) for s in lst: if lst.count(s) == 1: print(s) break
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s417203777
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
A, B, C = map(int, input().split())) if A == B: print(C) elif B == C: print(A) else: print(B)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s512682859
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
n = list(map(int,input().split(' '))) ans = i if i.count(dict.fromkeys(n))==1 for i in n print(str(ans))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s945329750
Wrong Answer
p03573
Input is given from Standard Input in the following format: A B C
x = list(map(int, input().split())) result = None for i in set(x): if x.count(i) > 1: result = i print(result)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s335292914
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
l=map(int,input().split()) if(l[0]==l[1]): print(l[2]) elif(l[1]==l[2]): print(l[0]): else:print(l[1])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s133738235
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
A, B, C = list(map(int, input().split())) if A == B: print(C) elif A == C print(B) else: print(A)
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s208869841
Runtime Error
p03573
Input is given from Standard Input in the following format: A B C
n = list(map(int,input().split(' '))) ans = i if n.count(i)==1 for i in list(dict.fromkeys(n)) print(str(ans))
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s419410221
Accepted
p03573
Input is given from Standard Input in the following format: A B C
# 075 A Ts = [int(j) for j in input().split()] for i in range(len(Ts)): if Ts.count(Ts[i]) == 1: print(Ts[i])
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]
Among A, B and C, print the integer that is different from the rest. * * *
s358419048
Accepted
p03573
Input is given from Standard Input in the following format: A B C
import sys def main(): # Get Args args = _input_args() # get arguments as an array from console/script parameters. # Call main Logic result = _main(args) # Output a result in a correct way. _output_result(result) def _main(args): """Write Main Logic here for the contest. :param args: arguments :type args: list :return: result :rtype: depends on your logic. """ hash = HashMap() for value in args: hash.add(value) # Return something. return hash.find_unique() class HashMap(object): def __init__(self): self.map = {} def add(self, value): if self.map.get(value) is None: self.map[value] = [value] else: self.map[value].append(value) def find_unique(self): for value, array in self.map.items(): if len(array) == 1: return array[0] def _input_args(): arguments = ( _input().split() ) # ptn2: get args from 1 line console prompt with space separated. return arguments # This will be array. def _input(): # If Subject requires interactive input, use this and patch mock in unittest. return input() # Change if necessary. def _output_result(result): print("{}".format(str(result))) # Same as above, but more versatile. if __name__ == "__main__": main()
Statement You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
[{"input": "5 7 5", "output": "7\n \n\nThis is the same case as the one in the statement.\n\n* * *"}, {"input": "1 1 7", "output": "7\n \n\nIn this case, C is the one we seek.\n\n* * *"}, {"input": "-100 100 100", "output": "-100"}]