Problem:

すごろくと駒 (Sugoroku and Pieces)

 問題文

JOI 君はすごろくを持っている．このすごろくは 2019 個のマスが横一列に並んだ形をしている．これらのマスには，左端のスタートマスから右端のゴールマスへと順に 1 から 2019 までの番号がついている．

現在このすごろくの上には，N 個の駒が置かれている．これらの駒には，スタートに近い順に 1 から N までの番号がついている．駒 i (1 ≦ i ≦ N) は，マス X_i に置かれている．すべての駒は異なるマスに置かれている．

JOI 君はこれから M 回の操作を行う．j 回目 (1 ≦ j ≦ M) の操作では，駒 A_j を 1 マス先へ進める．ただし，移動元のマスがゴールマスであった場合，もしくは移動先のマスに別の駒が置かれている場合，駒 A_j は進まず，位置は変わらない．

すべての操作が終了した時点で，各駒が置かれているマスを求めよ．

制約

1 ≦ N ≦ 100

1 ≦ X_1 

1 ≦ M ≦ 100

1 ≦ A_j ≦ N (1 ≦ j ≦ M)

入力・出力

入力

入力は以下の形式で標準入力から与えられる．

N

X_1 X_2 ... X_N

M

A_1 A_2 ... A_M

出力

N 行出力せよ．i 行目 (1 ≦ i ≦ N) には，すべての操作が終了した時点で駒 i が置かれているマスの番号を出力せよ．

入出力例

入力例 1

3
2 3 6
2
1 3

出力例 1

2
3
7

1 回目の操作では，駒 1 をマス 2 からマス 3 へと進めようする．しかし，駒 2 がすでにマス 3 に置かれているため，駒 1 は進まない．

2 回目の操作では，駒 3 をマス 6 からマス 7 へと進める．

すべての操作が終了した時点で，駒 1 はマス 2 に，駒 2 はマス 3 に，駒 3 はマス 7 に置かれている．

入力例 2

2
1 2016
4
2 2 2 2

出力例 2

1
2019

3 回目の操作が完了した時点で，駒 2 はマス 2019 に置かれている．そのため，4 回目の操作では駒 2 は進まない．

入力例 3

4
1001 1002 1003 1004
7
1 2 3 4 3 2 1

出力例 3

1002
1003
1004
1005

情報オリンピック日本委員会作 『第 18 回日本情報オリンピック JOI 2018/2019 予選競技課題』



Sample input:
3
2 3 6
2
1 3


Sample output:
2
3
7

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int,input().split()))
m = int(input())
a = list(map(int,input().split()))

x.insert(0,0)
a.insert(0,0)

for i in range(1,m+1):
    if x[a[i]] == 2019:
        pass
    elif a[i] == n:
        x[a[i]] = x[a[i]]+1
    elif x[a[i]]+1 != x[a[i]+1]:
        x[a[i]] = x[a[i]]+1


x.pop(0)
print(*x,sep = '\n')

Submission status: Accepted

Solution code:
n=int(input())
s=list(map(int,input().split()))
m=int(input())
a=list(map(int,input().split()))

for i in a:
    x=s[i-1]+1
    if x in s:
        continue
    if x >2019:
        continue
    else:
        s[i-1]=x
for i in range(n):
    print(s[i])

Submission status: Accepted

Solution code:
N = int(input())
P_locat = [int(i) for i in input().split()]
M = int(input())
P = [int(i) for i in input().split()]

for i in range(M):
    tmp_locat = P_locat[P[i]-1] + 1
    if tmp_locat <= 2019 :
        P_locat[P[i]-1] += 1
    if P[i] != N:
        if P_locat[P[i]-1] == P_locat[P[i]]:
            P_locat[P[i]-1] -= 1
for i in range(N):
    print(P_locat[i])

Submission status: Accepted

Solution code:
_map = [200 for i in range(2020)]
n = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))
for i in range(n):
    _map[X[i]] = i+1
