結果
| 問題 | No.228 ゆきこちゃんの 15 パズル | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-06-15 04:07:57 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 355 bytes | 
| コンパイル時間 | 533 ms | 
| コンパイル使用メモリ | 68,224 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-30 14:41:48 | 
| 合計ジャッジ時間 | 1,500 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~
            
            ソースコード
#include<iostream>
#include<algorithm>
using namespace std;
int a[16],cnt;
main()
{
	for(int i=0;i<16;i++)
	{
		cin>>a[i];a[i]--;
		if(a[i]<0)continue;
		int d=abs(i/4-a[i]/4)+abs(i%4-a[i]%4);
		if(d>1)
		{
			cout<<"No"<<endl;
			return 0;
		}
		else if(d>0)cnt++;
	}
	int next=15;
	for(;next!=-1;next=a[next])cnt--;
	cout<<(cnt==-1?"Yes":"No")<<endl;
}
            
            
            
        