https://atcoder.jp/contests/abc155 A
a, b, c = input().split()
ans = 'No'
if (a==b and a!=c) or (a==c and a!=b) or (b==c and a!=b): ans = 'Yes'
print(ans)
Since there were only three things to compare, we made a conditional branch by listing all the cases where "two are together and one is different".
I think it took longer than usual A problem.
Submission https://atcoder.jp/contests/abc155/submissions/10135101
Added a comment from @shiracamus. Consider the set ()
as a list of inputs.
Outputs Yes
if the size is 2
, and No
otherwise.
if len(set(input().split())) == 2: print('Yes')
else: print('No')
Submission https://atcoder.jp/contests/abc155/submissions/10242708 B
n = int(input())
a = list(map(int, input().split()))
ans = 'APPROVED'
for i in a:
if i % 2 != 0: continue
if (i % 3==0) or (i % 5==0): continue
ans = 'DENIED'
break
print(ans)
Look at A_1, ..., A_N in order, and if it is odd
or evendivisible by 3 or 5, look at the next element. If the two conditions are not met, the final output is set to
DENIED` and the for statement is exited.
Submission https://atcoder.jp/contests/abc155/submissions/10141261
C
n = int(input())
s = [input() for _ in range(n)]
d = {}
for w in s:
if w not in d:
d[w] = 0
d[w] += 1
d2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
maxcnts = [w[0] for w in d2 if w[1] == d2[0][1]]
maxcnts.sort()
for ans in maxcnts:
print(ans)
Make a dictionary of words. A dictionary in the form of {word: number of occurrences}
.
After that, it sorts by the number of occurrences, which is the value of the dictionary, and creates a list maxcnts
of only the maximum number of words.
Since sort ()
and sorted ()
of python can also sort the characters, the maxcnts
is sorted in alphabetical order and output one by one.
Submission https://atcoder.jp/contests/abc155/submissions/10146425
I would like to add it if I can AC. D is struggling to solve and understand.
Recommended Posts