結果
| 問題 |
No.228 ゆきこちゃんの 15 パズル
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-01-11 01:50:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 765 bytes |
| コンパイル時間 | 667 ms |
| コンパイル使用メモリ | 82,236 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-18 01:09:22 |
| 合計ジャッジ時間 | 1,442 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 17 |
ソースコード
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
//#include<bits/stdc++.h>
using namespace std;
int main() {
int t[20] = {};
int s = 0;
for (int i = 0; i < 16; i++) {
int x;
cin >> x;
x--;
if (x >= 0) {
int d = abs(i / 4 - x / 4) + abs(i % 4 - x % 4);
if (d > 1) { cout << "NO" << endl; return 0; }
if(d>0)s++;
}
t[i] = x;
}
int w = -1;
while (w != 15) {
for (int i = 0; i < 16; i++) {
if (t[i] == w) {
w = i;
s--;
break;
}
}
}
if (s == -1)cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}