0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paizaラーニング問題集「神経衰弱(オリジナル)」を解いてみた

Posted at

▼考え方

この問題を解くために私が考えた内容1.~3.を以下に示します。

  1. 各プレイヤーが取り除いたトランプの枚数は、辞書cardsで管理します。

  2. 現在、神経衰弱をプレイしているプレイヤーの番号は変数nで示します。

  3. 問題文にある手順のとおり処理します。

▼コード

########## 処理0(準備) インプット,リストや変数定義 ###########

H,W,N = map(int,input().split())

# 考え方1.
cards = {}
for i in range(N):
    cards[i+1] = 0

t = [[0]*W]*H
for i in range(H):
    t[i] = list(map(int,input().split()))

L = int(input())

# 考え方2.
n = 1

########## 処理1 神経衰弱の処理 ###########

# 考え方3.
for i in range(L):
    
    a,b,A,B = map(int,input().split())
    
    if t[a-1][b-1] != t[A-1][B-1]:
        n += 1
        if n > N:
            n = n % N
    else:
        cards[n] += 2

for i in range(N):
    print(cards[i+1])
0
0
3

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?