0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

はじめに

こんばんは。突然始まった不定期企画です。深夜にノリで書いた問題を貼るだけという企画です。眠たいです。

#1

問題

考えたこと
制約が小さいので、W*Hのlistを用意して操作を実際に行いました。要素1が白いマスで、0が黒いマスです。操作が4通りあるのでifゴリ押し

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

def view(now): #この関数は処理がうまくできてるかを可視化するために書いたので消しても良い
    s = ''
    now = list(reversed(now))
    for i in range(h):
        for j in range(w):
            s += str(now[i][j])
        else:
            s += '\n'
    return s

mapp = [[1]*(w)] * (h) #もとの図

for i in range(n):
    if xy[i][2] == 1 or xy[i][2] == 2:
        for j in range(h):
            if xy[i][2] == 1:
                mapp[j][:xy[i][0]] = [0]*xy[i][0]

            elif xy[i][2] == 2:
                mapp[j][xy[i][0]:] = [0]*(w-xy[i][0])

    elif xy[i][2] == 3:
        for s in range(xy[i][1]):
            mapp[s] = [0] * w

    elif xy[i][2] == 4:
        for s in range(xy[i][1],h):
            mapp[s] = [0] * w

    #print(view(mapp))
ans = 0
for i in range(h):
    ans += mapp[i].count(1)
print(ans)

気持ち

眠い。そして夜にこんな問題を解いてはいけない。おやすみなさい。

0
1
0

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?