結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー hirokazu1020hirokazu1020
提出日時 2015-06-19 22:40:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 942 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 75,408 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 09:59:57
合計ジャッジ時間 1,430 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:12: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
  char *ans="Yes";
            ^~~~~
main.cpp:52:8: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
    ans="No";
        ^~~~

ソースコード

diff #

#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define indexOf(v,x) (find(all(v),x)-v.begin())




int main(){
	bool mv[16]={};
	int a[4][4];
	rep(y,4)rep(x,4)cin>>a[y][x];
	char *ans="Yes";
	rep(i,16)rep(y,4)rep(x,4){
		int d=a[y][x];
		if(d==0)continue;
		d--;
		int dy,dx;
		dy=d/4;
		dx=d%4;
		if(abs(dy-y)+abs(dx-x)==1 && !mv[d] && a[dy][dx]==0){
			a[dy][dx]=d+1;
			a[y][x]=0;
			mv[d]=true;
		}
		
	}
	rep(y,4)rep(x,4){
		int d=a[y][x];
		if(d==0)continue;
		d--;
		int dy,dx;
		dy=d/4;
		dx=d%4;
		if(y!=dy||x!=dx){
			ans="No";
		}
		
	}

	cout<<ans<<endl;
	return 0;
}
0