for i in A:
    if _map.index(i)+1 < 2020 and _map[_map.index(i)+1] == 200:
        _map[_map.index(i)+1] = i
        _map[_map.index(i)] = 200
for i in range(n):
    print(_map.index(i+1))

Submission status: Accepted

Solution code:
N = int(input())
X = [int(i) for i in input().split(' ')]
M = int(input())
A = [int(i) for i in input().split(' ')]

GOAL = 2019


for a in A:
    if len(X) > a and (X[a-1] + 1) == X[a]:
        continue
    if X[a-1] == GOAL:
        continue
    X[a-1] = X[a-1] + 1
    
for x in X:
    print(x)

Submission status: Accepted

Solution code:
# 4
# 2 3 6 2019
# 2
# 1 3 4

N = int(input())
X = list(map(int, input().split()))  # 初期配置のリスト
M = int(input())
A = list(map(int, input().split()))  # 操作のリスト

# Aを読み込み、Nを操作
for j in A:
	if X[j - 1] == 2019:
		pass
	elif j <= N - 1:
		if X[j - 1] + 1 == X[j]:
			pass
		else:
			X[j - 1] = X[j - 1] + 1
	else:
		X[j - 1] = X[j - 1] + 1

# 結果出力
for k in X:
	print(k)

Submission status: Accepted

Solution code:
a=int(input())
array2019=[]
array_num=[]
array2019+=map(int,input().split(" ",a-1))
b=int(input())
array_num+=map(int,input().split(" ",b-1))

for n in array_num:
    if array2019[n-1]+1 in array2019 or array2019[n-1]==2019:
        pass
    else:array2019[n-1]+=1

for m in array2019:
    print(m)

Submission status: Accepted

Solution code:
MAX_PLACE = 2019
def sugoroku(N, X, M, A):
    X.append(MAX_PLACE + 1)
    for a in A:
        if(X[a - 1] + 1 == X[a]):
            pass
        else:
            X[a-1] += 1
    X.pop()
    for i in range(N):
        print(X[i])

#sugoroku(3, [2, 3, 6], 2, [1, 3])
#sugoroku(2, [1, 2016], 4, [2,2,2,2])
#sugoroku(4, [1001, 1002, 1003, 1004], 7, [1, 2, 3, 4, 3, 2, 1])

def main():
    N = int(input())
    X = list(map(int, input().split()))
    M = int(input())
    A = list(map(int, input().split()))
    sugoroku(N, X, M, A)

main()

Submission status: Accepted

Solution code:
N = input("")
X = input("").split(" ")
M = input("")
A = input("").split(" ")

for a in A:
    index = int(a) - 1
    if X[index] == "2019":
        continue
    if not str(int(X[index]) + 1) in X:
        X[index] = str(int(X[index]) + 1)
for x in X:
    print(x)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int,input().split()))
m = map(int,input())
a = list(map(int,input().split()))


for f in a:
  #print(f,n)
  if x[f-1] < 2019:
    if f == n:
      #print(f,x[f-1])
      x[f-1] += 1
      
    elif x[f-1]+1 != x[f]:
      #print(f,x[f-1])
      x[f-1] += 1

for j in x:
  print(j)

Submission status: Accepted

Solution code:
N = int(input())

BASYO = [int(i) for i in input().split()]

M = int(input())

KOMA = [int(i) for i in input().split()]

for i in range(M):
    
    X = KOMA[i] - 1
    
    if (N != X + 1 and 1 == BASYO[X+1] - BASYO[X]) or BASYO[X] == 2019:
        pass
    
    else:
        BASYO[X] += 1
for i in range(N):
    print(BASYO[i])

Submission status: Accepted

Solution code:
N = int(input())
X_N = [int(i) for i in input().split()]
M = int(input())
A_M = [int(i) for i in input().split()]

for i in range(0, M):
    if (X_N[A_M[i]-1] != 2019) and ((A_M[i] == N) or (X_N[A_M[i]] != X_N[A_M[i]-1] + 1)):
        X_N[A_M[i]-1] += 1
        
