結果
| 問題 | No.228 ゆきこちゃんの 15 パズル |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-19 22:38:47 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 1,463 bytes |
| 記録 | |
| コンパイル時間 | 763 ms |
| コンパイル使用メモリ | 113,372 KB |
| 実行使用メモリ | 6,144 KB |
| 最終ジャッジ日時 | 2026-03-28 18:34:03 |
| 合計ジャッジ時間 | 1,264 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/allocator.h:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bitset:54,
from main.cpp:2:
In member function 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<int, int>; _Args = {std::pair<int, int>}; _Tp = std::pair<int, int>]',
inlined from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<int, int>; _Args = {std::pair<int, int>}; _Tp = std::pair<int, int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/alloc_traits.h:674:17,
inlined from 'void std::deque<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {std::pair<int, int>}; _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/deque.tcc:170:30,
inlined from 'void std::deque<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_deque.h:1621:21,
inlined from 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::deque<std::pair<int, int>, std::allocator<std::pair<int, int> > >]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_queue.h:318:20,
inlined from 'int main()' at main.cpp:52:11:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/new_allocator.h:191:11: warning: 'sy' may be used uninitialized [-Wmaybe-uninitialized]
191 | { ::new((void *)__p) _Up(std::forward<_Args>
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;
int a[4][4];
int c[4][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15, 0}};
int dp[4][4];
int main(void){
int sx = -1, sy;
REP(i, 0, 4) {
REP(j , 0, 4) {
cin >> a[i][j];
dp[i][j] = a[i][j] != c[i][j];
if (a[i][j] == 0) {
sx = i;
sy = j;
}
}
}
queue<PI> que;
que.push(PI(sx, sy));
int dx[4] = {1,0,-1,0}, dy[4] = {0, 1, 0, -1};
while (!que.empty()) {
PI p = que.front(); que.pop();
REP(i, 0, 4 ) {
int nx = p.first + dx[i];
int ny = p.second + dy[i];
dp[p.first][p.second] = 0;
if (nx < 0 || nx >= 4 || ny < 0 || ny >= 4 || dp[nx][ny] == 0) {
continue;
}
if (a[nx][ny] == c[p.first][p.second]) {
que.push(PI(nx, ny));
break;
}
}
}
bool ok = 1;
REP(i, 0, 4) REP(j, 0, 4) {
ok &= ! dp[i][j];
}
cout << (ok ? "Yes" : "No") << endl;
}