結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー yaoshimaxyaoshimax
提出日時 2015-06-19 22:59:34
言語 Python2
(2.7.18)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 778 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 6,680 KB
実行使用メモリ 6,044 KB
最終ジャッジ日時 2023-09-21 10:05:17
合計ジャッジ時間 1,273 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,844 KB
testcase_01 AC 10 ms
6,044 KB
testcase_02 AC 11 ms
5,964 KB
testcase_03 AC 11 ms
5,848 KB
testcase_04 AC 10 ms
5,844 KB
testcase_05 AC 10 ms
5,968 KB
testcase_06 AC 10 ms
5,844 KB
testcase_07 AC 10 ms
5,856 KB
testcase_08 AC 10 ms
5,928 KB
testcase_09 AC 10 ms
5,848 KB
testcase_10 AC 10 ms
5,836 KB
testcase_11 AC 10 ms
5,848 KB
testcase_12 AC 10 ms
5,888 KB
testcase_13 AC 10 ms
6,024 KB
testcase_14 AC 11 ms
5,840 KB
testcase_15 AC 10 ms
6,020 KB
testcase_16 AC 10 ms
5,888 KB
testcase_17 AC 10 ms
5,988 KB
testcase_18 AC 10 ms
5,884 KB
testcase_19 AC 10 ms
6,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

table=[map(int,raw_input().split()) for i in range(4)]
default=[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,0]]
x,y=3,3
d=[(0,1),(0,-1),(1,0),(-1,0)]
while table[x][y]!=0:
    ok = False
    for dx,dy in d:
        #print dx,dy
        nx,ny=x+dx,y+dy
        if nx>=0 and ny>=0 and nx <4 and ny<4:
            if default[nx][ny]==table[x][y]:
                ok=True
                #print nx,ny,"<=>",x,y
                default[nx][ny],default[x][y]=default[x][y],default[nx][ny]
                x,y=nx,ny
                break
    if ok==False:
        break
yes=True
for i in range(4):
    for j in range(4):
        #print default[i][j],
        if table[i][j]!=default[i][j]:
            yes=False
            break
    #print
if yes:
    print "Yes"
else:
    print "No"
0