for i in range(0, N):
    print(X_N[i])

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int,input().split()))
x.append(0)
m = int(input())
a = list(map(int,input().split()))
for i in a:
    i -= 1
    if x[i] != 2019 and x[i]+1 != x[i+1]:
        x[i] += 1
for i in range(n):
    print(x[i])

Submission status: Accepted

Solution code:
N = int(input())
X = [int(x) for x in input().split()]
M = int(input())
A = [int(x) for x in input().split()]

peace = {x: 0 for x in range(1, N + 1)}  # 駒
square = {x: 0 for x in range(1, 2020)}  # マス

for i in range(N):
    peace[i + 1] = X[i]
    square[X[i]] = i + 1

for i in range(M):
    if peace[A[i]] < 2019 and square[peace[A[i]] + 1] == 0:
        square[peace[A[i]] + 1] = A[i]
        square[peace[A[i]]] = 0
        peace[A[i]] += 1

for i in range(1, N + 1):
    print(peace[i])

Submission status: Accepted

Solution code:
input()
*X,=map(int,input().split())
input()
for a in map(int,input().split()):
    a-=1
    if X[a]<2019 and X[a]+1 not in X:
        X[a]+=1
print(*X,sep="\n")

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    pieces = list(map(lambda x: int(x), input().split()))
    m = int(input())
    operations = list(map(lambda x: int(x), input().split()))
    res = {}
    ans = []

    for i in range(2019):
        res[i] = 0

    for i in pieces:
        res[i - 1] = 1

    for i in operations:
        piece = pieces[i - 1]
        if piece >= 2019:
            continue
            
        if res[piece] == 1:
            pass
        else:
            res[piece - 1] = 0
            res[piece] = 1
            if (pieces[i - 1] + 1) < 2019:
                pieces[i - 1] += 1

    for i in range(2019):
        if res[i] == 1:
            print(i + 1)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
*X, = map(int, input().split())
for i in range(N):
    X[i] -= 1
U = [0]*2019
for i, x in enumerate(X):
    U[x] = 1
M = int(input())
*A, = map(int, input().split())
for a in A:
    x = X[a-1]
    if x < 2018 and not U[x+1]:
        U[x+1] = 1; U[x] = 0
        X[a-1] += 1
for x in X:
    print(x+1)

Submission status: Accepted

Solution code:
N = int(input())
koma = list(map(int,input().split()))
M = int(input())
a = list(map(int,input().split()))

for i in a:
    if i == N:
        koma[i-1] = min(koma[i-1]+1, 2019)
    else:
        koma[i-1] = min(koma[i-1]+1, koma[i]-1)
        
for i in koma:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))

goal = 2019

v = [i in x for i in range(goal+1)]

int(input())
for a in map(int, input().split()):
    count = 0
    for i in range(goal + 1):
        if v[i]:
            count += 1
            if count == a:
                break

    if i < goal and v[i + 1] is False:
        v[i] = False
        v[i+1] = True

for i in range(goal + 1):
    if v[i]:
        print(i)

Submission status: Accepted

Solution code:
piece_num = int(input())                                # 駒の数
piece_pos_list = [int(s) for s in input().split()]      # 駒の位置リスト
ope_num = int(input())                                  # 操作回数
ope_list = [int(s) for s in input().split()]            # 操作の対象とする駒の番号リスト

MAX_SQUARE = 2019

for i in range(ope_num):
    if (piece_pos_list[ope_list[i] - 1] != MAX_SQUARE)\
       and ((piece_pos_list[ope_list[i] - 1] + 1) not in piece_pos_list):
        # 駒を1つ進める
        piece_pos_list[ope_list[i] - 1] += 1

# 結果を出力
for i in range(piece_num):
    print(piece_pos_list[i])

Submission status: Accepted

Solution code:
n = int(input())
a = [int(s) for s in input().split()]
m = int(input())
b = [int(r) for r in input().split()]

for i in range(m):
    h = a[b[i]-1] + 1
    if a.count(h) == 0 and h != 2020:
        a[b[i]-1] = h
