結果
問題 | No.228 ゆきこちゃんの 15 パズル |
ユーザー |
|
提出日時 | 2017-01-11 01:50:39 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 765 bytes |
コンパイル時間 | 681 ms |
コンパイル使用メモリ | 82,152 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-18 01:09:40 |
合計ジャッジ時間 | 1,465 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 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; }