結果
問題 | No.228 ゆきこちゃんの 15 パズル |
ユーザー | dnish |
提出日時 | 2018-06-18 10:34:57 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,241 bytes |
コンパイル時間 | 1,591 ms |
コンパイル使用メモリ | 166,440 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-13 06:42:51 |
合計ジャッジ時間 | 2,363 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,380 KB |
testcase_13 | AC | 1 ms
4,376 KB |
testcase_14 | AC | 1 ms
4,380 KB |
testcase_15 | AC | 1 ms
4,376 KB |
testcase_16 | AC | 2 ms
4,376 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 1 ms
4,376 KB |
testcase_19 | AC | 1 ms
4,380 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:28:19: 警告: ‘x’ may be used uninitialized [-Wmaybe-uninitialized] 28 | if(y==3&&x==3) break; | ~^~~ main.cpp:16:12: 備考: ‘x’ はここで定義されています 16 | int y, x; | ^ main.cpp:28:13: 警告: ‘y’ may be used uninitialized [-Wmaybe-uninitialized] 28 | if(y==3&&x==3) break; | ~^~~ main.cpp:16:9: 備考: ‘y’ はここで定義されています 16 | int y, x; | ^
ソースコード
#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<<endl #define p2(a,b) cout<<(a)<<" "<<(b)<<endl typedef long long ll; using namespace std; const ll inf=1e18; int a[4][4]; int dx[] ={1,0,-1,0}; int dy[] ={0,1,0,-1}; int main(){ int y, x; REP(i,0,4){ REP(j,0,4){ cin>>a[i][j]; if(a[i][j]==0){ y=i; x=j; } } } string ans="Yes"; REP(i,0,16){ if(y==3&&x==3) break; bool f=false; REP(k,0,4){ int ny=y+dy[k]; int nx=x+dx[k]; if(!CK(ny,0,4)||!CK(nx,0,4)) continue; if(a[ny][nx]==y*4+x+1){ swap(a[ny][nx],a[y][x]); y=ny; x=nx; f=true; break; } } if(!f){ ans="No"; break; } } REP(i,0,4){ REP(j,0,4){ if(i==3&&j==3) break; if(a[i][j]!=i*4+j+1){ ans="No"; } } } p(ans); return 0; }