for t in a:
    print(t)

Submission status: Accepted

Solution code:
N = int(input())
X = [int(x) for x in input().split()]
M = int(input())
A = [int(a) for a in input().split()]

for i in range(M):
    new_p = X[A[i]-1] + 1
    if new_p in X or new_p == 2020:
        continue
    X[A[i]-1] = new_p

for i in X:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
d = {i+1: v for i, v in enumerate(list(map(int, input().split())))}
m = int(input())
a = list(map(int, input().split()))

for i in a:
    if d[i]+1 not in d.values() and d[i] != 2019:
        d[i] += 1

print(*d.values(), sep="\n")

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
m = int(input())
a = list(map(int, input().split()))
for i in range(m):
    num = a[i]
    if x[num-1] + 1 in x:
        continue
    elif x[num-1] == 2019:
        continue
    else:
        x[num-1] += 1
for i in range(n):
    print(x[i])

Submission status: Accepted

Solution code:
N=int(input())
X=list(map(int,input().split()))
M=int(input())
A=list(map(int,input().split()))

for a in A:
    i=a-1
    mem=X[i]+1
    if mem in X or mem==2020:
        continue
    else:
        X[i]=mem
for x in X:
    print(x)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = int(input())
    xx = LI()
    m = int(input())
    aa = LI()
    line = [0] * 2020
    pos = [-1] * (n + 1)
    for a, x in enumerate(xx, 1):
        line[x] = a
        pos[a] = x
    for a in aa:
        if pos[a]==2019 or line[pos[a] + 1] != 0: continue
        line[pos[a]] = 0
        line[pos[a] + 1] = a
        pos[a] += 1
    for x in pos[1:]:
        print(x)

main()

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))

loc = [False] * 2020
for x in X:
    loc[x] = True

for m in range(M):
    now = X[A[m] - 1]
    new = X[A[m] - 1] + 1

    if now == 2019:
        continue

    if not loc[new]:
        X[A[m] - 1] = new
        loc[now] = False
        loc[new] = True

for x in X:
    print(x)

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split())) + [2020]
M = int(input())
A = list(map(int, input().split()))

for a in A:
    if X[a-1]+1 == X[a]: continue
    else: X[a-1] += 1
    
for x in X[:N]:
    print(x)

Submission status: Accepted

Solution code:
N=int(input()) #コマの個数
X=list(map(int, input().split())) #コマの場所
M=int(input()) #回数
A=list(map(int, input().split())) #どこの変化

for i in range(0,M):
    #print(A)
    #print(M)
    #print(X[A[i]-1])
    
    if (X[A[i]-1]+1 not in X) and X[A[i]-1]+1 <=2019:
        #print("not in",X[A[i]-1]+1,X)
        s=X[A[i]-1]
        X.insert(A[i],X[A[i]-1]+1)
        #print("X ",X)
        #print(s)
        X.remove(s)
        #print(X)

#print(" ")

X.sort()    
for i in range(len(X)):
    print(X[i])

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
m = int(input())
a = list(map(int, input().split()))

for i in a:
    if x[i-1]+1 in x or x[i-1] == 2019:
        pass
    else:
        x[i-1] += 1
for i in x:
    print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/python3

import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys


def main():
    N = read_int()
    X = read_ints()
    M = read_int()
    A = read_ints()
    print(*solve(N, X, M, A), sep='\n')


def solve(N, X, M, A):
    ar = [0] * 2020
    pos = [0] * (N + 1)
    for i, x in enumerate(X):
        ar[x] = i + 1
        pos[i + 1] = x

    for a in A:
        x = pos[a]
        if x != 2019 and ar[x + 1] == 0:
            ar[x] = 0
            ar[x + 1] = a
            pos[a] = x + 1

    return pos[1:]


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))
for x in A:
    if X[x-1] + 1 in X or X[x-1] == 2019:
        continue
    else:
        X[x-1] += 1
