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 |
|---|---|---|---|---|---|---|---|
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s005583921 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | from collections import deque
A, B, K = input().split()
A = int(A)
B = int(B)
K = int(K)
value = deque()
s = [i for i in range(A, B + 1)]
value.extend(s[0:K])
value.extend(s[len(s) - K : len(s)])
num = list(set(value))
for i in range(len(num)):
print(num[i])
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s007792147 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = input()
S.sort()
if S = "abc":
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s155531232 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | A, B, K = (int(i) for i in input().split())
low = range(A, A + K)
high = range(B, B - K, -1)
t = sorted(list(set(low) | set(high)))
for s in t:
if s >= A and s <= B:
print(s)
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s819095373 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = input()
if (S=="abc") or (S=="bca") or (S=="cba") or (S=="acb") or (S=="bac") or (S=="cab")
print("Yes")
else
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s780956920 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | #!/usr/bin/env python3
import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random # random, uniform, randint, randrange, shuffle, sample
# import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict # subclass of dict. defaultdict(facroty)
# from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce # reduce(f, iter[, init])
# from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate # accumulate(iter[, f])
# from operator import itemgetter # itemgetter(1), itemgetter('key')
# from fractions import gcd # for Python 3.4 (previous contest @AtCoder)
def main():
mod = 1000000007 # 10^9+7
inf = float("inf") # sys.float_info.max = 1.79...e+308
# inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19
sys.setrecursionlimit(10**6) # 1000 -> 1000000
def input():
return sys.stdin.readline().rstrip()
def ii():
return int(input())
def mi():
return map(int, input().split())
def mi_0():
return map(lambda x: int(x) - 1, input().split())
def lmi():
return list(map(int, input().split()))
def lmi_0():
return list(map(lambda x: int(x) - 1, input().split()))
def li():
return list(input())
s = input()
(
print("Yes")
if s.count("a") == 1 and s.count("b") == 1 and s.count("c") == 1
else print("No")
)
if __name__ == "__main__":
main()
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s864552881 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | t = int(input())
for i in range(t):
k = input().split()
a = int(k[0])
b = int(k[1])
c = a * b
d = int(c**0.5)
print(2 * d - 1 - ((d * d) == c) - (c == d * d and a != b))
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s121861160 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s = input()
for c in s:
if c == 'a':
r = 1
if c == 'b':
r = 2
if c == 'c':
r = 4
if r = 7:
print('Yes')
else:
print('No') | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s132511983 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if "".join(sorted(list(str(input())))) == "abc" else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s021066881 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print("No" if len(set(input())) != 3 else "Yes")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s065277335 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | A = input()
print("Yes" if "".join(sorted(A)) == "abc" else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s149699839 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if set(input()) == set(["a", "b", "c"]) else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s252423247 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print("Yes") if len(set(list(input()))) == 3 else print("No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s282615161 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if len(set(input()[:])) == 3 else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s851185813 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print(["Yes", "No"][not (3 == len(set(input())))])
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s203526909 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if set(input()) == set("abc") else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s194675210 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if sorted(list(input())) == ["a", "b", "c"] else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s579603500 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s=input()
if "".join(sorted(s)=="abc":
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s200729666 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | print(["Yes","No"][len(set(input())<3]) | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s472882952 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s = input().sort()
print("Yes") if s = "abc" else print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s008645013 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if all(input().count(t) > 0 for t in "abc") else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s825117134 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | print('Yes' len(set(input())) == 3 else 'No') | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s173904417 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S=set(input())
print("Yes" len(S)==3 else "No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s577815607 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | n=input()
n.sort()
if n="abc":
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s924851114 | Wrong Answer | p03385 | Input is given from Standard Input in the following format:
S | print("YES" if len(set(input())) == 3 else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s787363181 | Wrong Answer | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if "a" and "b" and "c" in input() else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s195173754 | Wrong Answer | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if len(input()) == 3 else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s640026195 | Wrong Answer | p03385 | Input is given from Standard Input in the following format:
S | print("YNeos"[sorted(input()) == "abc" :: 2])
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s854697428 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s=list(input())
if a,b,c in n:
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s686169685 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s = input()
print((s in 'a') and (s in 'b') and (s in 'c') ? 'Yes' : 'No')
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s360138151 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if sorted(input()).join("") == "abc" else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s775338881 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | print("YNeos"["".join(input().sort()) != "abc" :: 2])
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s118260270 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | s = list(input())
s2 = list("abc")
a = set(s) & set(s2)
print("Yes") if len(a) == 3 else print("No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s001303226 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = input()
if(S[0] != S[1] && S[1] != S[2] && S[2] != S[0]):
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s002284089 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = input()
if S[0] != S[1] && S[1] != S[2] && S[2] != S[0]:
print("Yes")
else:
print("No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s317581869 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S=input()
print( "Yes" if S in "abc" or S in "bca" or S in "acb" S in "cab" or S in "cba" or S in "bac" else "No" ) | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s588652453 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = input()
If “a” in S and “b” in S and “c” in S:
print(“Yes”)
else:
print(“No”) | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s883510063 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = input()
if “a” in S and “b” in S and “c” in S:
print(“Yes”)
else:
print(“No”)
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s066331727 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s = input()
print("Yes" s.count("a") == 1 and s.count("b") == 1 and s.count("c") == 1 else "No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s117392637 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | s = list(str(input()))
print("YNeos"["a" not in s or "b" not in s or "c" not in s :: 2])
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s285836044 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | def a:return "Yes" if "".join(sorted(list(input())))=="abc" else "No"
print(a()) | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s644554572 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = str(input())
if "a" in S and "b" in S and "c" in S:
print("Yes")
else ;
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s846521091 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s = input()
if "a" in s ans "b" in s and "c" in s:
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s775136414 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s = set(list(int(input())))
if s = {'a','b','c'}:
print('Yes')
else:
print('No') | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s922388350 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s = input
if s.count("a") == 1 ans s.count("b") == 1:
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s720051294 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | import sys
#+++++
def main():
s = input()
a = ''.join(sorted(s)) == 'abc'
if a:
print('Yes')
else:
print('No')
#print(' '.join([str(v) for v in l]))
#+++++
if __name__ == "__main__":
if sys.platform =='ios':
sys.stdin=open('inputFile.txt')
else:
#input = sys.stdin.readline
pass
ret = main()
if ret is not None:
print(ret) | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s472406642 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = input()
if "a" not in S:
print("No")
exit()
if "b" not in S:
print("No")
exit()
if "c" not in S:
print("No")
exit()
print("Yes") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s190056386 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | a, b, k = map(int, input().split())
li = list(range(a, b + 1))
li2 = []
for l in li[:k]:
li2.append(l)
for l in li[-k:]:
li2.append(l)
set(li2)
for ll in li2:
print(ll)
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s176477693 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | # -*- coding: utf-8 -*-
# 入力
S = list(input())
# 処理
S = list.join(S.sort())
if S = "abc":
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s513886696 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = input()
if S = "abc" or S = "acb" or S = "bac" or S = "bca" or S = "cab" or S = "cba":
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s779283235 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | a, b, k = map(int, input().split())
inte = []
if k >= (b - a + 1) // 2:
k = (b - a + 1) // 2
for i in range(a, a + k):
inte.append(i)
for i in range(b - k + 1, b + 1):
inte.append(i)
for i in range(len(set(inte))):
print(list(set(inte))[i])
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s843593745 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | # coding : utf-8
import numpy as np
A = input()
if(A[0]!=A[1] and A[0]!=A[2] and A[1]!=A[2])
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s380538040 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s=input()
flag=0
if s = "abc":
flag=1
elif s = "acb":
flag=1
elif s = "bac":
flag=1
elif s = "bca":
flag=1
elif s = "cab":
flag=1
elif s = "cba":
flag=1
if flag:
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s371964992 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | # coding:utf-8
n = [int(i) for i in input().split()]
if n[1] - n[0] + 1 <= 2 * n[2]:
for i in range(n[0], n[1] + 1):
print(i)
else:
for j in range(n[0], n[0] + n[2]):
print(j)
for k in range(n[1] - n[2] + 1, n[1] + 1):
print(k)
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s183262237 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | import sys
#+++++
def main():
s = input()
a = ''.join(sorted(s)) == 'abc'
if a:
print('Yes')
else:
print('No')
#print(' '.join([str(v) for v in l]))
#+++++
if __name__ == "__main__":
if sys.platform =='ios':
sys.stdin=open('inputFile.txt')
else:
#input = sys.stdin.readline
ret = main()
if ret is not None:
print(ret) | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s352716874 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | import collections
abc = input().strip()
c = collections.Counter(abc)
if c['a']==1 and c['b' ==1 and c['c' == 1:
print("Yes")
else:
print("No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s197288660 | Wrong Answer | p03385 | Input is given from Standard Input in the following format:
S | S = "".join(sorted(list(input())))
print("YES" if S == "abc" else "NO")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s761898965 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S |
a, b, c = input()
print("Yes" if set(a,b,c)=("a", "b", "c") else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s500536377 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | numList = input().split()
numList = list(map(int, numList))
commandList = [[2, 0, 0], [0, 2, 0], [0, 0, 2], [0, 1, 1], [1, 0, 1], [1, 1, 0]]
numListList = [numList]
def search(depth):
global numListList
tmpList = []
for numList in numListList:
for command in commandList:
sumedList = sumList(numList, command)
if check(sumedList, depth + 1):
return
tmpList.append(sumedList)
numListList = tmpList
search(depth + 1)
def sumList(list1, list2):
return [list1[0] + list2[0], list1[1] + list2[1], list1[2] + list2[2]]
def check(numList, count):
if numList[0] == numList[1] and numList[1] == numList[2]:
print(count)
return True
if numList[0] == numList[1]:
return check2(numList[0], numList[2], count)
if numList[1] == numList[2]:
return check2(numList[1], numList[0], count)
if numList[0] == numList[2]:
return check2(numList[0], numList[1], count)
return False
def check2(num1, num2, count):
if num1 > num2:
if (num1 - num2) % 2 == 0:
print(int(count + (num1 - num2) / 2))
return True
else:
print(int(count + (num1 - num2) / 2) + 2)
return True
else:
print(int(count + (num2 - num1)))
return True
if check(numList, 0):
pass
else:
search(0)
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s885165075 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | x, y, z = map(int, input().split())
a = max(x, y, z)
b = min(x, y, z)
c = x + y + z - a - b
if (a - b) % 2 == 0:
d = (a - b) / 2
if (a - c) % 2 == 0:
print(int((a - c) / 2 + d))
else:
print(int((a - 1 - c) / 2 + d + 2))
else:
e = (a - b - 1) / 2
if (a - c) % 2 == 0:
print(int((a - c) / 2 + 2 + e))
else:
print(int((a - 1 - c) / 2 + 1 + e))
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s654994392 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | A, B, C = sorted(map(int, input().split()))
def calculate(P, Q, R):
num = 0
if abs(P - Q) % 2 == 0:
num += abs(P - Q) // 2
else:
num += 1 + (abs(P - Q) + 1) // 2
P += 1
R += 1
if abs(P - R) % 2 == 0:
num += abs(P - R) // 2
else:
num += 1 + (abs(P - R) + 1) // 2
return num
ans = min(calculate(C, B, A), calculate(C, A, B), calculate(B, A, C))
print(ans)
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s535882380 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print(["No", "Yes"][len(set(list(input()))) == 3])
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s013364318 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print("YNeos"[sorted(input()) != list("abc") :: 2])
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s175516568 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | r = set(list(input()))
print("No" if len(r) != 3 else "Yes")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s338924832 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | print("Yes" if len(set(list(input()))) == 3 else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s927939570 | Wrong Answer | p03385 | Input is given from Standard Input in the following format:
S | print("yes" if len(set(input())) == 3 else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s526715648 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | print('Yes' if ''join(sorted.input())=='abc' else 'No' ) | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s242826636 | Wrong Answer | p03385 | Input is given from Standard Input in the following format:
S | x = input()
print(["No", "Yes"][(x[0] in "abc") * (x[1] in "abc") * (x[2] in "abc")])
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s998961114 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = input()
A = S.count('a')
B = S.count('b')
C = S.count('c')
if a == b == c == 1:
print('Yes')
else
:
print('No') | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s316640605 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if a*b*c == 1:
print('Yse')
else;
print('No') | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s889126728 | Accepted | p03385 | Input is given from Standard Input in the following format:
S | # abc of ABC
print("Yes" if input() in ["abc", "acb", "bac", "bca", "cab", "cba"] else "No")
| Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s585887547 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | s = input()
s = sorted(s)
if s = ['a','b','c']:
print('Yes')
else:
print('No') | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
If S can be obtained by permuting `abc`, print `Yes`; otherwise, print `No`.
* * * | s447476671 | Runtime Error | p03385 | Input is given from Standard Input in the following format:
S | S = list(input())
if S = "abc" or S = "acb" or S = "bac" or S = "bca" or S = "cab" or S = "cba":
print("Yes")
else:
print("No") | Statement
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine
if S can be obtained by permuting `abc`. | [{"input": "bac", "output": "Yes\n \n\nSwapping the first and second characters in `bac` results in `abc`.\n\n* * *"}, {"input": "bab", "output": "No\n \n\n* * *"}, {"input": "abc", "output": "Yes\n \n\n* * *"}, {"input": "aaa", "output": "No"}] |
Print the number of pairs (i, j) (i < j) such that the distance between the
i-th point and the j-th point is an integer.
* * * | s155672542 | Accepted | p02982 | Input is given from Standard Input in the following format:
N D
X_{11} X_{12} ... X_{1D}
X_{21} X_{22} ... X_{2D}
\vdots
X_{N1} X_{N2} ... X_{ND} | #
# abc133 b
#
import sys
from io import StringIO
import unittest
from math import sqrt
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """3 2
1 2
5 5
-2 8"""
output = """1"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """3 4
-3 7 8 2
-12 1 10 2
-2 8 9 3"""
output = """2"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """5 1
1
2
3
4
5"""
output = """10"""
self.assertIO(input, output)
def resolve():
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i, x1 in enumerate(X):
for x2 in X[i + 1 :]:
tmp = 0
for j in range(D):
tmp += (x2[j] - x1[j]) ** 2
tmp = sqrt(tmp)
if tmp.is_integer() == True:
ans += 1
print(ans)
if __name__ == "__main__":
# unittest.main()
resolve()
| Statement
There are N points in a D-dimensional space.
The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).
The distance between two points with coordinates (y_1, y_2, ..., y_D) and
(z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D -
z_D)^2}.
How many pairs (i, j) (i < j) are there such that the distance between the
i-th point and the j-th point is an integer? | [{"input": "3 2\n 1 2\n 5 5\n -2 8", "output": "1\n \n\nThe number of pairs with an integer distance is one, as follows:\n\n * The distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n * The distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n * The distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\n* * *"}, {"input": "3 4\n -3 7 8 2\n -12 1 10 2\n -2 8 9 3", "output": "2\n \n\n* * *"}, {"input": "5 1\n 1\n 2\n 3\n 4\n 5", "output": "10"}] |
Print the number of pairs (i, j) (i < j) such that the distance between the
i-th point and the j-th point is an integer.
* * * | s381737471 | Accepted | p02982 | Input is given from Standard Input in the following format:
N D
X_{11} X_{12} ... X_{1D}
X_{21} X_{22} ... X_{2D}
\vdots
X_{N1} X_{N2} ... X_{ND} | f = lambda: map(int, input().split())
n, d = f()
ll = [list(f()) for _ in range(n)]
a = 0
for j in range(n):
for i in range(j):
a += sum((ll[i][k] - ll[j][k]) ** 2 for k in range(d)) ** 0.5 % 1 == 0
print(a)
| Statement
There are N points in a D-dimensional space.
The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}).
The distance between two points with coordinates (y_1, y_2, ..., y_D) and
(z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D -
z_D)^2}.
How many pairs (i, j) (i < j) are there such that the distance between the
i-th point and the j-th point is an integer? | [{"input": "3 2\n 1 2\n 5 5\n -2 8", "output": "1\n \n\nThe number of pairs with an integer distance is one, as follows:\n\n * The distance between the first point and the second point is \\sqrt{|1-5|^2 + |2-5|^2} = 5, which is an integer.\n * The distance between the second point and the third point is \\sqrt{|5-(-2)|^2 + |5-8|^2} = \\sqrt{58}, which is not an integer.\n * The distance between the third point and the first point is \\sqrt{|-2-1|^2+|8-2|^2} = 3\\sqrt{5}, which is not an integer.\n\n* * *"}, {"input": "3 4\n -3 7 8 2\n -12 1 10 2\n -2 8 9 3", "output": "2\n \n\n* * *"}, {"input": "5 1\n 1\n 2\n 3\n 4\n 5", "output": "10"}] |
If the objective is achievable, print the minimum necessary number of
operations. Otherwise, print `-1` instead.
* * * | s003874657 | Wrong Answer | p03690 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
b_1 b_2 ... b_N | N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
s = 0
for i in A:
s = s ^ i
if sorted(A) == sorted(B):
ans = 0
for i in range(N):
if A[i] != B[i]:
ans += 1
if s not in B:
if A == B:
print(0)
else:
print(ans + 1)
exit()
m = s
L = list()
for i in range(N):
L.append(m)
m = A[B.index(m)]
if len(set(L)) == ans:
print(ans)
else:
print(ans + 1)
exit()
else: # OK
ans = 0
A += [s]
L = sorted(A)
R = sorted(B)
for i in range(N):
if L[i] != R[i]:
L.remove(L[i])
break
if i == N - 1:
L.remove(L[N])
if sorted(L) != sorted(R):
print(-1)
exit()
for i in range(N):
if A[i] != B[i]:
ans += 1
print(ans)
| Statement
There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a
non-negative integer.
Snuke can repeatedly perform the following operation:
* Let the XOR of all the elements in a be x. Select an integer i (1 ≤ i ≤ N) and replace a_i with x.
Snuke's objective is to match a with another sequence b = (b_1, b_2, ...,
b_N). Here, each b_i is a non-negative integer.
Determine whether the objective is achievable, and find the minimum necessary
number of operations if the answer is positive. | [{"input": "3\n 0 1 2\n 3 1 0", "output": "2\n \n\nAt first, the XOR of all the elements of a is 3. If we replace a_1 with 3, a\nbecomes (3, 1, 2).\n\nNow, the XOR of all the elements of a is 0. If we replace a_3 with 0, a\nbecomes (3, 1, 0), which matches b.\n\n* * *"}, {"input": "3\n 0 1 2\n 0 1 2", "output": "0\n \n\n* * *"}, {"input": "2\n 1 1\n 0 0", "output": "-1\n \n\n* * *"}, {"input": "4\n 0 1 2 3\n 1 0 3 2", "output": "5"}] |
If the objective is achievable, print the minimum necessary number of
operations. Otherwise, print `-1` instead.
* * * | s588353904 | Wrong Answer | p03690 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
b_1 b_2 ... b_N | from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
bonusNumber = 0
for i in range(n):
bonusNumber ^= a[i]
aa = Counter({bonusNumber: 1})
bb = Counter()
for i in range(n):
aa[a[i]] += 1
bb[b[i]] += 1
for x in bb.keys():
if bb[x] > aa[x]:
print(-1)
exit()
#############################
ans = 0
tmp = []
first = True
for i in range(n):
if first and b[i] == bonusNumber and b[i] != a[i]:
bonusNumber = a[i]
a[i] = b[i]
ans += 1
first = False
elif b[i] != a[i]:
tmp.append(b[i])
while bonusNumber in tmp:
tmp.remove(bonusNumber)
bonusNumber = a[b.index(bonusNumber)]
ans += 1
if len(tmp) == 0:
print(ans)
else:
ans += len(tmp) + 1
print(ans)
| Statement
There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a
non-negative integer.
Snuke can repeatedly perform the following operation:
* Let the XOR of all the elements in a be x. Select an integer i (1 ≤ i ≤ N) and replace a_i with x.
Snuke's objective is to match a with another sequence b = (b_1, b_2, ...,
b_N). Here, each b_i is a non-negative integer.
Determine whether the objective is achievable, and find the minimum necessary
number of operations if the answer is positive. | [{"input": "3\n 0 1 2\n 3 1 0", "output": "2\n \n\nAt first, the XOR of all the elements of a is 3. If we replace a_1 with 3, a\nbecomes (3, 1, 2).\n\nNow, the XOR of all the elements of a is 0. If we replace a_3 with 0, a\nbecomes (3, 1, 0), which matches b.\n\n* * *"}, {"input": "3\n 0 1 2\n 0 1 2", "output": "0\n \n\n* * *"}, {"input": "2\n 1 1\n 0 0", "output": "-1\n \n\n* * *"}, {"input": "4\n 0 1 2 3\n 1 0 3 2", "output": "5"}] |
If the objective is achievable, print the minimum necessary number of
operations. Otherwise, print `-1` instead.
* * * | s708112330 | Runtime Error | p03690 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
b_1 b_2 ... b_N | n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = a[0]
for i in range(1,n):
x = x^a[i]
a.append(x)
a_=[]
b_=[]
for i in range(n):
if a[i]!=b[i]:
a_.append(a[i])
b_.append(b[i])
a_.sort()
b_.sort()
flag=True
boo = False
for i in range(len(a_)):
if a_[i]!=b_[i]:
if boo == False:
boo =True
else:
print('-1')
flag=False
if flag==True:
if boo = True:
print(len(b_))
else:
print(len(b_)+1) | Statement
There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a
non-negative integer.
Snuke can repeatedly perform the following operation:
* Let the XOR of all the elements in a be x. Select an integer i (1 ≤ i ≤ N) and replace a_i with x.
Snuke's objective is to match a with another sequence b = (b_1, b_2, ...,
b_N). Here, each b_i is a non-negative integer.
Determine whether the objective is achievable, and find the minimum necessary
number of operations if the answer is positive. | [{"input": "3\n 0 1 2\n 3 1 0", "output": "2\n \n\nAt first, the XOR of all the elements of a is 3. If we replace a_1 with 3, a\nbecomes (3, 1, 2).\n\nNow, the XOR of all the elements of a is 0. If we replace a_3 with 0, a\nbecomes (3, 1, 0), which matches b.\n\n* * *"}, {"input": "3\n 0 1 2\n 0 1 2", "output": "0\n \n\n* * *"}, {"input": "2\n 1 1\n 0 0", "output": "-1\n \n\n* * *"}, {"input": "4\n 0 1 2 3\n 1 0 3 2", "output": "5"}] |
If the objective is achievable, print the minimum necessary number of
operations. Otherwise, print `-1` instead.
* * * | s306974943 | Wrong Answer | p03690 | Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
b_1 b_2 ... b_N | print(-1)
| Statement
There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a
non-negative integer.
Snuke can repeatedly perform the following operation:
* Let the XOR of all the elements in a be x. Select an integer i (1 ≤ i ≤ N) and replace a_i with x.
Snuke's objective is to match a with another sequence b = (b_1, b_2, ...,
b_N). Here, each b_i is a non-negative integer.
Determine whether the objective is achievable, and find the minimum necessary
number of operations if the answer is positive. | [{"input": "3\n 0 1 2\n 3 1 0", "output": "2\n \n\nAt first, the XOR of all the elements of a is 3. If we replace a_1 with 3, a\nbecomes (3, 1, 2).\n\nNow, the XOR of all the elements of a is 0. If we replace a_3 with 0, a\nbecomes (3, 1, 0), which matches b.\n\n* * *"}, {"input": "3\n 0 1 2\n 0 1 2", "output": "0\n \n\n* * *"}, {"input": "2\n 1 1\n 0 0", "output": "-1\n \n\n* * *"}, {"input": "4\n 0 1 2 3\n 1 0 3 2", "output": "5"}] |
The output consists of _N_ lines. Please output the intermediate sequence in a
line for each step. Elements of the sequence should be separated by single
space. | s093483087 | Accepted | p02255 | The first line of the input includes an integer N, the number of elements in
the sequence.
In the second line, _N_ elements of the sequence are given separated by a
single space. | n = int(input())
NUM_STR = input()
print(NUM_STR)
NUM_LIST = list(map(int, NUM_STR.split()))
for i in range(1, len(NUM_LIST)):
v = NUM_LIST[i]
j = i - 1
while NUM_LIST[j] > v and j >= 0:
NUM_LIST[j + 1] = NUM_LIST[j]
j -= 1
NUM_LIST[j + 1] = v
STR = list(map(str, NUM_LIST))
print(" ".join(STR))
| Insertion Sort
Write a program of the Insertion Sort algorithm which sorts a sequence A in
ascending order. The algorithm should be based on the following pseudocode:
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >= 0 and A[j] > key
A[j+1] = A[j]
j--
A[j+1] = key
Note that, indices for array elements are based on 0-origin.
To illustrate the algorithms, your program should trace intermediate result
for each step. | [{"input": "6\n 5 2 4 6 1 3", "output": "5 2 4 6 1 3\n 2 5 4 6 1 3\n 2 4 5 6 1 3\n 2 4 5 6 1 3\n 1 2 4 5 6 3\n 1 2 3 4 5 6"}, {"input": "3\n 1 2 3", "output": "1 2 3\n 1 2 3\n 1 2 3"}] |
The output consists of _N_ lines. Please output the intermediate sequence in a
line for each step. Elements of the sequence should be separated by single
space. | s765439774 | Accepted | p02255 | The first line of the input includes an integer N, the number of elements in
the sequence.
In the second line, _N_ elements of the sequence are given separated by a
single space. | i = int(input())
n = list(map(int, input().split()))
print(" ".join(map(str, n)))
for k in range(1, i):
target = n[k]
hh = k - 1
while hh >= 0 and n[hh] > target:
n[hh + 1] = n[hh]
hh -= 1
n[hh + 1] = target
print(" ".join(map(str, n)))
| Insertion Sort
Write a program of the Insertion Sort algorithm which sorts a sequence A in
ascending order. The algorithm should be based on the following pseudocode:
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >= 0 and A[j] > key
A[j+1] = A[j]
j--
A[j+1] = key
Note that, indices for array elements are based on 0-origin.
To illustrate the algorithms, your program should trace intermediate result
for each step. | [{"input": "6\n 5 2 4 6 1 3", "output": "5 2 4 6 1 3\n 2 5 4 6 1 3\n 2 4 5 6 1 3\n 2 4 5 6 1 3\n 1 2 4 5 6 3\n 1 2 3 4 5 6"}, {"input": "3\n 1 2 3", "output": "1 2 3\n 1 2 3\n 1 2 3"}] |
The output consists of _N_ lines. Please output the intermediate sequence in a
line for each step. Elements of the sequence should be separated by single
space. | s135343752 | Accepted | p02255 | The first line of the input includes an integer N, the number of elements in
the sequence.
In the second line, _N_ elements of the sequence are given separated by a
single space. | def FUNC00(ARG00):
for VAR00 in range(1, len(ARG00)):
VAR01 = ARG00[VAR00]
VAR02 = VAR00 - 1
while VAR02 >= 0 and ARG00[VAR02] > VAR01:
ARG00[VAR02 + 1] = ARG00[VAR02]
VAR02 -= 1
ARG00[VAR02 + 1] = VAR01
print(" ".join([str(VAR03) for VAR03 in ARG00]))
VAR04 = int(input())
VAR05 = [int(VAR06) for VAR06 in input().split()]
print(" ".join([str(VAR06) for VAR06 in VAR05]))
FUNC00(VAR05)
| Insertion Sort
Write a program of the Insertion Sort algorithm which sorts a sequence A in
ascending order. The algorithm should be based on the following pseudocode:
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >= 0 and A[j] > key
A[j+1] = A[j]
j--
A[j+1] = key
Note that, indices for array elements are based on 0-origin.
To illustrate the algorithms, your program should trace intermediate result
for each step. | [{"input": "6\n 5 2 4 6 1 3", "output": "5 2 4 6 1 3\n 2 5 4 6 1 3\n 2 4 5 6 1 3\n 2 4 5 6 1 3\n 1 2 4 5 6 3\n 1 2 3 4 5 6"}, {"input": "3\n 1 2 3", "output": "1 2 3\n 1 2 3\n 1 2 3"}] |
The output consists of _N_ lines. Please output the intermediate sequence in a
line for each step. Elements of the sequence should be separated by single
space. | s289322600 | Accepted | p02255 | The first line of the input includes an integer N, the number of elements in
the sequence.
In the second line, _N_ elements of the sequence are given separated by a
single space. | length = int(input())
targ = [int(n) for n in input().split(" ")]
for l in range(length):
for m in range(l):
if targ[l - m] < targ[l - m - 1]:
disp = targ[l - m - 1]
targ[l - m - 1] = targ[l - m]
targ[l - m] = disp
print(" ".join([str(n) for n in targ]))
| Insertion Sort
Write a program of the Insertion Sort algorithm which sorts a sequence A in
ascending order. The algorithm should be based on the following pseudocode:
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >= 0 and A[j] > key
A[j+1] = A[j]
j--
A[j+1] = key
Note that, indices for array elements are based on 0-origin.
To illustrate the algorithms, your program should trace intermediate result
for each step. | [{"input": "6\n 5 2 4 6 1 3", "output": "5 2 4 6 1 3\n 2 5 4 6 1 3\n 2 4 5 6 1 3\n 2 4 5 6 1 3\n 1 2 4 5 6 3\n 1 2 3 4 5 6"}, {"input": "3\n 1 2 3", "output": "1 2 3\n 1 2 3\n 1 2 3"}] |
The output consists of _N_ lines. Please output the intermediate sequence in a
line for each step. Elements of the sequence should be separated by single
space. | s412380374 | Wrong Answer | p02255 | The first line of the input includes an integer N, the number of elements in
the sequence.
In the second line, _N_ elements of the sequence are given separated by a
single space. | print(input())
| Insertion Sort
Write a program of the Insertion Sort algorithm which sorts a sequence A in
ascending order. The algorithm should be based on the following pseudocode:
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >= 0 and A[j] > key
A[j+1] = A[j]
j--
A[j+1] = key
Note that, indices for array elements are based on 0-origin.
To illustrate the algorithms, your program should trace intermediate result
for each step. | [{"input": "6\n 5 2 4 6 1 3", "output": "5 2 4 6 1 3\n 2 5 4 6 1 3\n 2 4 5 6 1 3\n 2 4 5 6 1 3\n 1 2 4 5 6 3\n 1 2 3 4 5 6"}, {"input": "3\n 1 2 3", "output": "1 2 3\n 1 2 3\n 1 2 3"}] |
The output consists of _N_ lines. Please output the intermediate sequence in a
line for each step. Elements of the sequence should be separated by single
space. | s655210862 | Wrong Answer | p02255 | The first line of the input includes an integer N, the number of elements in
the sequence.
In the second line, _N_ elements of the sequence are given separated by a
single space. | N = int(input())
array = map(int, input().split())
print(*array)
| Insertion Sort
Write a program of the Insertion Sort algorithm which sorts a sequence A in
ascending order. The algorithm should be based on the following pseudocode:
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >= 0 and A[j] > key
A[j+1] = A[j]
j--
A[j+1] = key
Note that, indices for array elements are based on 0-origin.
To illustrate the algorithms, your program should trace intermediate result
for each step. | [{"input": "6\n 5 2 4 6 1 3", "output": "5 2 4 6 1 3\n 2 5 4 6 1 3\n 2 4 5 6 1 3\n 2 4 5 6 1 3\n 1 2 4 5 6 3\n 1 2 3 4 5 6"}, {"input": "3\n 1 2 3", "output": "1 2 3\n 1 2 3\n 1 2 3"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s650731973 | Accepted | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
n = int(readline())
xyu = read().split()
# x,y,/=p.\=m
num = 200_000
x, y, p, m = dict(), dict(), dict(), dict()
for i in [x, y]:
for s in "URDL":
i[s] = [[] for _ in range(num + 1)]
for i in [p, m]:
for s in "URDL":
i[s] = [[] for _ in range(num * 2 + 1)]
it = iter(xyu)
for a, b, c in zip(it, it, it):
a = int(a)
b = int(b)
if c in "UD":
y[c][a].append(b)
if c in "RL":
x[c][b].append(a)
p[c][num + a - b].append(b)
m[c][a + b].append(b)
inf = 10**10
ans = inf
for i in [x]:
for j in range(num + 1):
# RL
if (len(i["R"][j]) > 0) & (len(i["L"][j]) > 0):
a = i["R"][j]
a.sort()
b = i["L"][j]
b.sort()
b_ind = 0
for ai in a:
while b_ind < len(b):
if ai > b[b_ind]:
b_ind += 1
else:
break
if b_ind == len(b):
break
ans = min(ans, abs(ai - b[b_ind]) * 5)
for i in [y]:
for j in range(num + 1):
# UD
if (len(i["U"][j]) > 0) & (len(i["D"][j]) > 0):
a = i["U"][j]
a.sort()
b = i["D"][j]
b.sort()
b_ind = 0
for ai in a:
while b_ind < len(b):
if ai > b[b_ind]:
b_ind += 1
else:
break
if b_ind == len(b):
break
ans = min(ans, abs(ai - b[b_ind]) * 5)
for i in [p]:
for j in range(num * 2 + 1):
# UL
if (len(i["U"][j]) > 0) & (len(i["L"][j]) > 0):
a = i["U"][j]
a.sort()
b = i["L"][j]
b.sort()
b_ind = 0
for ai in a:
while b_ind < len(b):
if ai > b[b_ind]:
b_ind += 1
else:
break
if b_ind == len(b):
break
ans = min(ans, abs(ai - b[b_ind]) * 10)
# RD
if (len(i["R"][j]) > 0) & (len(i["D"][j]) > 0):
a = i["R"][j]
a.sort()
b = i["D"][j]
b.sort()
b_ind = 0
for ai in a:
while b_ind < len(b):
if ai > b[b_ind]:
b_ind += 1
else:
break
if b_ind == len(b):
break
ans = min(ans, abs(ai - b[b_ind]) * 10)
for i in [m]:
for j in range(num * 2 + 1):
# UR
if (len(i["U"][j]) > 0) & (len(i["R"][j]) > 0):
a = i["U"][j]
a.sort()
b = i["R"][j]
b.sort()
b_ind = 0
for ai in a:
while b_ind < len(b):
if ai > b[b_ind]:
b_ind += 1
else:
break
if b_ind == len(b):
break
ans = min(ans, abs(ai - b[b_ind]) * 10)
# LD
if (len(i["L"][j]) > 0) & (len(i["D"][j]) > 0):
a = i["L"][j]
a.sort()
b = i["D"][j]
b.sort()
b_ind = 0
for ai in a:
while b_ind < len(b):
if ai > b[b_ind]:
b_ind += 1
else:
break
if b_ind == len(b):
break
ans = min(ans, abs(ai - b[b_ind]) * 10)
if ans == inf:
print("SAFE")
else:
print(ans)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s858903862 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | n = int(input())
x_line = {}
y_line = {}
min_crash = 2e5
for _ in range(n):
x, y, u = list(input().split())
x = int(x)
y = int(y)
if x_line.get(x):
x_line[x].append([y, u])
else:
x_line[x] = [[y, u]]
if y_line.get(y):
y_line[y].append([x, u])
else:
y_line[y] = [[x, u]]
min_crash = 2e5
for y_list in x_line.values():
if len(y_list) >= 2:
y_list_s = sorted(y_list, key=lambda a: a[0])
u_y = None
for y, u in y_list_s:
if u == "D" and u_y:
crash = (y - u_y) // 2
min_crash = min(min_crash, crash)
elif u == "U":
u_y = y
for x_list in y_line.values():
if len(x_list) >= 2:
x_list_s = sorted(x_list, key=lambda a: a[0])
r_x = None
for x, u in x_list_s:
if u == "L" and r_x:
crash = x - r_x
min_crash = min(min_crash, crash)
elif u == "R":
r_x = x
if min_crash == 2e5:
print("SAFE")
else:
print(min_crash * 10)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s292263598 | Accepted | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | (N,) = map(int, input().split())
from collections import defaultdict
D = defaultdict(lambda: defaultdict(list))
D2 = defaultdict(lambda: defaultdict(list))
def Fm(d1, d2):
alist = D[d1]
blist = D[d2]
R = 10**18
for key in alist:
if key not in blist:
continue
A, B = alist[key], blist[key]
X = sorted(A + B, key=lambda x: x[0])
for a, b in zip(X, X[1:]):
if a[2] != b[2] and (a[2] == "R" or a[2] == "D"):
R = min(R, 10 * (b[0] - a[0]))
return R
def Fm2(d1, d2):
alist = D2[d1]
blist = D2[d2]
R = 10**18
for key in alist:
if key not in blist:
continue
A, B = alist[key], blist[key]
X = sorted(A + B, key=lambda x: x[0])
for a, b in zip(X, X[1:]):
if a[2] != b[2] and (a[2] == "R" or a[2] == "U"):
R = min(R, 10 * (b[0] - a[0]))
return R
Dx = defaultdict(list)
Dy = defaultdict(list)
for _ in range(N):
x, y, d = input().split()
x, y = int(x), int(y)
D[d][x + y].append((x, y, d))
D2[d][x - y].append((x, y, d))
if d in {"R", "L"}:
Dx[y].append((x, d))
else:
Dy[x].append((y, d))
R = 10**18
for key in Dx:
X = sorted(Dx[key])
for (x, d), (xx, d2) in zip(X, X[1:]):
if d == "R" and d2 == "L":
R = min(R, (xx - x) * 5)
for key in Dy:
X = sorted(Dy[key])
for (x, d), (xx, d2) in zip(X, X[1:]):
if d == "U" and d2 == "D":
R = min(R, (xx - x) * 5)
R = min(R, Fm("D", "L"))
R = min(R, Fm("U", "R"))
R = min(R, Fm2("D", "R"))
R = min(R, Fm2("U", "L"))
if R != 10**18:
print(R)
else:
print("SAFE")
# for key in D["R"]:
# if key not in D["U"]:
# continue
# print(D["R"][key], D["U"][key])
# for key in D["D"]:
# if key not in D["L"]:
# continue
# print(D["D"][key], D["L"][key])
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s405040213 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | n = int(input())
xx = [[] for _ in range(200001)]
yy = [[] for _ in range(200001)]
xy = [[] for _ in range(400001)]
yx = [[] for _ in range(200001)]
for _ in range(n):
x, y, u = input().split()
if u == "U" or u == "D":
xx[int(x)].append((int(y), u))
else:
yy[int(y)].append((int(x), u))
xy[int(x) + int(y)].append((int(x), u))
yx[int(y) - int(x)].append((int(x), u))
ans = 10**10
for i in xx:
if len(i) <= 1:
continue
i.sort()
d = -(10**10)
for j, k in i:
if k == "U":
d = j
elif ans > (j - d) * 5:
ans = (j - d) * 5
for i in yy:
if len(i) <= 1:
continue
i.sort()
d = -(10**10)
for j, k in i:
if k == "R":
d = j
elif ans > (j - d) * 5:
ans = (j - d) * 5
for i in xy:
if len(i) <= 1:
continue
i.sort()
d = -(10**10)
for j, k in i:
if k == "R":
d = j
elif k == "U" and ans > (j - d) * 10:
ans = (j - d) * 10
d = -(10**10)
for j, k in i:
if k == "D":
d = j
elif k == "L" and ans > (j - d) * 10:
ans = (j - d) * 10
for i in yx:
if len(i) <= 1:
continue
i.sort()
d = -(10**10)
for j, k in i:
if k == "U":
d = j
elif k == "L" and ans > (j - d) * 10:
ans = (j - d) * 10
d = -(10**10)
for j, k in i:
if k == "R":
d = j
elif k == "D" and ans > (j - d) * 10:
ans = (j - d) * 10
if ans == 10**10:
print("safe")
else:
print(ans)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s258329844 | Runtime Error | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | from operator import itemgetter
N = int(input())
PP = {
"D": [],
"U": [],
"L": [],
"R": [],
}
for i in range(N):
x, y, d = input().split()
x, y = int(x), int(y)
PP[d].append((x, y, x + y, y - x))
# print(PP)
ans = 1e10
# DvsU
PD = sorted(PP["D"])
PU = sorted(PP["U"])
j = 0
for i in range(len(PD)):
while j < len(PU) - 1 and PD[i][0] > PU[j][0]:
j += 1
if PD[i][0] == PU[j][0]:
if PD[i][1] >= PU[j][1]:
ans = min(ans, (PD[i][1] - PU[j][1]) * 5)
# L vs R
PL = sorted(PP["L"], key=itemgetter(1))
PR = sorted(PP["R"], key=itemgetter(1))
j = 0
for i in range(len(PL)):
while j < len(PR) - 1 and PL[i][1] > PR[j][1]:
j += 1
if PL[i][1] == PR[j][1]:
if PL[i][0] >= PR[j][0]:
ans = min(ans, (PL[i][0] - PR[j][0]) * 5)
# D vs R
# y = x + k <-> y-x = k が同一の点は当たる可能性
PD = sorted(PP["D"], key=itemgetter(3))
PR = sorted(PP["R"], key=itemgetter(3))
j = 0
for i in range(len(PD)):
while j < len(PR) - 1 and PD[i][3] > PR[j][3]:
j += 1
if PD[i][3] == PR[j][3]:
if PD[i][2] >= PR[j][2]:
ans = min(ans, abs(PD[i][2] - PR[j][2]) * 5)
# R vs U
# y = -x + k <-> y+x = k が同一の点は当たる可能性
PR = sorted(PP["R"], key=itemgetter(2))
PU = sorted(PP["U"], key=itemgetter(2))
j = 0
for i in range(len(PR)):
while j < len(PU) - 1 and PR[i][2] > PU[j][2]:
j += 1
if PR[i][2] == PU[j][2]:
if PR[i][3] >= PU[j][3]:
ans = min(ans, abs(PR[i][3] - PU[j][3]) * 5)
# D vs R
# U vs L
# y = x + k <-> y-x = k が同一の点は当たる可能性
PU = sorted(PP["U"], key=itemgetter(3))
PL = sorted(PP["L"], key=itemgetter(3))
j = 0
for i in range(len(PU)):
while j < len(PL) - 1 and PU[i][3] > PL[j][3]:
j += 1
if PU[i][3] == PL[j][3]:
if PU[i][2] <= PL[j][2]:
ans = min(ans, abs(PU[i][2] - PL[j][2]) * 5)
# R vs U
# L vs D
# y = -x + k <-> y+x = k が同一の点は当たる可能性
PL = sorted(PP["L"], key=itemgetter(2))
PD = sorted(PP["D"], key=itemgetter(2))
j = 0
for i in range(len(PL)):
while j < len(PD) - 1 and PL[i][2] > PD[j][2]:
j += 1
if PL[i][2] == PD[j][2]:
if PL[i][3] <= PD[j][3]:
ans = min(ans, abs(PL[i][3] - PD[j][3]) * 5)
print(ans)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s310185869 | Runtime Error | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | N = int(input())
f = [[], [], [], []]
for _ in range(N):
X, Y, U = map(int, input().split())
if U == "U":
f[0].append((X, Y))
elif U == "R":
f[1].append((X, Y))
elif U == "D":
f[2].append((X, Y))
else:
f[3].append((X, Y))
earliest = 2000000
ud = {}
rl = {}
ur_dl = {}
ul_dr = {}
for i in f[0]:
if i[0] not in ud:
ud[i[0]] = [[i[1]], []]
else:
ud[i[0]][0] += i[1]
if i[0] + i[1] not in ur_dl:
ur_dl[i[0] + i[1]] = [i[0]]
else:
ur_dl[i[0] + i[1]] += i[0]
for i in f[2]:
if i[0] in ud:
ud[i[0]][1] += i[1]
if i[0] + i[1] not in ur_dl:
ur_dl[i[0] + i[1]] = [i[0]]
else:
ur_dl[i[0] + i[1]] += i[0]
for i in ud.values():
for j in i[0]:
for k in i[1]:
dis = abs(j - k)
if j < k and dis < earliest:
earliest = dis
for i in f[1]:
if i[0] not in rl:
rl[i[1]] = [[i[0]], []]
else:
rl[i[1]][0] += i[0]
if i[0] + i[1] not in ur_dl:
ur_dl[i[0] + i[1]] = [i[0]]
else:
ur_dl[i[0] + i[1]] += i[0]
for i in f[3]:
if i[1] in rl:
rl[i[1]][1] += i[0]
if i[0] + i[1] in ur_dl:
ur_dl[i[0] + i[1]] += i[0]
for i in rl.values():
for j in i[0]:
for k in i[1]:
dis = abs(j - k)
if j < k and dis < earliest:
earliest = dis
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s151282858 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | import sys
input = sys.stdin.readline
from collections import defaultdict
from bisect import bisect_left, bisect_right
# bisect_left(a,x):a[i]>=xとなるような最小のi.
# 昇順ソートされたリストaに昇順を崩さずxを挿入できる位置s(0-index)を返す.
# a=[1,3,5,7,9,11,13,15,17,19]
# s = bisect_left(a,4)
# s=2
# d = defaultdict(int)で0で初期化
# d = defaultdict(lambda: 100)で100で初期化
n = int(input())
a = [list(input().split()) for i in range(n)]
for i in range(n):
if a[i][2] == "R":
a[i][2] = 1
elif a[i][2] == "L":
a[i][2] = 2
elif a[i][2] == "U":
a[i][2] = 3
else:
a[i][2] = 4
a[i][0] = int(a[i][0])
a[i][1] = int(a[i][1])
a.sort(key=lambda x: x[2])
R1 = defaultdict(list)
R2 = defaultdict(list)
L1 = defaultdict(list)
L2 = defaultdict(list)
U = defaultdict(list)
R = defaultdict(list)
R1u = defaultdict(bool)
R2u = defaultdict(bool)
L1u = defaultdict(bool)
L2u = defaultdict(bool)
Uu = defaultdict(bool)
Ru = defaultdict(bool)
M = 10000000
for x, y, u in a:
if u == 1:
R1[y - x].append(x)
R2[x + y].append(x)
R[y].append(x)
elif u == 2:
L1[x + y].append(x)
L2[y - x].append(x)
if not Ru[y]:
R[y].sort()
Ru[y] = True
k = bisect_right(R[y], x)
if k > 0:
M = min((x - R[y][k - 1]) * 5, M)
elif u == 3:
if not L2u[y - x]:
L2[y - x].sort()
L2u[y - x] = True
k = bisect_left(L2[y - x], x - 1)
if k < len(L2[y - x]):
M = min(M, (L2[y - x][k] - x) * 10)
if not R2[x + y]:
R2[x + y].sort()
R2u[x + y] = True
k = bisect_right(R2[x + y], x)
if k > 0:
M = min(M, (x - R2[x + y][k - 1]) * 10)
U[x].append(y)
else:
if not L1u[x + y]:
L1[x + y].sort()
L1u[x + y] = True
k = bisect_left(L1[x + y], x - 1)
if k < len(L1[x + y]):
M = min(M, (L1[x + y][k] - x) * 10)
if not R1u[y - x]:
R1[y - x].sort()
R1u[y - x] = True
k = bisect_right(R1[y - x], x)
if k > 0:
M = min(M, (x - R1[y - x][k - 1]) * 10)
if not Uu[x]:
U[y].sort()
Uu[y] = True
k = bisect_right(U[x], y)
if k > 0:
M = min((y - U[x][k - 1]) * 5, M)
print(M if M < 10000000 else "SAFE")
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s382576046 | Accepted | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | import sys
import collections
input = sys.stdin.readline
def main():
N = int(input()[:-1])
X = collections.defaultdict(list) # X
Y = collections.defaultdict(list) # Y
XYp = collections.defaultdict(list) # X + Y
XYn = collections.defaultdict(list) # X + Y
YXp = collections.defaultdict(list) # Y - X
YXn = collections.defaultdict(list) # Y - X
for _ in range(N):
x, y, u = input().split()
x = int(x)
y = int(y)
if u in ("U", "D"):
X[x].append((y, u == "U"))
if u in ("R", "L"):
Y[y].append((x, u == "R"))
if u in ("U", "R"):
XYp[x + y].append((x - y, u == "R"))
if u in ("D", "L"):
XYn[x + y].append((x - y, u == "D"))
if u in ("U", "L"):
YXp[y - x].append((x + y, u == "U"))
if u in ("D", "R"):
YXn[y - x].append((x + y, u == "R"))
ans = 200000 * 100
for x in [X, Y, XYp, XYn, YXp, YXn]:
for V in x.values():
V = sorted(V)
for i in range(len(V) - 1):
if V[i][1] and not V[i + 1][1]:
ans = min(ans, V[i + 1][0] - V[i][0])
if ans == 200000 * 100:
print("SAFE")
else:
print(ans * 5)
if __name__ == "__main__":
main()
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s209224161 | Accepted | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | import sys
from collections import defaultdict
def smin(x, y):
if x > y:
return y
else:
return x
sys.setrecursionlimit(500000)
def input():
return sys.stdin.readline()[:-1]
def main():
N = int(input())
dd = defaultdict(list)
ans = 10**27
for i in range(N):
x, y, u = input().split()
x, y = int(x), int(y)
dd[u].append((x, y))
dd_u = defaultdict(list)
for x, y in dd["U"]:
dd_u[x].append((y, "U"))
for x, y in dd["D"]:
if x in dd_u:
dd_u[x].append((y, "D"))
for x in dd_u:
dd_u[x].sort()
for i in range(len(dd_u[x]) - 1):
if dd_u[x][i][1] == "U" and dd_u[x][i + 1][1] == "D":
ans = smin((dd_u[x][i + 1][0] - dd_u[x][i][0]) / 2, ans)
dd_l = defaultdict(list)
for x, y in dd["L"]:
dd_l[y].append((x, "L"))
for x, y in dd["R"]:
if y in dd_l:
dd_l[y].append((x, "R"))
for y in dd_l:
dd_l[y].sort()
for i in range(len(dd_l[y]) - 1):
if dd_l[y][i][1] == "R" and dd_l[y][i + 1][1] == "L":
ans = smin((dd_l[y][i + 1][0] - dd_l[y][i][0]) / 2, ans)
dd_v = defaultdict(list)
for x, y in dd["U"]:
v = y - x
dd_v[v].append((x + y, "U"))
for x, y in dd["L"]:
v = y - x
if v in dd_v:
dd_v[v].append((x + y, "L"))
for v in dd_v:
dd_v[v].sort()
for i in range(len(dd_v[v]) - 1):
if dd_v[v][i][1] == "U" and dd_v[v][i + 1][1] == "L":
ans = smin((dd_v[v][i + 1][0] - dd_v[v][i][0]) / 2, ans)
dd_v = defaultdict(list)
for x, y in dd["U"]:
v = y + x
dd_v[v].append((x - y, "U"))
for x, y in dd["R"]:
v = y + x
if v in dd_v:
dd_v[v].append((x - y, "R"))
for v in dd_v:
dd_v[v].sort()
for i in range(len(dd_v[v]) - 1):
if dd_v[v][i][1] == "R" and dd_v[v][i + 1][1] == "U":
ans = smin((dd_v[v][i + 1][0] - dd_v[v][i][0]) / 2, ans)
dd_v = defaultdict(list)
for x, y in dd["D"]:
v = y - x
dd_v[v].append((x + y, "D"))
for x, y in dd["R"]:
v = y - x
if v in dd_v:
dd_v[v].append((x + y, "R"))
for v in dd_v:
dd_v[v].sort()
for i in range(len(dd_v[v]) - 1):
if dd_v[v][i][1] == "R" and dd_v[v][i + 1][1] == "D":
ans = smin((dd_v[v][i + 1][0] - dd_v[v][i][0]) / 2, ans)
dd_v = defaultdict(list)
for x, y in dd["D"]:
v = y + x
dd_v[v].append((x - y, "D"))
for x, y in dd["L"]:
v = y + x
if v in dd_v:
dd_v[v].append((x - y, "L"))
for v in dd_v:
dd_v[v].sort()
for i in range(len(dd_v[v]) - 1):
if dd_v[v][i][1] == "D" and dd_v[v][i + 1][1] == "L":
ans = smin((dd_v[v][i + 1][0] - dd_v[v][i][0]) / 2, ans)
if ans > 10**24:
print("SAFE")
else:
print(int(ans * 10))
if __name__ == "__main__":
main()
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s655482247 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | import sys
input = sys.stdin.readline
from collections import defaultdict
M = 200001
N = int(input())
X = [[] for _ in range(M)] # 上向きのy座標, 下向きのy座標
Y = [[] for _ in range(M)]
S1 = defaultdict(list) # x+yが一致
S2 = defaultdict(list)
T1 = defaultdict(list)
T2 = defaultdict(list)
for _ in range(N):
x, y, c = input().split()
x = int(x)
y = int(y)
if c == "U":
c = 0
S1[x + y].append((x - y, c))
T1[x - y].append((x + y, c))
elif c == "R":
c = 1
S1[x + y].append((x - y, c))
T2[x - y].append((x + y, c))
elif c == "D":
c = 2
S2[x + y].append((x - y, c))
T2[x - y].append((x + y, c))
else:
c = 3
S2[x + y].append((x - y, c))
T1[x - y].append((x + y, c))
if c % 2 == 0:
X[x].append((y, c))
else:
Y[y].append((x, c))
res = 10**18
tmp = None
for i in range(M):
X[i].sort()
for j in range(len(X[i])):
y, c = X[i][j]
if c == 0:
tmp = y
if c == 2:
if tmp is not None:
res = min(res, (y - tmp) * 5)
for i in range(M):
Y[i].sort()
tmp = None
for j in range(len(Y[i])):
x, c = Y[i][j]
if c == 1:
tmp = x
if c == 3:
if tmp is not None:
res = min(res, (x - tmp) * 5)
for k, v in S1.items():
v.sort()
tmp = None
for j in range(len(v)):
z, c = v[j]
if c == 1:
tmp = z
if c == 0:
if tmp is not None:
res = min(res, (z - tmp) * 5)
for k, v in S2.items():
v.sort()
tmp = None
for j in range(len(v)):
z, c = v[j]
if c == 2:
tmp = z
if c == 3:
if tmp is not None:
res = min(res, (z - tmp) * 5)
for k, v in T1.items():
v.sort()
tmp = None
for j in range(len(v)):
z, c = v[j]
if c == 0:
tmp = z
if c == 3:
if tmp is not None:
res = min(res, (z - tmp) * 5)
for k, v in T2.items():
v.sort()
tmp = None
for j in range(len(v)):
z, c = v[j]
if c == 1:
tmp = z
if c == 2:
if tmp is not None:
res = min(res, (z - tmp) * 5)
print(res if res != 10**18 else "SAFE")
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s370968694 | Accepted | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | N = int(input())
A1 = []
A2 = []
A3 = []
B1 = []
B4 = []
B5 = []
C2 = []
C4 = []
C6 = []
D3 = []
D5 = []
D6 = []
for i in range(N):
X, Y, U = input().split()
X = int(X)
Y = int(Y)
U = str(U)
if U == "R":
A1.append((Y, X))
A2.append((X - Y, X))
A3.append((X + Y, X))
elif U == "L":
B1.append((Y, X))
B4.append((X + Y, -X))
B5.append((X - Y, -X))
elif U == "D":
C2.append((X - Y, X))
C4.append((X + Y, -X))
C6.append((X, Y))
elif U == "U":
D3.append((X + Y, X))
D5.append((X - Y, -X))
D6.append((X, Y))
ans = 10**20
A1.sort()
B1.sort()
i = 0
for x1, y1 in A1:
while i < len(B1):
x2, y2 = B1[i]
if (x1, y1) < (x2, y2):
if x1 == x2:
ans = min(ans, (y2 - y1) * 5)
break
else:
i += 1
A2.sort()
C2.sort()
i = 0
for x1, y1 in A2:
while i < len(C2):
x2, y2 = C2[i]
if (x1, y1) < (x2, y2):
if x1 == x2:
ans = min(ans, (y2 - y1) * 10)
break
else:
i += 1
A3.sort()
D3.sort()
i = 0
for x1, y1 in A3:
while i < len(D3):
x2, y2 = D3[i]
if (x1, y1) < (x2, y2):
if x1 == x2:
ans = min(ans, (y2 - y1) * 10)
break
else:
i += 1
C4.sort()
B4.sort()
i = 0
for x1, y1 in B4:
while i < len(C4):
x2, y2 = C4[i]
if (x1, y1) < (x2, y2):
if x1 == x2:
ans = min(ans, (y2 - y1) * 10)
break
else:
i += 1
D5.sort()
B5.sort()
i = 0
for x1, y1 in B5:
while i < len(D5):
x2, y2 = D5[i]
if (x1, y1) < (x2, y2):
if x1 == x2:
ans = min(ans, (y2 - y1) * 10)
break
else:
i += 1
C6.sort()
D6.sort()
i = 0
for x1, y1 in D6:
while i < len(C6):
x2, y2 = C6[i]
if (x1, y1) < (x2, y2):
if x1 == x2:
ans = min(ans, (y2 - y1) * 5)
break
else:
i += 1
# print(B4, C4)
print(ans if ans < 10**20 else "SAFE")
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s881000138 | Accepted | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | n = int(input())
n1, n2 = 200001, 400001
s1, s2 = [[] for _ in range(n1)], [[] for _ in range(n1)]
s3, s4 = [[] for _ in range(n2)], [[] for _ in range(n2)]
for _ in range(n):
x, y, u = input().split()
x, y = int(x), int(y)
a, b = x + y, x - y + 200000
s1[x].append([y, u])
s2[y].append([x, u])
s3[a].append([b, u])
s4[b].append([a, u])
ans = 100000000
for t in s1:
if not t:
continue
a, b = -1, -1
t.sort()
for tt in t:
if tt[1] == "U":
a = tt[0]
elif tt[1] == "D":
b = tt[0]
if not min(a, b) == -1 and a < b:
ans = min(ans, 5 * (b - a))
for t in s2:
if not t:
continue
a, b = -1, -1
t.sort()
for tt in t:
if tt[1] == "R":
a = tt[0]
elif tt[1] == "L":
b = tt[0]
if not min(a, b) == -1 and a < b:
ans = min(ans, 5 * (b - a))
for t in s3:
if not t:
continue
a, b, c, d = -1, -1, -1, -1
t.sort()
for tt in t:
if tt[1] == "U":
a = tt[0]
elif tt[1] == "D":
b = tt[0]
elif tt[1] == "R":
c = tt[0]
elif tt[1] == "L":
d = tt[0]
if not min(a, c) == -1 and a > c:
ans = min(ans, 5 * (a - c))
if not min(b, d) == -1 and d > b:
ans = min(ans, 5 * (d - b))
for t in s4:
if not t:
continue
a, b, c, d = -1, -1, -1, -1
t.sort()
for tt in t:
if tt[1] == "U":
a = tt[0]
elif tt[1] == "D":
b = tt[0]
elif tt[1] == "R":
c = tt[0]
elif tt[1] == "L":
d = tt[0]
if not min(b, c) == -1 and c < b:
ans = min(ans, 5 * (b - c))
if not min(a, d) == -1 and a < d:
ans = min(ans, 5 * (d - a))
print(ans if not ans == 100000000 else "SAFE")
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s038381578 | Accepted | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | INF = float("inf")
sc = iter(open(0).read().split())
ni = lambda: int(next(sc))
ns = lambda: next(sc)
LR, UD, RU, LD, LU, RD = [[[] for _ in range(400_100)] for _ in range(6)]
U = []
N = ni()
for i in range(N):
x, y, u = ni(), ni(), ns()
U.append(u)
if u in "LR":
LR[y].append((x, i))
if u in "UD":
UD[x].append((y, i))
if u in "LD":
LD[x + y].append((y, i))
if u in "RU":
RU[x + y].append((y, i))
if u in "LU":
LU[y - x + 200_000].append((x, i))
if u in "RD":
RD[y - x + 200_000].append((x, i))
ans = INF
for i in range(400_001):
LR[i].sort()
UD[i].sort()
LD[i].sort()
RU[i].sort()
LU[i].sort()
RD[i].sort()
ans = min(
ans,
5
* min(
(
(LR[i][j + 1][0] - LR[i][j][0])
for j in range(len(LR[i]) - 1)
if U[LR[i][j][1]] == "R" and U[LR[i][j + 1][1]] == "L"
),
default=INF,
),
5
* min(
(
(UD[i][j + 1][0] - UD[i][j][0])
for j in range(len(UD[i]) - 1)
if U[UD[i][j][1]] == "U" and U[UD[i][j + 1][1]] == "D"
),
default=INF,
),
10
* min(
(
(LD[i][j + 1][0] - LD[i][j][0])
for j in range(len(LD[i]) - 1)
if U[LD[i][j][1]] == "L" and U[LD[i][j + 1][1]] == "D"
),
default=INF,
),
10
* min(
(
(RU[i][j + 1][0] - RU[i][j][0])
for j in range(len(RU[i]) - 1)
if U[RU[i][j][1]] == "U" and U[RU[i][j + 1][1]] == "R"
),
default=INF,
),
10
* min(
(
(LU[i][j + 1][0] - LU[i][j][0])
for j in range(len(LU[i]) - 1)
if U[LU[i][j][1]] == "U" and U[LU[i][j + 1][1]] == "L"
),
default=INF,
),
10
* min(
(
(RD[i][j + 1][0] - RD[i][j][0])
for j in range(len(RD[i]) - 1)
if U[RD[i][j][1]] == "R" and U[RD[i][j + 1][1]] == "D"
),
default=INF,
),
)
print("SAFE" if ans == INF else ans)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s681564199 | Accepted | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | N = int(input())
MAX = 200000
NEVER_T = (MAX + 1) * 10
planesH = [[] for _ in range(MAX + 1)]
planesV = [[] for _ in range(MAX + 1)]
planes45 = [[] for _ in range(MAX * 2 + 1)]
planes135 = [[] for _ in range(MAX * 2 + 1)]
for _ in range(N):
X, Y, U = input().strip().split()
X = int(X)
Y = int(Y)
planes45[MAX + X - Y].append((X, U))
planes135[X + Y].append((X, U))
if U == "U" or U == "D":
planesV[X].append((Y, U))
else:
planesH[Y].append((X, U))
def search(group, U1, U2, minT, t):
last = -1
for plane in group:
U = plane[1]
if U == U1:
last = plane[0]
elif U == U2:
if last >= 0:
T = (plane[0] - last) * t
if minT > T:
minT = T
return minT
minT = NEVER_T
for group in planes45:
if len(group) > 0:
group.sort()
minT = search(group, "U", "L", minT, 10)
minT = search(group, "R", "D", minT, 10)
for group in planes135:
if len(group) > 0:
group.sort()
minT = search(group, "D", "L", minT, 10)
minT = search(group, "R", "U", minT, 10)
for group in planesH:
if len(group) > 0:
group.sort()
minT = search(group, "R", "L", minT, 5)
for group in planesV:
if len(group) > 0:
group.sort()
minT = search(group, "U", "D", minT, 5)
if minT < NEVER_T:
print(minT)
else:
print("SAFE")
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s948307895 | Wrong Answer | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | # import io
# import sys
# _INPUT = """\
# 2
# 2 1 U
# 3 2 L
# 8
# 168 224 U
# 130 175 R
# 111 198 D
# 121 188 L
# 201 116 U
# 112 121 R
# 145 239 D
# 185 107 L
# """
# sys.stdin = io.StringIO(_INPUT)
####################################################################
import sys
def _p(*_a):
return
_s = " ".join(map(str, _a))
# print(_s)
sys.stderr.write(_s + "\n")
####################################################################
def _pa(_aa):
return
for _a in _aa:
_p(_a)
####################################################################
N = int(input())
X = []
Y = []
U = []
from collections import defaultdict
dAU = defaultdict(list)
dAD = defaultdict(list)
dAL = defaultdict(list)
dAR = defaultdict(list)
dBU = defaultdict(list)
dBD = defaultdict(list)
dBL = defaultdict(list)
dBR = defaultdict(list)
dXU = defaultdict(list)
dXD = defaultdict(list)
# dXR = defaultdict(list)
# dXL = defaultdict(list)
# dYU = defaultdict(list)
# dYD = defaultdict(list)
dYR = defaultdict(list)
dYL = defaultdict(list)
# for k, v in s:
# d[k].append(v)
# print(sorted(d.items())) #=> [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]
for i in range(N):
x, y, u = input().split()
x = int(x)
y = int(y)
X.append(x)
Y.append(y)
U.append(u)
a = y - x
b = x + y
if u == "U":
dAU[a].append((x, y, u, i))
dBU[b].append((x, y, u, i))
dXU[x].append((x, y, u, i))
if u == "D":
dAD[a].append((x, y, u, i))
dBD[b].append((x, y, u, i))
dXD[x].append((x, y, u, i))
if u == "L":
dAL[a].append((x, y, u, i))
dBL[b].append((x, y, u, i))
dYL[y].append((x, y, u, i))
if u == "R":
dAR[a].append((x, y, u, i))
dBR[b].append((x, y, u, i))
dYR[y].append((x, y, u, i))
ans = []
L = [[dXU, dXD], [dYL, dYR]]
for d1, d2 in L:
for k, v in d1.items():
_p("d1, k,v=", k, v)
for v1 in v:
_p("d1, k,v1=", k, v1)
for v2 in d2[k]:
_p("d2, k,v2=", k, v2)
x1, y1, u1, i1 = v1
x2, y2, u2, i2 = v2
if u1 == "U" and u2 == "D":
if y1 > y2:
continue
a = abs(y1 - y2) // 2
if u1 == "L" and u2 == "R":
if x1 < x2:
continue
a = abs(x1 - x2) // 2
_p("a=", a)
ans.append(a)
_p("ans=", ans)
L = [[dAU, dAL], [dAD, dAR], [dBU, dBR], [dBD, dBL]]
for d1, d2 in L:
_p("---")
for k, v in d1.items():
_p("d1, k,v=", k, v)
for v1 in v:
_p("d1, k,v1=", k, v1)
for v2 in d2[k]:
_p("d2, k,v2=", k, v2)
x1, y1, u1, i1 = v1
x2, y2, u2, i2 = v2
if u1 == "D" and u2 == "L":
if x1 > x2:
continue
if u1 == "D" and u2 == "R":
if x1 < x2:
continue
if u1 == "U" and u2 == "L":
if x1 > x2:
continue
if u1 == "U" and u2 == "R":
if x1 < x2:
continue
a = abs(x1 - x2)
_p("a=", a)
ans.append(a)
_p(" ---")
_p("ans=", ans)
if len(ans) == 0:
print("SAFE")
else:
ans.sort()
for a in ans:
print(a * 10)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
If there is a pair of airplanes that will collide with each other if they keep
flying as they are now, print an integer representing the number of seconds
after which the first collision will happen.
If there is no such pair, print `SAFE`.
* * * | s847038744 | Runtime Error | p02605 | Input is given from Standard Input in the following format:
N
X_1 Y_1 U_1
X_2 Y_2 U_2
X_3 Y_3 U_3
:
X_N Y_N U_N | N = int(input())
U = list()
D = list()
R = list()
L = list()
for i in range(N):
X, Y, direction = [str(x) for x in input().split()]
if direction == "U":
U.append([int(X), int(Y)])
elif direction == "D":
D.append([int(X), int(Y)])
elif direction == "R":
R.append([int(X), int(Y)])
elif direction == "L":
L.append([int(X), int(Y)])
ans = list()
for i in range(len(U)):
for j in range(len(D)):
if (U[i][0] == D[j][0]) and (U[i][1] > D[j][1]):
ans.append(U[i][1] - D[j][1])
for i in range(len(R)):
for j in range(len(L)):
if (R[i][1] == L[i][1]) and (R[i][0] < L[j][0]):
ans.append(L[j][0] - R[i][0])
for i in range(len(U)):
for j in range(len(R)):
if (
(U[i][1] < R[j][1])
and (U[i][0] > R[j][0])
and ((U[i][0] - R[j][0]) == (R[j][1] - U[j][1]))
):
ans.append(U[i][0] - R[j][0])
for i in range(len(U)):
for j in range(len(L)):
if (
(U[i][1] < L[j][1])
and (U[i][0] < L[j][0])
and ((L[j][0] - U[i][0]) == (L[j][1] - U[j][1]))
):
ans.append(L[j][0] - U[i][0])
for i in range(len(D)):
for j in range(len(R)):
if (
(D[i][1] > R[j][1])
and (D[i][0] > R[j][0])
and ((D[i][0] - R[j][0]) == (D[j][1] - R[j][1]))
):
ans.append(D[i][0] - R[j][0])
for i in range(len(D)):
for j in range(len(L)):
if (
(D[i][1] > L[j][1])
and (D[i][0] < L[j][0])
and ((L[j][0] - D[i][0]) == (D[j][1] - L[j][1]))
):
ans.append(L[j][0] - D[i][0])
if not ans:
print("SAFE")
else:
print(min(ans) * 10)
| Statement
M-kun is a brilliant air traffic controller.
On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all
flying at the same altitude.
Each of the airplanes flies at a constant speed of 0.1 per second in a
constant direction. The current coordinates of the airplane numbered i are
(X_i, Y_i), and the direction of the airplane is as follows:
* if U_i is `U`, it flies in the positive y direction;
* if U_i is `R`, it flies in the positive x direction;
* if U_i is `D`, it flies in the negative y direction;
* if U_i is `L`, it flies in the negative x direction.
To help M-kun in his work, determine whether there is a pair of airplanes that
will collide with each other if they keep flying as they are now.
If there is such a pair, find the number of seconds after which the first
collision will happen.
We assume that the airplanes are negligibly small so that two airplanes only
collide when they reach the same coordinates simultaneously. | [{"input": "2\n 11 1 U\n 11 47 D", "output": "230\n \n\nIf the airplanes keep flying as they are now, two airplanes numbered 1 and 2\nwill reach the coordinates (11, 24) simultaneously and collide.\n\n* * *"}, {"input": "4\n 20 30 U\n 30 20 R\n 20 10 D\n 10 20 L", "output": "SAFE\n \n\nNo pair of airplanes will collide.\n\n* * *"}, {"input": "8\n 168 224 U\n 130 175 R\n 111 198 D\n 121 188 L\n 201 116 U\n 112 121 R\n 145 239 D\n 185 107 L", "output": "100"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.