結果
| 問題 |
No.228 ゆきこちゃんの 15 パズル
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-19 22:41:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 698 bytes |
| コンパイル時間 | 525 ms |
| コンパイル使用メモリ | 58,684 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 04:07:32 |
| 合計ジャッジ時間 | 1,195 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 6 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int grid[16];
int vec[4] = {1, -1, 4, -1};
int current;
for(int i = 0; i < 16; i++){
cin >> grid[i];
if(grid[i] == 0)
current = i;
}
for(int i = 0; i < 16; i++){
for(int j = 0; j < 4; j++){
if(current + vec[j] >= 0 && current + vec[j] < 16
&& grid[current + vec[j]] == current + 1){
swap(grid[current], grid[current + vec[j]]);
current += vec[j];
break;
}
}
}
bool result = true;
for(int i = 0; i < 15; i++){
if(grid[i] != i + 1)
result = false;
}
if(result)
cout << "Yes" << endl;
else
cout << "No" << endl;
}