for i in range(N):
    print(X[i])

Submission status: Accepted

Solution code:
N=int(input())
X=list(map(int,input().split()))
M=int(input())
A=list(map(int,input().split()))
for i in range(M):
    X[A[i]-1]+=1
    if A[i]!=N:
        if X[A[i]-1]>=X[A[i]]:
            X[A[i]-1]=X[A[i]]-1
    if X[A[i]-1]>=2019:
        X[A[i]-1]=2019

for i in range(N):
    print(X[i])

Submission status: Accepted

Solution code:
import random
import math
N = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))


for i in range (M):
    if A[i] == N and (X[A[i]-1] != 2019): 
        X[A[i]-1]=1+X[A[i]-1]
    elif  X[A[i]-1]==2019:
        continue 
    elif X[A[i]-1]+1 != X[A[i]] :
        X[A[i]-1]+=1


for i in range (N):
    print(X[i])

Submission status: Accepted

Solution code:
n=int(input())
X=list(map(int,input().split()))
M=int(input())
A=list(map(int,input().split()))

for i in range (len(A)):
    for j in range(len(X)):
        cnt=0
        if A[i]==j+1:
            X[j]+=1
            for k in range (len(X)):
                if X[j]==X[k] and k!=j:
                    X[j]=X[j]-1
            if X[j]>2019:
                X[j]=X[j]-1
      
            
for i in range (len(X)):
    print(X[i])

Submission status: Accepted

Solution code:
N=int(input())

X=list(map(int,input().split()))

M=int(input())

A=list(map(int,input().split()))

for i in A:

    if ( (X[i-1]+1) in X) or (X[i-1]==2019):
        pass
    else:
        X[i-1]+=1

for i in range(N):
    print(X[i])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 学籍番号 17D8101029G 石塚 博之 ID: mcatpolo 言語: python3

N = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))



for i in range(0, M):
    if X[A[i]-1]+1 not in X and X[A[i]-1] < 2019:
        X[A[i]-1] += 1

for i in X:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
x=list(map(int,input().split()))
M=int(input())
a=list(map(int,input().split()))
F=True    
for i in a:
    for j in range(N):
        #print(x[i-1])
        if x[i-1]+1 == x[j] or x[i-1] ==2019:
            F=False
            break
    if F==True:
        x[i-1]+=1
    F=True
for i in range(N):
    print(x[i])

Submission status: Accepted

Solution code:
n=int(input())
X=[]
X=input().split()
X=[int(u) for u in X]
m=int(input())
A=[]
A=input().split()
A=[int(u) for u in A]
for i in range(0,m):
    a=A[i]
    p=0
    for u in range(a,n):
        if (X[a-1]+1)==X[u]:
            p=p+1
    if p==0:
        if X[a-1]!=2019:
            X[a-1]=X[a-1]+1
for i in range(0,n):
    print(X[i])

Submission status: Accepted

Solution code:
S = [0]*2020

n = int(input())
X = [int(a) for a in input().split()]
for a in X:
  S[a] = 1

m = int(input())
M = [int(a) for a in input().split()]
for i in M:
  i = i - 1
  if X[i]+1 != 2020:
    if S[X[i]+1] == 0:
      S[X[i]+1] = 1
      S[X[i]] = 0
      X[i] = X[i]+1

for i in range(2020):
  if S[i] == 1:
    print(i)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    x = [-1] + [int(i) for i in input().split()]
    x_set = set(x)
    M = int(input())
    A = [int(i) for i in input().split()]
    for i in range(M):
        posi = A[i]
        next_posi = x[posi] + 1
        if next_posi in x_set or next_posi > 2019:
            continue
        x_set.discard(x[posi])
        x_set.add(next_posi)
        x[posi] += 1

    print(*x[1:], sep="\n")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=int(input())
N=list(map(int,input().split(" ")))
b=int(input())
M=list(map(int,input().split(" ")))

#a=2
#N=[1,2016]
#b=4
#M=[2,2,2,2]

