結果
| 問題 |
No.228 ゆきこちゃんの 15 パズル
|
| コンテスト | |
| ユーザー |
reew2n
|
| 提出日時 | 2015-06-19 22:34:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 929 bytes |
| コンパイル時間 | 1,194 ms |
| コンパイル使用メモリ | 159,916 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 04:06:55 |
| 合計ジャッジ時間 | 1,708 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 17 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<pr,ut> ppr;
typedef vector<ppr> Vppr;
typedef priority_queue<ppr,Vppr,greater<ppr> > PQ;
const int INF=1e+9;
int ans[5][5],an[5][5];
int dx[]={0,0,1,-1},dy[]={1,-1,0,0};
int main(){
FOR(i,1,5)
FOR(j,1,5)
cin >> an[i][j];
int now=1;
FOR(i,1,5)
FOR(j,1,5)
ans[i][j]=now++;
ans[4][4]=0;
REP(l,20){
FOR(i,1,5)
FOR(j,1,5)
REP(k,4)
if(an[i][j]==0 && an[i+dy[k]][j+dx[k]]==ans[i][j])
swap(an[i][j],an[i+dy[k]][j+dx[k]]);
}
bool diff=false;
FOR(i,1,5)
FOR(j,1,5)
if(an[i][j]!=ans[i][j]) diff=true;
if(diff)
cout << "NO" << endl;
else
cout <<"YES" << endl;
}
reew2n