LoginSignup
0
0

More than 3 years have passed since last update.

PythonでABC166のA~Dを解く

Last updated at Posted at 2020-05-03

はじめに

今日はA~Dの4完でした。今日もCに悩まされたよ()

A問題

問題

考えたこと
if

s = input()

if s == 'ABC':
    print('ARC')
else:
    print('ABC')

B問題

問題

考えたこと
入力がやや面倒だった。N人のリスト作って、お菓子を持ってるかを確認する。

n, k = map(int,input().split())
d = []
a = []
for _ in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))
check = [False] * n
for i in range(k):
    for j in a[i]:
        check[j-1] = True

ans = 0
for i in range(n):
    if not check[i]:
        ans += 1
print(ans)

C問題

問題

考えたこと
繋がってる道の数のlistを作って大小を確認する。
高さが同じ場合の処理をしていなくて3WAも出てしまいました。ゆるしません。

n, m = map(int,input().split())
h = list(map(int,input().split()))
ab = [(list(map(int,input().split()))) for _ in range(m)]

path = [0] * n
check = [0] * n
for i in range(m):
    path[ab[i][0]-1] += 1
    path[ab[i][1]-1] += 1
    if h[ab[i][0]-1] < h[ab[i][1]-1]:
        check[ab[i][1]-1] += 1
    elif h[ab[i][0]-1] == h[ab[i][1]-1]:
        continue
    else:
        check[ab[i][0]-1] += 1

ans = 0
for i in range(n):
    if path[i] == check[i]:
        ans +=1

print(ans)

D問題

問題

考えたこと
数学?知らない子ですね。$-1000<=a,b<=1000$くらいになるで全探索しました。

x = int(input())

for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i ** 5 - j ** 5 == x:
            print(i,j)
            quit()

まとめ

細かいところを見落としてペナが生えたり、時間のロスが生じているので良くない。今回も、C,Dはもっと早く解けました。悔しいです。ではまた、おやすみなさい。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0