for index,i in enumerate(M):
#    print(i)
    if N[i-1]+1 in N or N[i-1]==2019:
#        print(N[i-1])
        continue
    else:
        N[i-1]+=1
    
for i in N:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
m=int(input())
a=list(map(int,input().split()))

for v in a:
    if x[v-1]+1 in x or x[v-1]==2019:
        x[v-1]=x[v-1]
    else:
        x[v-1]+=1
for i in range(n):
    print(x[i])

Submission status: Accepted

Solution code:
##petite_prig   ono takaki

#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    X=LI()
    M=I()
    A=LI_()

    exist=[0]*2021
    for i,x in enumerate(X):
        exist[x]+=1

    for a in A:
        where = X[a]
        if exist[where+1] or where == 2019:
            continue
        else:
            exist[where+1]+=1
            exist[where]-=1
            X[a]+=1
    print(*X,sep="\n")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
m = int(input())
a = list(map(int, input().split()))

for i in range(m):
    if x[a[i]-1]+1 in x or x[a[i]-1] == 2019:
        pass
    else:
        x[a[i]-1] += 1

for i in range(n):
    print(x[i])

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
m = int(input())
a = list(map(int, input().split()))

for mi in a:
    if x[mi-1] + 1 in x:
        pass
    else :
        x[mi-1] = min(2019, x[mi-1] + 1)

for i in x:
    print(i)

Submission status: Accepted

Solution code:
import sys

input()
x = list(map(int,sys.stdin.readline().split()))
input()
a = tuple(map(int,sys.stdin.readline().split()))
for i in range(len(a)):
    idx = a[i] - 1
    # print(idx, x[idx])
    if x[idx] == 2019:
        pass
    elif idx+1 == len(x):
        x[idx] += 1
    elif x[idx]+1 != x[idx+1]:
        x[idx] += 1

for i in x:
    print(i)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Sugoroku and Pieces
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0653

