結果
問題 | No.228 ゆきこちゃんの 15 パズル |
ユーザー |
![]() |
提出日時 | 2020-03-22 19:25:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 683 bytes |
コンパイル時間 | 2,372 ms |
コンパイル使用メモリ | 196,448 KB |
最終ジャッジ日時 | 2025-01-09 09:38:52 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include<bits/stdc++.h> using lint=long long; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); std::vector<lint>a(16); for(lint i=0;i<16;i++){ lint x;std::cin>>x; a.at(i)=x?x-1:15; } while(!std::is_sorted(a.begin(),a.end())){ lint i=std::find(a.begin(),a.end(),15)-a.begin(); lint j=std::find(a.begin(),a.end(),i)-a.begin(); if(std::abs(i-j)==4||std::abs(i-j)==1&&i/4==j/4){ std::swap(a.at(i),a.at(j)); }else{ std::cout<<"No"<<'\n'; return 0; } } std::cout<<"Yes"<<'\n'; }