結果
問題 | No.228 ゆきこちゃんの 15 パズル |
ユーザー | FF256grhy |
提出日時 | 2015-06-20 00:18:25 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 920 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 26,640 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-21 10:24:04 |
合計ジャッジ時間 | 1,129 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,384 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,380 KB |
testcase_13 | AC | 1 ms
4,376 KB |
testcase_14 | AC | 1 ms
4,380 KB |
testcase_15 | AC | 2 ms
4,380 KB |
testcase_16 | AC | 2 ms
4,376 KB |
testcase_17 | AC | 1 ms
4,376 KB |
testcase_18 | AC | 1 ms
4,376 KB |
testcase_19 | AC | 2 ms
4,376 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:27:55: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized] if(a[ x + dx[i] ][ y + dy[i] ] == (x - 1) + 4 * (y - 1) + 1) { ~~~^~~~ main.cpp:27:41: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized] if(a[ x + dx[i] ][ y + dy[i] ] == (x - 1) + 4 * (y - 1) + 1) { ~~~^~~~
ソースコード
#include <stdio.h> int a[6][6]; int complete(); int main(void) { int i, j, x, y; for(j = 0; j < 6; j++) { for(i = 0; i < 6; i++) { a[i][j] = 0; // 番兵 } } for(j = 1; j <= 4; j++) { for(i = 1; i <= 4; i++) { scanf("%d", &a[i][j]); if(a[i][j] == 0) { x = i; y = j; } // x, yに空きマスの位置をメモ if(a[i][j] == (i - 1) + 4 * (j - 1) + 1) { a[i][j] = 0; } // 正しい位置にあるものを0に } } int dx[4] = {+1, -1, 0, 0}; int dy[4] = { 0, 0, +1, -1}; while(1) { int flag = 0; for(i = 0; i < 4; i++) { if(a[ x + dx[i] ][ y + dy[i] ] == (x - 1) + 4 * (y - 1) + 1) { a[ x + dx[i] ][ y + dy[i] ] = 0; x += dx[i]; y += dy[i]; flag = 1; continue; } } if(!flag) { break; } } int flag = 1; for(j = 1; j <= 4; j++) { for(i = 1; i <= 4; i++) { if(a[i][j] > 0) { flag = 0; break; } } } printf("%s\n", flag ? "Yes" : "No"); return 0; }