"""
import sys


class Piece:
    def __init__(self, pos):
        self.pos = pos


def main(args):
    _ = input()                 #  N
    board = [None] * 2020
    pieces = [Piece(0)]
    for p in map(int, input().split()):
        x = Piece(p)
        board[p] = x
        pieces.append(x)
    _ = input()                 #  M
    for p in map(int, input().split()):
        if pieces[p].pos == 2019 or board[pieces[p].pos + 1] != None:
            continue
        pos = pieces[p].pos
        pieces[p].pos += 1
        board[pos] = None
        board[pos + 1] = pieces[p]
    for p in pieces[1:]:
        print(p.pos)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
num = int(input())
L = [int(x) for x in input().split()]
L.append(2020)
input()
s = [int(x)-1 for x in input().split()]

for i in s:
    if L[i+1] > L[i] +1:
        L[i] += 1

for i in range(len(L) -1):
    print(L[i])

Submission status: Accepted

Solution code:
n = int(input())
Pieces = list(map(int, input().split()))

t = int(input())
commands = list(map(int, input().split()))

for piece in commands:
    if piece != len(Pieces):
        if (Pieces[piece-1]+1) == Pieces[piece] or (Pieces[piece-1]) == 2019:
            pass
        else:
            Pieces[piece-1]+=1
    else:
        if Pieces[piece-1] != 2019:
            Pieces[piece-1]+=1

for i in Pieces:
    print(i)

Submission status: Accepted

Solution code:
num=int(input())
koma_n=input().split()
koma_n = [int(s) for s in koma_n]
times=int(input())
which=input().split()
which  = [int(s) for s in which]

for i in range(times):
    flag=0
    for j in range(which[i]-1,num):
        if koma_n[which[i]-1]+1==koma_n[j]:
          flag=1
          break
   
    if flag==0 and koma_n[which[i]-1]<=2018:
        koma_n[which[i]-1]+=1

for i in range(num):
    print(koma_n[i])

Submission status: Accepted

Solution code:
N = int(input())
pieces = {}
X = list(map(int, input().split()))
for p in range(N):
    pieces.setdefault(p+1, X[p])
M = int(input())
move = list(map(int, input().split()))
for i in range(M):
    destination = pieces[move[i]] + 1
    if destination > 2019 or destination in pieces.values():
        continue
    pieces[move[i]] = destination
for i in range(N):
    print(pieces[i+1])

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))
m=int(input())
a=list(map(int,input().split()))
ax=[]
for j in range(m):
    if x[a[j]-1]+1 not in x and x[a[j]-1]<=2018:
        x[a[j]-1]+=1
for i in x:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
m = int(input())
a = list(map(int, input().split()))
output = [0] * 2019

for i in x:
    output[i - 1] = 1


for k in range(m):
    count = 0
    for l in range(2019):
        if output[l] == 1:
            count += 1


        if count == a[k]:
            if l == 2018:
                break

            if output[l + 1] == 0:
                output[l], output[l + 1] = 0, 1

for i in range(2019):
    if output[i] == 1:
        print(i + 1)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split())) + [2020]
m = int(input())
for i in map(int, input().split()): x[i-1]=min(x[i-1]+1,x[i]-1)
for i in range(n): print(x[i])

Submission status: Accepted

Solution code:
N = int(input())
p = [int(i) for i in input().split()]
input()
O = [int(i) for i in input().split()]
for x in O:
    if p[x - 1] == 2019:
        continue
    if x < N and p[x - 1] + 1 == p[x]:
        continue
    p[x - 1] += 1

for x in p:
    print(x)

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))

MAX = 2019
MIN = 1

for i in range(M):
    if (X[A[i] - 1] + 1 in X) == False and X[A[i] - 1] != MAX:
        X[A[i] - 1] += 1

for i in range(N):
    print(X[i])

Submission status: Accepted

Solution code:
n=int(input())
x=[int(i) for i in input().split()]

mas=[False]*2020
for i in x:
    mas[i]=True
m=int(input())
a=[int(i) for i in input().split()]

for i in range(m):
    now=x[a[i]-1]
    if now==2019:
        continue
    elif mas[now+1]:
        continue
    mas[now],mas[now+1]=False,True
    x[a[i]-1]+=1

for i in range(2020):
    if mas[i]:
        print(i)

Submission status: Accepted

Solution code:
a=int(input())
Xin=input().split( )
X=[int(Xin[i]) for i in range(a)]
 
X.append(2020)
b=int(input())
Ain=input().split( )
A=[int(Ain[i]) for i in range(b)]
 
for t in range(b):
    j=A[t]-1
    if X[j]<X[j+1]-1:
        X[j]+=1
for i in range(a):
    print(X[i])

Submission status: Accepted

Solution code:

def solve():
    N = int(input())
    X = [int(i) for i in input().split()]
    M = int(input())
    A = [int(i) for i in input().split()]
    for a in A:
        if not X[a - 1] + 1 in X:
            X[a - 1] = min(X[a - 1] + 1, 2019)
    for x in X:
        print(x)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int,input().split()))

mas=[False]*2022

for i in x:
    mas[i]=True

m=int(input())
a=list(map(int,input().split()))

for i in range(m):
    now=x[a[i]-1]
    if not mas[now+1] and now!=2019:
        mas[now]=False
        mas[now+1]=True
        x[a[i]-1]+=1

for i in range(2020):
    if mas[i]:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split()))
M = int(input())
A = list(map(int, input().split()))

for i in range(M) :
  num = A[i] - 1
  x = X[num]
  if(x + 1 in X or x == 2019) :
    pass
  else :
    X[num] = x + 1

for i in range(N) :
  print(X[i])

Submission status: Accepted

Solution code:
N=int(input())
Xin=input().split( )
X=[int(Xin[i]) for i in range(N)]

X.append(2020)
M=int(input())
Ain=input().split( )
A=[int(Ain[i]) for i in range(M)]

for t in range(M):
    j=A[t]-1
    if X[j]<X[j+1]-1:
        X[j]+=1
for i in range(N):
    print(X[i])

Submission status: Accepted

Solution code:
tmp = [2020]*101
n = int(input())
X = list(map(int, input().split()))
m = int(input())
A = list(map(int, input().split()))
for i in range(n):
    tmp[i] = X[i]

for i in range(m):
    if (tmp[A[i]-1]+1) < tmp[A[i]]:
        tmp[A[i]-1] += 1

for i in range(n):
    print(tmp[i])

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
def keisan(a,b):
    
    if a>2019:
        return True
    
    i=0
    while i<len(b):
        if b[i]==a :
            return True
        i+=1
    
    return False
    


koma_kazu=int(input()) #3

koma=input().rstrip().split()
komaI=[int(s) for s in koma]  #2,3,6

idou_kazu=int(input()) #2

idou=input().rstrip().split()
idouI=[int(s) for s in idou] #1,3


i=0
while i<idou_kazu:
    #if komaI[idouI[i]-1]+1 in komaI==False:
    if keisan(komaI[idouI[i]-1]+1,komaI)==False:
        komaI[idouI[i]-1]+=1
    i+=1

i=0
while i<koma_kazu:
    print(komaI[i])
    i+=1

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys


def main():
    n = int(input())
    arrx = list(map(int,input().split()))
    m = input()
    arra = list(map(int,input().split()))
    for i in arra:
        if(i == n ):
            if(arrx[i-1] < 2019):
                arrx[i-1] += 1
        else:
            if(arrx[i-1] + 1 < arrx[i] and arrx[i-1] < 2019):
                arrx[i-1] += 1
    for i in arrx:
        print(i)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
xlst = list(map(int, input().split()))
m = int(input())
alst = list(map(int, input().split()))
for a in alst:
    if (a == n or xlst[a] - xlst[a - 1] > 1) and xlst[a - 1] < 2019:
        xlst[a - 1] += 1

print(*xlst, sep="\n")

Submission status: Accepted

Solution code:
N = int(input())
koma = list(map(int, input().split()))
M = int(input())
order = list(map(int, input().split()))
koma.append(0)

for i in range(M):
    koma[order[i]-1] += 1
    if koma[order[i]-1] == koma[order[i]] or koma[order[i]-1] == 2020:
        koma[order[i]-1] -= 1

del koma[-1]
for v in koma:
    print(v)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int,input().split()))
m = int(input())
a = list(map(int,input().split()))

for i in range(m):
    a[i] -= 1

for i in a:
    if i == n-1:
        x[i] = min(x[i]+1, 2019)
    else:
        x[i] = min(x[i]+1, x[i+1]-1)

for i in x:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
X=list(map(int,input().split()))
M=int(input())
A=list(map(int,input().split()))
A=[A[i]-1 for i in range(len(A))]

for i in range(M):
    l=A[i]
    if X[l]+1 not in X and X[l]!=2019:
        X[l]+=1
print(format("\n".join(map(str,X))))

Submission status: Accepted

Solution code:
n=int(input())
koma=list(map(int,input().split()))
koma.append(2020)
m=int(input())
mi=list(map(int,input().split()))
for i in mi:
    if koma[i]>koma[i-1]+1:
        koma[i-1]+=1
koma.remove(2020)
for i in koma:
    print(i)

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main(){
	int board[2020];
	for(int i = 0; i < 2020; i++){
		board[i] = 0;
	}
	int N;
	cin >> N;
	int tkn[N];
	for(int i = 0; i < N; i++){
		int p = 0;
		cin >> p;
		tkn[i] = p;
		board[p] = i + 1;
	}
	int M;
	cin >> M;
	for(int i = 0; i < M; i++){
		int move;
		cin >> move;
		if(tkn[move-1] != 2019){
			if(board[tkn[move-1]+1] == 0){
				board[tkn[move-1]+1] = move;
				board[tkn[move-1]] = 0;
				tkn[move-1]++;
			}
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < 2020; j++){
			if(board[j] == i){
				cout << j << "\n";
				break;
			}
		}
	}
}