Currently (2020/05/05) in use ** Templates for competitive pros (for Python) such as AtCoder! ** ** Please use when it is good~ (I'm sorry if I make a mistake!)
I think that the first line is often deleted and submitted, so
Always use sys
and other libraries (at input)
It is divided into two lines!
Also, sys.stdin.readline (). Rstrip ()
is clearly faster than ʻinput ()`! !! !!
Reference article
[8 small differences in processing speed that Python should know]
(https://www.kumilog.net/entry/python-speed-comp#input-%E3%81%A8-sysstdinreadline)
** (Added on 2020/05/17) **
Moved the position of S ()
over LS ()
(because it didn't look good)
test.py
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A = [LI() for _ in range(N)]
** (Added on 2020/05/17) **
Added np.argmax ()
bisect()
deque()
Counter()
most_common()
defaultdict()
deepcopy()
heapify()
heappush()
heappop()
accumulate()
groupby()
--product ()
Duplicate
--permutations ()
No duplication (permutation)
--combinations ()
No duplication (combination)gcd()
ceil()
factorial()
fmax()
argmax()
vstack()
ascii_lowercase()
ascii_uppercase()
lower()
upper()
swapcase()
** (Added on 2020/05/11) ** ABC167A When I received the following characters, I got an error and was impatient ...
NG.py
import sys
def S(): return sys.stdin.readline().rstrip()
S = S()
T = S()
print('Yes' if S==T[:-1] else 'No')
T = S()
By the way
S
is just a string (overwritten just before), but you can't useS ()
! Error with!
If you think about it, it's natural ...
In such a case, let's deal with it as follows ~
OK1.py
import sys
def S(): return sys.stdin.readline().rstrip()
S,T = S(),S()
print('Yes' if S==T[:-1] else 'No')
You can do this! Or rather, I'm glad I wrote this way normally ...
OK2.py
import sys
def S(): return sys.stdin.readline().rstrip()
s = S()
t = S()
print('Yes' if s==t[:-1] else 'No')
Make variables lowercase (other than uppercase S
) ~
end!
Recommended Posts