submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s326433700 | p00121 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
map<string, int> dp;
int direction[4] = { 1, -1, 4, -4 };
//************************************
// Method: bfs
// FullName: bfs
// Access: public
// Returns: void
// Qualifier: 隶ゥ0貍ォ貂ク謨エ荳ェ蟄嶺クイ
//************************************
void bfs()
{
queue<string> que;
que.push("01234567");
dp["01234567"] = 0;
while (!que.empty())
{
string now = que.front(); que.pop();
// p譏ッ'0'逧?ス咲スョ
int p = 0;
for (int j = 0; j < 8; ++j)
{
if (now[j] == '0')
{
p = j;
break;
}
}
for (int i = 0; i < 4; ++i)
{
int n = p + direction[i];
if (0 <= n && n < 8 &&
!(p == 3 && i == 0) && // 蜿ウ荳願ァ剃ク崎?蜀榊セ?承莠? !(p == 4 && i == 1)) // 蟾ヲ荳玖ァ剃ク崎?蜀榊セ?キヲ莠? {
string next = now;
swap(next[p], next[n]);
if (dp.find(next) == dp.end())
{
dp[next] = dp[now] + 1;
que.push(next);
}
}
}
}
}
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
bfs();
string line;
while (getline(cin, line))
{
line.erase(remove(line.begin(), line.end(), ' '), line.end());
cout << dp[line] << endl;
}
return 0;
} | a.cc: In function 'void bfs()':
a.cc:42:24: error: expected primary-expression before 'next'
42 | string next = now;
| ^~~~
a.cc:43:26: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
43 | swap(next[p], next[n]);
| ^
a.cc:43:35: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
43 | swap(next[p], next[n]);
| ^
a.cc:43:39: error: expected ')' before ';' token
43 | swap(next[p], next[n]);
| ^
| )
a.cc:40:16: note: to match this '('
40 | if (0 <= n && n < 8 &&
| ^
a.cc:44:28: error: no matching function for call to 'std::map<std::__cxx11::basic_string<char>, int>::find(<unresolved overloaded function type>)'
44 | if (dp.find(next) == dp.end())
| ~~~~~~~^~~~~~
In file included from /usr/include/c++/14/map:63,
from a.cc:4:
/usr/include/c++/14/bits/stl_map.h:1224:9: note: candidate: 'template<class _Kt> decltype (((std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_find_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::find(const _Kt&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >]'
1224 | find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
| ^~~~
/usr/include/c++/14/bits/stl_map.h:1224:9: note: template argument deduction/substitution failed:
a.cc:44:28: note: couldn't deduce template parameter '_Kt'
44 | if (dp.find(next) == dp.end())
| ~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_map.h:1249:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_find_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::find(const _Kt&) const [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >]'
1249 | find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x))
| ^~~~
/usr/include/c++/14/bits/stl_map.h:1249:9: note: template argument deduction/substitution failed:
a.cc:44:28: note: couldn't deduce template parameter '_Kt'
44 | if (dp.find(next) == dp.end())
| ~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_map.h:1218:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::iterator std::map<_Key, _Tp, _Compare, _Alloc>::find(const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; iterator = std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::iterator; key_type = std::__cxx11::basic_string<char>]'
1218 | find(const key_type& __x)
| ^~~~
/usr/include/c++/14/bits/stl_map.h:1218:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const std::map<std::__cxx11::basic_string<char>, int>::key_type&' {aka 'const std::__cxx11::basic_string<char>&'}
1218 | find(const key_type& __x)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:1243:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::const_iterator std::map<_Key, _Tp, _Compare, _Alloc>::find(const key_type&) const [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; const_iterator = std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >::const_iterator; key_type = std::__cxx11::basic_string<char>]'
1243 | find(const key_type& __x) const
| ^~~~
/usr/include/c++/14/bits/stl_map.h:1243:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const std::map<std::__cxx11::basic_string<char>, int>::key_type&' {aka 'const std::__cxx11::basic_string<char>&'}
1243 | find(const key_type& __x) const
| ~~~~~~~~~~~~~~~~^~~
a.cc:46:23: error: no match for 'operator[]' (operand types are 'std::map<std::__cxx11::basic_string<char>, int>' and '<unresolved overloaded function type>')
46 | dp[next] = dp[now] + 1;
| ^
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; mapped_type = int; key_type = std::__cxx11::basic_string<char>]'
504 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const std::map<std::__cxx11::basic_string<char>, int>::key_type&' {aka 'const std::__cxx11::basic_string<char>&'}
504 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; mapped_type = int; key_type = std::__cxx11::basic_string<char>]'
524 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::map<std::__cxx11::basic_string<char>, int>::key_type&&' {aka 'std::__cxx11::basic_string<char>&&'}
524 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
a.cc:47:29: error: no matching function for call to 'std::queue<std::__cxx11::basic_string<char> >::push(<unresolved overloaded function type>)'
47 | que.push(next);
| ~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/queue:66,
from a.cc:5:
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >; value_type = std::__cxx11::basic_string<char>]'
283 | push(const value_type& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const std::queue<std::__cxx11::basic_string<char> >::value_type&' {aka 'const std::__cxx11::basic_string<char>&'}
283 | push(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::__cxx11::basic_string<char>; _Sequence = std::deque<std::__cxx11::basic_string<char>, std::allocator<std::__cxx11::basic_string<char> > >; value_type = std::__cxx11::basic_string<char>]'
288 | push(value_type&& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::queue<std::__cxx11::basic_string<char> >::value_type&&' {aka 'std::__cxx11::basic_string<char>&&'}
288 | push(value_type&& __x)
| ~~~~~~~~~~~~~^~~
a.cc: At global scope:
a.cc:52:1: error: expected declaration before '}' token
52 | }
| ^
|
s997566647 | p00121 | C++ | #include<iostream>
#include<queue>
using namespace std;
bool acceptable(int** p) {
for (int j = 0; j < 2; j++)
for (int i = 0; i < 4; i++)
if (p[i][j] != j * 4 + i) return false;
return true;
}
int** move_0_up(int** p) {
int val[4][2];
for (int j = 0; j < 2; j++)
for (int i = 0; i < 4; i++)
val[i][j] = p[i][j];
int x, y;
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 4; i++) {
if (p[i][j] == 0) {
x = i; y = j;
}
}
}
val[x][y] = p[x][(y == 0)? 1:0];
val[x][(y == 0)? 1:0] = 0;
return val;
}
int** move_0_right(int** p) {
int val[4][2];
for (int j = 0; j < 2; j++)
for (int i = 0; i < 4; i++)
val[i][j] = p[i][j];
int x, y;
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 4; i++) {
if (p[i][j] == 0) {
x = i; y = j;
}
}
}
if (x == 3) return val;
val[x][y] = p[x+1][y] | a.cc: In function 'int** move_0_up(int**)':
a.cc:32:10: error: cannot convert 'int (*)[2]' to 'int**' in return
32 | return val;
| ^~~
| |
| int (*)[2]
a.cc: In function 'int** move_0_right(int**)':
a.cc:51:22: error: cannot convert 'int (*)[2]' to 'int**' in return
51 | if (x == 3) return val;
| ^~~
| |
| int (*)[2]
a.cc:53:24: error: expected ';' at end of input
53 | val[x][y] = p[x+1][y]
| ^
| ;
a.cc:53:24: error: expected '}' at end of input
a.cc:35:29: note: to match this '{'
35 | int** move_0_right(int** p) {
| ^
|
s720297321 | p00121 | C++ | #include<iostream>
#include<queue>
using namespace std;
bool acceptable(int** p) {
for (int j = 0; j < 2; j++)
for (int i = 0; i < 4; i++)
if (p[i][j] != j * 4 + i) return false;
return true;
}
int** move_0_up(int** p) {
int val[4][2];
for (int j = 0; j < 2; j++)
for (int i = 0; i < 4; i++)
val[i][j] = p[i][j];
int x, y;
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 4; i++) {
if (p[i][j] == 0) {
x = i; y = j;
}
}
}
val[x][y] = p[x][(y == 0)? 1:0];
val[x][(y == 0)? 1:0] = 0;
return val;
}
int** move_0_right(int** p) {
int val[4][2];
for (int j = 0; j < 2; j++)
for (int i = 0; i < 4; i++)
val[i][j] = p[i][j];
int x, y;
for (int j = 0; j < 2; j++) {
for (int i = 0; i < 4; i++) {
if (p[i][j] == 0) {
x = i; y = j;
}
}
}
if (x == 3) return val;
val[x][y] = p[x+1][y] | a.cc: In function 'int** move_0_up(int**)':
a.cc:32:10: error: cannot convert 'int (*)[2]' to 'int**' in return
32 | return val;
| ^~~
| |
| int (*)[2]
a.cc: In function 'int** move_0_right(int**)':
a.cc:51:22: error: cannot convert 'int (*)[2]' to 'int**' in return
51 | if (x == 3) return val;
| ^~~
| |
| int (*)[2]
a.cc:53:24: error: expected ';' at end of input
53 | val[x][y] = p[x+1][y]
| ^
| ;
a.cc:53:24: error: expected '}' at end of input
a.cc:35:29: note: to match this '{'
35 | int** move_0_right(int** p) {
| ^
|
s474404528 | p00121 | C++ | //AOJ 0121
//include
#include<bits/stdc++.h>
//using
using namespace std;
//define static const typedef
#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define DUMP(x) cerr << #x << " = " << x << "\n";
#define DEBUG(x) cerr << #x << " = " << x << " (L:" << __LINE__ << ") " << __FILE__ << "\n";
#define F first
#define S second
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
static const int INF = 1 << 25;
//global
static VI clear;
static VVI move(8);
static VI now(8);
static int b;
static queue<pair<pair<VI, int>, int> > q;
//function
int main(){
REP(i, 8){
clear.PB(i);
}
move[0].PB(1);
move[0].PB(4);
move[1].PB(0);
move[1].PB(2);
move[1].PB(5);
move[2].PB(1);
move[2].PB(3);
move[2].PB(6);
move[3].PB(2);
move[3].PB(7);
move[4].PB(0);
move[4].PB(5);
move[5].PB(1);
move[5].PB(4);
move[5].PB(6);
move[6].PB(2);
move[6].PB(5);
move[6].PB(7);
move[7].PB(3);
move[7].PB(6);
while(scanf("%d %d %d %d %d %d %d %d", &now[0], &now[1], &now[2], & now[3], &now[4], &now[5], &now[6], &now[7]) != EOF){
REP(i, 8){
if(!now[i]){
b = i;
break;
}
}
VI copy = now;
if(now == clear){
printf("0\n");
continue;
}
int d;
{
map<VI, int> ans;
ans[clear] = INF;
q.push(pair<pair<VI, int>, int>(pair<VI, int>(now, 0),b));
while(!q.empty()){
now = q.front().F.F;
int a = q.front().F.S;
b = q.front().S;
q.pop();
if(!ans[now] || (ans[now] > a && ans[clear] > a)){
ans[now] = a;
}
else if(ans[clear] == a){
break;
}
else{
continue;
}
//cout << "a = " << a << " b = " << b << "\n";
REP(i, move[b].size()){
int tmp = move[b][i];
swap(now[tmp], now[b]);
q.push(pair<pair<VI, int>, int>(pair<VI, int>(now, a + 1), tmp));
swap(now[tmp], now[b]);
}
}
d = ans[clear];
}
dp[now] = d;
printf("%d\n", d);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:47:3: error: reference to 'move' is ambiguous
47 | move[0].PB(1);
| ^~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
In file included from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:48:3: error: reference to 'move' is ambiguous
48 | move[0].PB(4);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:49:3: error: reference to 'move' is ambiguous
49 | move[1].PB(0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:50:3: error: reference to 'move' is ambiguous
50 | move[1].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:51:3: error: reference to 'move' is ambiguous
51 | move[1].PB(5);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:52:3: error: reference to 'move' is ambiguous
52 | move[2].PB(1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:53:3: error: reference to 'move' is ambiguous
53 | move[2].PB(3);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:54:3: error: reference to 'move' is ambiguous
54 | move[2].PB(6);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:55:3: error: reference to 'move' is ambiguous
55 | move[3].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:56:3: error: reference to 'move' is ambiguous
56 | move[3].PB(7);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class |
s599007281 | p00121 | C++ | //AOJ 0121
//include
#include<bits/stdc++.h>
//using
using namespace std;
//define static const typedef
#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define DUMP(x) cerr << #x << " = " << x << "\n";
#define DEBUG(x) cerr << #x << " = " << x << " (L:" << __LINE__ << ") " << __FILE__ << "\n";
#define F first
#define S second
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
static const int INF = 1 << 25;
//global
static int clear[8];
static VVI move(8);
static int now[8];
static int b;
static queue<pair<pair<VI, int>, int> > q;
static map<VI, int> ans;
static map<VI, int> cp;
//function
int main(){
REP(i, 8){
clear[i] = i;
}
move[0].PB(1);
move[0].PB(4);
move[1].PB(0);
move[1].PB(2);
move[1].PB(5);
move[2].PB(1);
move[2].PB(3);
move[2].PB(6);
move[3].PB(2);
move[3].PB(7);
move[4].PB(0);
move[4].PB(5);
move[5].PB(1);
move[5].PB(4);
move[5].PB(6);
move[6].PB(2);
move[6].PB(5);
move[6].PB(7);
move[7].PB(3);
move[7].PB(6);
while(scanf("%d %d %d %d %d %d %d %d", &now[0], &now[1], &now[2], & now[3], &now[4], &now[5], &now[6], &now[7]) != EOF){
REP(i, 8){
if(!now[i]){
b = i;
break;
}
}
if(now == clear){
printf("0\n");
continue;
}
int d;
{
ans = cp;
ans[clear] = INF;
q.push(pair<pair<VI, int>, int>(pair<VI, int>(VI(now), 0),b));
while(!q.empty()){
now = q.front().F.F;
int a = q.front().F.S;
b = q.front().S;
q.pop();
if(!ans[now] || (ans[now] > a && ans[clear] > a)){
ans[now] = a;
}
else if(ans[clear] == a){
break;
}
else{
continue;
}
//cout << "a = " << a << " b = " << b << "\n";
REP(i, move[b].size()){
int tmp = move[b][i];
swap(now[tmp], now[b]);
q.push(pair<pair<VI, int>, int>(pair<VI, int>(VI(now), a + 1), tmp));
swap(now[tmp], now[b]);
}
}
d = ans[clear];
}
printf("%d\n", d);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:49:3: error: reference to 'move' is ambiguous
49 | move[0].PB(1);
| ^~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
In file included from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:50:3: error: reference to 'move' is ambiguous
50 | move[0].PB(4);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:51:3: error: reference to 'move' is ambiguous
51 | move[1].PB(0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:52:3: error: reference to 'move' is ambiguous
52 | move[1].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:53:3: error: reference to 'move' is ambiguous
53 | move[1].PB(5);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:54:3: error: reference to 'move' is ambiguous
54 | move[2].PB(1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:55:3: error: reference to 'move' is ambiguous
55 | move[2].PB(3);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:56:3: error: reference to 'move' is ambiguous
56 | move[2].PB(6);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:57:3: error: reference to 'move' is ambiguous
57 | move[3].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:12: note: 'VVI move'
38 | static VVI move(8);
| ^~~~
a.cc:58:3: error: reference to 'move' is ambiguous
58 | move[3].PB(7);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class |
s237930880 | p00121 | C++ | //AOJ 0121
//include
#include<bits/stdc++.h>
//using
using namespace std;
//define static const typedef
#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define DUMP(x) cerr << #x << " = " << x << "\n";
#define DEBUG(x) cerr << #x << " = " << x << " (L:" << __LINE__ << ") " << __FILE__ << "\n";
#define F first
#define S second
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
static const int INF = 1 << 25;
//global
static vector<short> clear(8);
static vector<vector<short> > move(8);
static vector<short> now(8);
static int b;
static queue<pair<pair<vector<short>, int>, int> > q;
static map<vector<short>, int> ans;
static map<vector<short>, int> cp;
//function
static int main(){
REP(i, 8){
clear[i] = i;
}
move[0].PB(1);
move[0].PB(4);
move[1].PB(0);
move[1].PB(2);
move[1].PB(5);
move[2].PB(1);
move[2].PB(3);
move[2].PB(6);
move[3].PB(2);
move[3].PB(7);
move[4].PB(0);
move[4].PB(5);
move[5].PB(1);
move[5].PB(4);
move[5].PB(6);
move[6].PB(2);
move[6].PB(5);
move[6].PB(7);
move[7].PB(3);
move[7].PB(6);
while(scanf("%d %d %d %d %d %d %d %d", &now[0], &now[1], &now[2], & now[3], &now[4], &now[5], &now[6], &now[7]) != EOF){
REP(i, 8){
if(!now[i]){
b = i;
break;
}
}
if(now == clear){
printf("0\n");
continue;
}
static int d;
ans = cp;
ans[clear] = INF;
q.push(pair<pair<vector<short>, int>, int>(pair<vector<short>, int>(now, 0),b));
while(!q.empty()){
now = q.front().F.F;
int a = q.front().F.S;
b = q.front().S;
q.pop();
if(!ans[now] || (ans[now] > a && ans[clear] > a)){
ans[now] = a;
}
else if(ans[clear] == a){
break;
}
else{
continue;
}
//cout << "a = " << a << " b = " << b << "\n";
REP(i, move[b].size()){
int tmp;
tmp = move[b][i];
swap(now[tmp], now[b]);
q.push(pair<pair<vector<short>, int>, int>(pair<vector<short>, int>(now, a + 1), tmp));
swap(now[tmp], now[b]);
}
}
d = ans[clear];
printf("%d\n", d);
}
return 0;
} | a.cc:45:12: error: cannot declare '::main' to be static
45 | static int main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:49:3: error: reference to 'move' is ambiguous
49 | move[0].PB(1);
| ^~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
In file included from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:50:3: error: reference to 'move' is ambiguous
50 | move[0].PB(4);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:51:3: error: reference to 'move' is ambiguous
51 | move[1].PB(0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:52:3: error: reference to 'move' is ambiguous
52 | move[1].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:53:3: error: reference to 'move' is ambiguous
53 | move[1].PB(5);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:54:3: error: reference to 'move' is ambiguous
54 | move[2].PB(1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:55:3: error: reference to 'move' is ambiguous
55 | move[2].PB(3);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:56:3: error: reference to 'move' is ambiguous
56 | move[2].PB(6);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:57:3: error: reference to 'move' is ambiguous
57 | move[3].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: |
s018589603 | p00121 | C++ | //AOJ 0121
//include
#include<bits/stdc++.h>
//using
using namespace std;
//define static const typedef
#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define DUMP(x) cerr << #x << " = " << x << "\n";
#define DEBUG(x) cerr << #x << " = " << x << " (L:" << __LINE__ << ") " << __FILE__ << "\n";
#define F first
#define S second
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
static const int INF = 1 << 25;
//global
static vector<short> clear(8);
static vector<vector<short> > move(8);
static vector<short> now(8);
static int b;
static queue<pair<pair<vector<short>, int>, int> > q;
static map<vector<short>, int> ans;
static map<vector<short>, int> cp;
//function
static int main(){
REP(i, 8){
clear[i] = i;
}
move[0].PB(1);
move[0].PB(4);
move[1].PB(0);
move[1].PB(2);
move[1].PB(5);
move[2].PB(1);
move[2].PB(3);
move[2].PB(6);
move[3].PB(2);
move[3].PB(7);
move[4].PB(0);
move[4].PB(5);
move[5].PB(1);
move[5].PB(4);
move[5].PB(6);
move[6].PB(2);
move[6].PB(5);
move[6].PB(7);
move[7].PB(3);
move[7].PB(6);
while(scanf("%d %d %d %d %d %d %d %d", &now[0], &now[1], &now[2], & now[3], &now[4], &now[5], &now[6], &now[7]) != EOF){
REP(i, 8){
if(!now[i]){
b = i;
break;
}
}
if(now == clear){
printf("0\n");
continue;
}
static int d;
ans = cp;
ans[clear] = INF;
q.push(pair<pair<vector<short>, int>, int>(pair<vector<short>, int>(now, 0),b));
while(!q.empty()){
now = q.front().F.F;
int a = q.front().F.S;
b = q.front().S;
q.pop();
if(!ans[now] || (ans[now] > a && ans[clear] > a)){
ans[now] = a;
}
else if(ans[clear] == a){
break;
}
else{
continue;
}
//cout << "a = " << a << " b = " << b << "\n";
REP(i, move[b].size()){
int tmp;
tmp = move[b][i];
swap(now[tmp], now[b]);
q.push(pair<pair<vector<short>, int>, int>(pair<vector<short>, int>(now, a + 1), tmp));
swap(now[tmp], now[b]);
}
}
d = ans[clear];
printf("%d\n", d);
}
return 0;
} | a.cc:45:12: error: cannot declare '::main' to be static
45 | static int main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:49:3: error: reference to 'move' is ambiguous
49 | move[0].PB(1);
| ^~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
In file included from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:50:3: error: reference to 'move' is ambiguous
50 | move[0].PB(4);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:51:3: error: reference to 'move' is ambiguous
51 | move[1].PB(0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:52:3: error: reference to 'move' is ambiguous
52 | move[1].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:53:3: error: reference to 'move' is ambiguous
53 | move[1].PB(5);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:54:3: error: reference to 'move' is ambiguous
54 | move[2].PB(1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:55:3: error: reference to 'move' is ambiguous
55 | move[2].PB(3);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:56:3: error: reference to 'move' is ambiguous
56 | move[2].PB(6);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:31: note: 'std::vector<std::vector<short int> > move'
38 | static vector<vector<short> > move(8);
| ^~~~
a.cc:57:3: error: reference to 'move' is ambiguous
57 | move[3].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: |
s699469002 | p00121 | C++ | //AOJ 0121
//include
#include<bits/stdc++.h>
//using
using namespace std;
//define static const typedef
#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define DUMP(x) cerr << #x << " = " << x << "\n";
#define DEBUG(x) cerr << #x << " = " << x << " (L:" << __LINE__ << ") " << __FILE__ << "\n";
#define F first
#define S second
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
static const int INF = 1 << 25;
//global
static vector<char> clear(8);
static vector<vector<char> > move(8);
static vector<char> now(8);
static char b;
static queue<pair<pair<vector<char>, char>, char> > q;
static map<vector<char>, char> ans;
static map<vector<char>, char> cp;
//function
int main(){
REP(i, 8){
clear[i] = i;
}
move[0].PB(1);
move[0].PB(4);
move[1].PB(0);
move[1].PB(2);
move[1].PB(5);
move[2].PB(1);
move[2].PB(3);
move[2].PB(6);
move[3].PB(2);
move[3].PB(7);
move[4].PB(0);
move[4].PB(5);
move[5].PB(1);
move[5].PB(4);
move[5].PB(6);
move[6].PB(2);
move[6].PB(5);
move[6].PB(7);
move[7].PB(3);
move[7].PB(6);
while(scanf("%d %d %d %d %d %d %d %d", &now[0], &now[1], &now[2], & now[3], &now[4], &now[5], &now[6], &now[7]) != EOF){
REP(i, 8){
if(!now[i]){
b = i;
break;
}
}
if(now == clear){
printf("0\n");
continue;
}
ans = cp;
ans[clear] = 127;
q.push(pair<pair<vector<char>, int>, int>(pair<vector<char>, char>(now, 0),b));
while(!q.empty()){
now = q.front().F.F;
char a = q.front().F.S;
b = q.front().S;
q.pop();
if(!ans[now] || (ans[now] > a && ans[clear] > a)){
ans[now] = a;
}
else if(ans[clear] == a){
break;
}
else{
continue;
}
//cout << "a = " << a << " b = " << b << "\n";
REP(i, move[b].size()){
char tmp;
tmp = move[b][i];
swap(now[tmp], now[b]);
q.push(pair<pair<vector<char>, char>, char>(pair<vector<char>, char>(now, a + 1), tmp));
swap(now[tmp], now[b]);
}
}
d = ans[clear];
printf("%d\n", d);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:49:3: error: reference to 'move' is ambiguous
49 | move[0].PB(1);
| ^~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
In file included from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:50:3: error: reference to 'move' is ambiguous
50 | move[0].PB(4);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:51:3: error: reference to 'move' is ambiguous
51 | move[1].PB(0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:52:3: error: reference to 'move' is ambiguous
52 | move[1].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:53:3: error: reference to 'move' is ambiguous
53 | move[1].PB(5);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:54:3: error: reference to 'move' is ambiguous
54 | move[2].PB(1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:55:3: error: reference to 'move' is ambiguous
55 | move[2].PB(3);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:56:3: error: reference to 'move' is ambiguous
56 | move[2].PB(6);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:57:3: error: reference to 'move' is ambiguous
57 | move[3].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/ |
s206947601 | p00121 | C++ | //AOJ 0121
//include
#include<bits/stdc++.h>
//using
using namespace std;
//define static const typedef
#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define DUMP(x) cerr << #x << " = " << x << "\n";
#define DEBUG(x) cerr << #x << " = " << x << " (L:" << __LINE__ << ") " << __FILE__ << "\n";
#define F first
#define S second
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
static const int INF = 1 << 25;
//global
static vector<char> clear(8);
static vector<vector<char> > move(8);
static vector<char> now(8);
static char b;
static queue<pair<pair<vector<char>, char>, char> > q;
static VVII c;
//function
int main(){
REP(i, 8){
clear[i] = i;
}
move[0].PB(1);
move[0].PB(4);
move[1].PB(0);
move[1].PB(2);
move[1].PB(5);
move[2].PB(1);
move[2].PB(3);
move[2].PB(6);
move[3].PB(2);
move[3].PB(7);
move[4].PB(0);
move[4].PB(5);
move[5].PB(1);
move[5].PB(4);
move[5].PB(6);
move[6].PB(2);
move[6].PB(5);
move[6].PB(7);
move[7].PB(3);
move[7].PB(6);
while(scanf("%d %d %d %d %d %d %d %d", &now[0], &now[1], &now[2], & now[3], &now[4], &now[5], &now[6], &now[7]) != EOF){
REP(i, 8){
if(!now[i]){
b = i;
break;
}
}
if(now == clear){
printf("0\n");
continue;
}
ans = cp;
ans[clear] = 127;
q.push(pair<pair<vector<char>, char>, char>(pair<vector<char>, char>(now, 0),b));
c.PB(now);
while(!q.empty()){
now = q.front().F.F;
char a = q.front().F.S;
b = q.front().S;
q.pop();
if(!ans[now] || (ans[now] > a && ans[clear] > a)){
ans[now] = a;
if(clear == now){
d = ans[now];
}
}
else if(ans[clear] == a){
break;
}
else{
continue;
}
//cout << "a = " << a << " b = " << b << "\n";
REP(i, move[b].size()){
char tmp;
tmp = move[b][i];
swap(now[tmp], now[b]);
if(!binary_search(c.begin(), c.end(), now)){
c.PB(now);
q.push(pair<pair<vector<char>, char>, char>(pair<vector<char>, char>(now, a + 1), tmp));
}
swap(now[tmp], now[b]);
}
}
printf("%d\n", d);
}
return 0;
} | a.cc:42:8: error: 'VVII' does not name a type; did you mean 'VVI'?
42 | static VVII c;
| ^~~~
| VVI
a.cc: In function 'int main()':
a.cc:48:3: error: reference to 'move' is ambiguous
48 | move[0].PB(1);
| ^~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
In file included from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:49:3: error: reference to 'move' is ambiguous
49 | move[0].PB(4);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:50:3: error: reference to 'move' is ambiguous
50 | move[1].PB(0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:51:3: error: reference to 'move' is ambiguous
51 | move[1].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:52:3: error: reference to 'move' is ambiguous
52 | move[1].PB(5);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:53:3: error: reference to 'move' is ambiguous
53 | move[2].PB(1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:54:3: error: reference to 'move' is ambiguous
54 | move[2].PB(3);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:55:3: error: reference to 'move' is ambiguous
55 | move[2].PB(6);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:56:3: error: reference to 'move' is ambiguous
56 | move[3].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> |
s683392596 | p00121 | C++ | //AOJ 0121
//include
#include<bits/stdc++.h>
//using
using namespace std;
//define static const typedef
#define FOR(i, s, n) for(int (i) = (s); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define DUMP(x) cerr << #x << " = " << x << "\n";
#define DEBUG(x) cerr << #x << " = " << x << " (L:" << __LINE__ << ") " << __FILE__ << "\n";
#define F first
#define S second
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
static const int INF = 1 << 25;
//global
static vector<char> clear(8);
static vector<vector<char> > move(8);
static vector<char> now(8);
static char b;
static queue<pair<pair<vector<char>, char>, char> > q;
static map<vector<char>, char> ans;
//function
int main(){
REP(i, 8){
clear[i] = i;
}
move[0].PB(1);
move[0].PB(4);
move[1].PB(0);
move[1].PB(2);
move[1].PB(5);
move[2].PB(1);
move[2].PB(3);
move[2].PB(6);
move[3].PB(2);
move[3].PB(7);
move[4].PB(0);
move[4].PB(5);
move[5].PB(1);
move[5].PB(4);
move[5].PB(6);
move[6].PB(2);
move[6].PB(5);
move[6].PB(7);
move[7].PB(3);
move[7].PB(6);
while(scanf("%d %d %d %d %d %d %d %d", &now[0], &now[1], &now[2], & now[3], &now[4], &now[5], &now[6], &now[7]) != EOF){
REP(i, 8){
if(!now[i]){
b = i;
break;
}
}
if(now == clear){
printf("0\n");
continue;
}
ans = map();
ans[clear] = 127;
q.push(pair<pair<vector<char>, char>, char>(pair<vector<char>, char>(now, 0),b));
while(!q.empty()){
now = q.front().F.F;
char a = q.front().F.S;
b = q.front().S;
q.pop();
if(!ans[now] || (ans[now] > a && ans[clear] > a)){
ans[now] = a;
}
else if(ans[clear] == a){
break;
}
else{
continue;
}
//cout << "a = " << a << " b = " << b << "\n";
REP(i, move[b].size()){
char tmp;
tmp = move[b][i];
swap(now[tmp], now[b]);
q.push(pair<pair<vector<char>, char>, char>(pair<vector<char>, char>(now, a + 1), tmp));
swap(now[tmp], now[b]);
}
}
printf("%d\n", ans[clear]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:48:3: error: reference to 'move' is ambiguous
48 | move[0].PB(1);
| ^~~~
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
In file included from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:49:3: error: reference to 'move' is ambiguous
49 | move[0].PB(4);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:50:3: error: reference to 'move' is ambiguous
50 | move[1].PB(0);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:51:3: error: reference to 'move' is ambiguous
51 | move[1].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:52:3: error: reference to 'move' is ambiguous
52 | move[1].PB(5);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:53:3: error: reference to 'move' is ambiguous
53 | move[2].PB(1);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:54:3: error: reference to 'move' is ambiguous
54 | move[2].PB(3);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:55:3: error: reference to 'move' is ambiguous
55 | move[2].PB(6);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/move.h:137:5: note: 'template<class _Tp> constexpr typename std::remove_reference<_Tp>::type&& std::move(_Tp&&)'
137 | move(_Tp&& __t) noexcept
| ^~~~
a.cc:38:30: note: 'std::vector<std::vector<char> > move'
38 | static vector<vector<char> > move(8);
| ^~~~
a.cc:56:3: error: reference to 'move' is ambiguous
56 | move[3].PB(2);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:353:1: note: candidates are: 'template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator2> std::move(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)'
353 | move(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 __d_first);
| ^~~~
/usr/include/c++/14/bits/stl_algobase.h:675:5: note: 'template<class _II, class _OI> _OI std::move(_II, _II, _OI)'
675 | move(_II __first, _II __last, _OI __result)
| ^~~~
/usr/include/c++/14/bits/ |
s917185027 | p00121 | C++ | #include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
static const int INF=1<<24;
map<vector<vector<int> >,int> ma;
vector<vector<int> > puz;
vector<vectr<int> > v;
template<class T>
void initvv(vector<vector<T> > &v,int a,int b,const T &t=T()){
v.assign(a,vector<T>(b,t));
}
int solve(int c){
if(v==puz) return c;
if(ma[v]) return ma[v];
int t=INF;
rep(i,4){
if(v[0][i]==0){
if(i>=1){
swap(v[0][i-1],v[0][i]);
t=min(t,solve()
}
}
}
}
int main(){
initvv(puz,2,4);
rep(i,4){
// cout<<i<<endl;
puz[0][i]=i;
puz[1][i]=i+4;
}
// rep(i,2){
// rep(j,4){
// cout<<puz[i][j]<<endl;
// }
// }
// vector<vector<int> > v;
initvv(v,2,4);
while(cin>>v[0][0]){
rep(i,3){
cin>>v[0][i+1];
}
rep(i,4) cin>>v[1][i];
cout<<solve(0)<<endl;
}
} | a.cc:11:8: error: 'vectr' was not declared in this scope; did you mean 'qecvt_r'?
11 | vector<vectr<int> > v;
| ^~~~~
| qecvt_r
a.cc:11:17: error: template argument 1 is invalid
11 | vector<vectr<int> > v;
| ^
a.cc:11:17: error: template argument 2 is invalid
a.cc:11:19: error: expected unqualified-id before '>' token
11 | vector<vectr<int> > v;
| ^
a.cc: In function 'int solve(int)':
a.cc:19:12: error: 'v' was not declared in this scope
19 | if(v==puz) return c;
| ^
a.cc:20:15: error: 'v' was not declared in this scope
20 | if(ma[v]) return ma[v];
| ^
a.cc:23:20: error: 'v' was not declared in this scope
23 | if(v[0][i]==0){
| ^
a.cc:26:46: error: too few arguments to function 'int solve(int)'
26 | t=min(t,solve()
| ~~~~~^~
a.cc:18:5: note: declared here
18 | int solve(int c){
| ^~~~~
a.cc: In function 'int main()':
a.cc:46:16: error: 'v' was not declared in this scope
46 | initvv(v,2,4);
| ^
|
s349681072 | p00121 | C++ | #include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int vis[17000000];
int temp[10];
int s;
int dir[4]={-1,1,4,-4};
struct Node
{
int x;
int line;
int step;
friend bool operator <(Node a, Node b)
{
return a.step>b.step;
}
};
void BFS(int x,int s)
{
priority_queue<Node> Q;
Node p,q;
int k,t,i;
p.x=x;
p.step=0;
p.line=s;
Q.push(p);
while(!Q.empty())
{
q=Q.top();
Q.pop();
if(q.line==342391)
{
printf("%d\n",q.step);
return ;
}
for(k=0;k<4;k++)
{
p.x=q.x+dir[k];
if(p.x>8||p.x<=0||(p.x==5&&(q.x==4||q.x==6)))
continue;
t=q.line;
for(i=8;i>=1;i--)
{
temp[i]=t%8;
t=t>>3;
}
p.line=0;
for(i=1;i<=8;i++)
{
if(i==p.x)
{
p.line=(p.line<<3)+temp[q.x];
}
else if(i==q.x)
{
p.line=(p.line<<3)+temp[p.x];
}
else
{
p.line=(p.line<<3)+temp[i];
}
}
if(vis[p.line])
continue;
vis[p.line]=1;
p.step=q.step+1;
Q.push(p);
}
}
printf("-1\n");
}
int main()
{
int k=0;
int t;
while(scanf("%d",&t)!=EOF)
{
k=(k<<3)+t;
memset(vis,0,sizeof(vis));
if(t==0)
s=1;
for(int i=2;i<=8;i++)
{
scanf("%d",&t);
if(t==0)
s=i;
k=(k<<3)+t;
}
vis[k]=1;
BFS(s,k);
k=0;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:81:17: error: 'memset' was not declared in this scope
81 | memset(vis,0,sizeof(vis));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<algorithm>
+++ |+#include <cstring>
4 | using namespace std;
|
s461979430 | p00121 | C++ | import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;
public class Main {
Scanner sc = new Scanner(System.in);
HashMap<String, Integer> map;
LinkedList<String> que;
void run() {
map = new HashMap<String, Integer>();
que = new LinkedList<String>();
int cnt = 0;
que.add("01234567");
map.put("01234567", cnt);
while (!que.isEmpty()) {
cnt++;
int size = que.size();
for (int i = 0; i < size; i++) {
String now = que.poll();
int zero = now.indexOf('0');
if (zero != 0 && zero != 4) {
char[] next = now.toCharArray();
char t = next[zero - 1];
next[zero] = t;
next[zero - 1] = '0';
setParam(next, cnt);
}
if (zero != 3 && zero != 7) {
char[] next = now.toCharArray();
char t = next[zero + 1];
next[zero] = t;
next[zero + 1] = '0';
setParam(next, cnt);
}
char[] next = now.toCharArray();
char t = next[(zero + 4) % 8];
next[zero] = t;
next[(zero + 4) % 8] = '0';
setParam(next, cnt);
}
}
while (sc.hasNext()) {
String key = "";
for (int i = 0; i < 8; i++) {
key += sc.nextInt();
}
System.out.println(map.get(key));
}
}
void setParam(char[] next, int cnt) {
String nextS = String.valueOf(next);
if (!map.containsKey(nextS)) {
map.put(nextS, cnt);
que.add(nextS);
}
}
public static void main(String[] args) {
new Main().run();
}
void debug(Object... o) {
System.out.println(Arrays.deepToString(o));
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.Arrays;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.util.HashMap;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.LinkedList;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.Scanner;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
6 | public class Main {
| ^~~~~~
|
s527370892 | p00121 | C++ | #include<iostream>
#include<set>
#include<deque>
#include<utility>
#include<algorithm>
#include<stack>
#include<vector>
#include<string>
using namespace std;
bool used[8][8][8][8][8][8][8][8];
inline bool judge(vector<int> ar){
for(int i=0;i<ar.size();i++){
if (ar[i] != i) return false;
}
return true;
}
inline int findzero(vector<int> ar){
for(int i=0;i<8;i++){
if(ar[i] == 0) return i;
}
return 0;
}
int main(){
vector<int> ar(8);
// set< vector<int> > memo1;
// set< vector<int> > memo2;
deque< vector<int> > next;
deque< vector<int> > rec;
int d[] = {-4,-1,1,4};
int zero,nextzero;
bool endflag=false,flag;
int res;
while(true){
memset(used,0,sizeof(used));
res = 0;
flag = false;
for(int i=0;i<8;i++){
if((cin >> ar[i])==0){
endflag = true;
break;
}
if(ar[i] == 0) zero = i;
}
if(endflag) break;
next.push_back(ar);
if(judge(ar)){
flag = true;
cout << res << endl;
}
while(!flag){
res++;
while(!next.empty()){
ar = next.front();
used[ar[0]][ar[1]][ar[2]][ar[3]][ar[4]][ar[5]][ar[6]][ar[7]] = true;
zero = findzero(ar);
next.pop_front();
for(int i=0;i<4;i++){
nextzero = zero + d[i];
if(nextzero>-1&&nextzero<8){
if(zero == 3 && i==2) continue;
else if(zero == 4 && i == 1) continue;
swap(ar[nextzero],ar[zero]);
if(judge(ar)){
flag = true;
cout << res << endl;
break;
}
if(!used[ar[0]][ar[1]][ar[2]][ar[3]][ar[4]][ar[5]][ar[6]][ar[7]]){
rec.push_back(ar);
}
swap(ar[nextzero],ar[zero]);
}
}
if(flag) break;
}
swap(next,rec);
}
if(flag){
next.clear();
rec.clear();
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:41:9: error: 'memset' was not declared in this scope
41 | memset(used,0,sizeof(used));
| ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
7 | #include<vector>
+++ |+#include <cstring>
8 | #include<string>
a.cc:45:30: error: no match for 'operator==' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'int')
45 | if((cin >> ar[i])==0){
| ~~~~~~~~~~~~~~^~~
| | |
| | int
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
a.cc:45:30: note: candidate: 'operator==(int, int)' (built-in)
45 | if((cin >> ar[i])==0){
| ~~~~~~~~~~~~~~^~~
a.cc:45:30: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>'
45 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>'
45 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
45 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
45 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
45 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
45 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>'
45 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
45 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
45 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
45 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
45 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
45 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:45:32: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>'
45 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:25 |
s312856292 | p00121 | C++ | #include<iostream>
#include<set>
#include<deque>
#include<utility>
#include<algorithm>
#include<stack>
#include<vector>
#include<string.h>
using namespace std;
bool used[8][8][8][8][8][8][8][8];
inline bool judge(vector<int> ar){
for(int i=0;i<ar.size();i++){
if (ar[i] != i) return false;
}
return true;
}
inline int findzero(vector<int> ar){
for(int i=0;i<8;i++){
if(ar[i] == 0) return i;
}
return 0;
}
int main(){
int d[] = {-4,-1,1,4};
vector< vector<int> > d1;
for(int i=0;i<8;i++){
d1.push_back(vector<int>());
for(int j=0;j<4;j++){
if(i+d[j]>-1&&i+d[j]<8){
if(i == 3 && j==2) continue;
else if(i == 4 && j == 1) continue;
d1[i].push_back(i+d[j]);
}
}
}
vector<int> ar(8);
deque< vector<int> > next;
deque< vector<int> > rec;
int zero,nextzero;
bool endflag=false,flag;
int res;
while(true){
memset(used,0,sizeof(used));
res = 0;
flag = false;
for(int i=0;i<8;i++){
if((cin >> ar[i])==0){
endflag = true;
break;
}
if(ar[i] == 0) zero = i;
}
if(endflag) break;
next.push_back(ar);
if(judge(ar)){
flag = true;
cout << res << endl;
}
while(!flag){
res++;
while(!next.empty()){
ar = next.front();
used[ar[0]][ar[1]][ar[2]][ar[3]][ar[4]][ar[5]][ar[6]][ar[7]] = true;
zero = findzero(ar);
next.pop_front();
for(int i=0;i<d1[zero].size();i++){
nextzero = d1[zero][i];
swap(ar[nextzero],ar[zero]);
if(judge(ar)){
flag = true;
cout << res << endl;
break;
}
if(!used[ar[0]][ar[1]][ar[2]][ar[3]][ar[4]][ar[5]][ar[6]][ar[7]]){
rec.push_back(ar);
}
swap(ar[nextzero],ar[zero]);
}
if(flag) break;
}
swap(ne | a.cc: In function 'int main()':
a.cc:55:30: error: no match for 'operator==' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'int')
55 | if((cin >> ar[i])==0){
| ~~~~~~~~~~~~~~^~~
| | |
| | int
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
a.cc:55:30: note: candidate: 'operator==(int, int)' (built-in)
55 | if((cin >> ar[i])==0){
| ~~~~~~~~~~~~~~^~~
a.cc:55:30: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>'
55 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>'
55 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
55 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
55 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
55 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
55 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>'
55 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
55 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
55 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
55 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
55 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
55 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>'
55 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed:
a.cc:55:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
55 | if((cin >> ar[i])==0){
| ^
In file included from / |
s095222293 | p00121 | C++ | #include<iostream>
#include<set>
#include<deque>
#include<utility>
#include<algorithm>
#include<stack>
#include<vector>
#include<string.h>
using namespace std;
bool used[8][8][8][8][8][8][8][8];
short dp[8][8][8][8][8][8][8][8];
inline bool judge(vector<int> ar){
for(int i=0;i<ar.size();i++){
if (ar[i] != i) return false;
}
return true;
}
inline int findzero(vector<int> ar){
for(int i=0;i<8;i++){
if(ar[i] == 0) return i;
}
return 0;
}
int main(){
int d[] = {-4,-1,1,4};
vector< vector<int> > d1;
for(int i=0;i<8;i++){
d1.push_back(vector<int>());
for(int j=0;j<4;j++){
if(i+d[j]>-1&&i+d[j]<8){
if(i == 3 && j==2) continue;
else if(i == 4 && j == 1) continue;
d1[i].push_back(i+d[j]);
}
}
}
vector<int> ar(8);
deque< vector<int> > next;
deque< vector<int> > rec;
int zero,nextzero;
bool endflag=false,flag;
int res;
while(true){
memset(used,0,sizeof(used));
res = 0;
flag = false;
for(int i=0;i<8;i++){
if((cin >> ar[i])==0){
endflag = true;
break;
}
if(ar[i] == 0) zero = i;
}
if(endflag) break;
next.push_back(ar);
if(judge(ar)){
flag = true;
cout << res << endl;
}
while(!flag){
res++;
while(!next.empty()){
ar = next.front();
used[ar[0]][ar[1]][ar[2]][ar[3]][ar[4]][ar[5]][ar[6]][ar[7]] = true;
if( dp[ar[0]][ar[1]][ar[2]][ar[3]][ar[4]][ar[5]][ar[6]][ar[7]] != 0) res += dp[ar[0]][ar[1]][ar[2]][ar[3]][ar[4]][ar[5]][ar[6]][ar[7]] - 1 ;
zero = findzero(ar);
next.pop_front();
for(int i=0;i<d1[zero].size();i++){
nextzero = d1[zero][i];
swap(ar[nextzero],ar[zero]);
if(judge(ar)){
flag = true;
dp[ar[0]][ar[1]][ar[2]][ar[3]][ar[4]][ar[5]][ar[6]][ar[7]] = res;
cout << res << endl;
break;
}else{
}
if(!used[ar[0]][ar[1]][ar[2]][ar[3]][ar[4]][ar[5]][ar[6]][ar[7]]){
rec.push_back(ar);
}
swap(ar[nextzero],ar[zero]);
}
if(flag) break;
}
swap(next,rec);
}
if(flag){
next.clear();
rec.clear();
}
}
return 0; | a.cc: In function 'int main()':
a.cc:56:30: error: no match for 'operator==' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'int')
56 | if((cin >> ar[i])==0){
| ~~~~~~~~~~~~~~^~~
| | |
| | int
| std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
a.cc:56:30: note: candidate: 'operator==(int, int)' (built-in)
56 | if((cin >> ar[i])==0){
| ~~~~~~~~~~~~~~^~~
a.cc:56:30: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>'
56 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>'
56 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
56 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
56 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
56 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
56 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>'
56 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
56 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
56 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
56 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
56 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
56 | if((cin >> ar[i])==0){
| ^
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>'
56 | if((cin >> ar[i])==0){
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed:
a.cc:56:32: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
56 | if((cin >> ar[i])==0){
| ^
In file included from / |
s025360779 | p00121 | C++ | #include <iostream>
#include <queue>
#define INF 9999999
using namespace std;
typedef struct {
int d[9];
}data;
int main() {
while(true) {
queue<data> bfs;
data first;
bool checked[8][8][8][8][8][8][8];
int min = INF;
for (int i = 0;i < 8;i++) {
cin >> first.d[i];
}
first.d[8] = 0;
bfs.push(first);
for (;;) {
if (bfs.empty()) break;
data front;
front = bfs.front();
bfs.pop();
for (int k = 0;k < 4;k++) {
cout << front.d[k] << " ";
}
cout << endl;
for (int k = 4;k < 8;k++) {
cout << front.d[k] << " ";
}
cout << endl;
//Is it already covered?
if(checked[front.d[0]][front.d[1]][front.d[2]][front.d[3]][front.d[4]][front.d[5]][front.d[6]][front.d[7]] == true) {
cout << "skipped" << endl;
continue;
}
else {
cout << "NOT" << endl;
}
//Check
if (front.d[8] < min) {
for (int i = 0;i < 8;i++) {
if(front.d[i] != i) goto outofcheck;
}
min = front.d[8];
}
outofcheck:
//Find Zero
int zero;
for (int i = 0;i < 8;i++) {
if (front.d[i] == 0) {
zero = i;
break;
}
}
//Move
if (zero < 4) {
//???????????\?????????
int x;
data array = front;
array.d[8] = front.d[8] + 1;
x = array.d[zero];
array.d[zero] = array.d[zero+4];
array.d[zero+4] = x;
bfs.push(array);
if (zero>0) {
int y;
data array2 = front;
array2.d[8] = front.d[8] + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<3) {
int z;
data array3 = front;
array3.d[8] = front.d[8] + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
else {
//???????????\?????????
int x;
data array = front;
array.d[8] = front.d[8] + 1;
x = array.d[zero];
array.d[zero] = array.d[zero-4];
array.d[zero-4] = x;
bfs.push(array);
if (zero>4) {
int y;
data array2= front;
array2.d[8] = front.d[8] + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<7) {
int z;
data array3 = front;
array3.d[8] = front.d[8] + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
checked[front.d[0]][front.d[1]][front.d[2]][front.d[3]][front.d[4]][front.d[5]][front.d[6]][front.d[7]] = true;
}
cout << min << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:27: error: template argument 1 is invalid
10 | queue<data> bfs;
| ^
a.cc:10:27: error: template argument 2 is invalid
a.cc:11:17: error: reference to 'data' is ambiguous
11 | data first;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:7:2: note: 'typedef struct data data'
7 | }data;
| ^~~~
a.cc:16:32: error: 'first' was not declared in this scope
16 | cin >> first.d[i];
| ^~~~~
a.cc:18:17: error: 'first' was not declared in this scope
18 | first.d[8] = 0;
| ^~~~~
a.cc:19:21: error: request for member 'push' in 'bfs', which is of non-class type 'int'
19 | bfs.push(first);
| ^~~~
a.cc:21:33: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
21 | if (bfs.empty()) break;
| ^~~~~
a.cc:22:25: error: reference to 'data' is ambiguous
22 | data front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:7:2: note: 'typedef struct data data'
7 | }data;
| ^~~~
a.cc:23:25: error: 'front' was not declared in this scope
23 | front = bfs.front();
| ^~~~~
a.cc:23:37: error: request for member 'front' in 'bfs', which is of non-class type 'int'
23 | front = bfs.front();
| ^~~~~
a.cc:24:29: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
24 | bfs.pop();
| ^~~
a.cc:61:33: error: reference to 'data' is ambiguous
61 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:7:2: note: 'typedef struct data data'
7 | }data;
| ^~~~
a.cc:62:38: error: expected unqualified-id before '.' token
62 | array.d[8] = front.d[8] + 1;
| ^
a.cc:63:42: error: missing template arguments before '.' token
63 | x = array.d[zero];
| ^
a.cc:64:38: error: expected unqualified-id before '.' token
64 | array.d[zero] = array.d[zero+4];
| ^
a.cc:65:38: error: expected unqualified-id before '.' token
65 | array.d[zero+4] = x;
| ^
a.cc:66:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
66 | bfs.push(array);
| ^~~~
a.cc:66:47: error: missing template arguments before ')' token
66 | bfs.push(array);
| ^
a.cc:69:41: error: reference to 'data' is ambiguous
69 | data array2 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:7:2: note: 'typedef struct data data'
7 | }data;
| ^~~~
a.cc:70:41: error: 'array2' was not declared in this scope
70 | array2.d[8] = front.d[8] + 1;
| ^~~~~~
a.cc:74:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
74 | bfs.push(array2);
| ^~~~
a.cc:78:41: error: reference to 'data' is ambiguous
78 | data array3 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:7:2: note: 'typedef struct data data'
7 | }data;
| ^~~~
a.cc:79:41: error: 'array3' was not declared in this scope
79 | array3.d[8] = front.d[8] + 1;
| ^~~~~~
a.cc:83:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
83 | bfs.push(array3);
| ^~~~
a.cc:89:33: error: reference to 'data' is ambiguous
89 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Conta |
s902560072 | p00121 | C++ | #include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef struct {
int d[8];
int count;
} data;
map <string,int> memo;
queue <data> bfs;
int main() {
data first;
for (int i = 0;i < 8;i++) {
first.d[i] = i;
}
first.count = 0;
bfs.push(first);
for (;;) {
if (bfs.empty()) break;
data front = bfs.front();
bfs.pop();
string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
if(memo.find(str) !=memo.end()){
continue;
}
memo[str] = front.count;
//Find Zero
int zero;
for (int i = 0;i < 8;i++) {
if (front.d[i] == 0) {
zero = i;
break;
}
}
//Move
if (zero < 4) {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero+4];
array.d[zero+4] = x;
bfs.push(array);
if (zero>0) {
int y;
data array2 = front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<3) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
else {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero-4];
array.d[zero-4] = x;
bfs.push(array);
if (zero>4) {
int y;
data array2= front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<7) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
}
while(true) {
int puz[8];
if (cin >> puz[0]) {
for (int i = 1;i < 8;i++) {
cin >> puz[i];
}
string str = to_string(puz[0])+to_string(puz[1])+to_string(puz[2])+to_string(puz[3])+to_string(puz[4])+to_string(puz[5])+to_string(puz[6])+to_string(puz[7]);
cout << memo[str] << endl;
}
else break;
}
return 0;
} | a.cc:11:12: error: template argument 1 is invalid
11 | queue <data> bfs;
| ^
a.cc:11:12: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:14:9: error: reference to 'data' is ambiguous
14 | data first;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:16:17: error: 'first' was not declared in this scope
16 | first.d[i] = i;
| ^~~~~
a.cc:18:9: error: 'first' was not declared in this scope
18 | first.count = 0;
| ^~~~~
a.cc:19:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
19 | bfs.push(first);
| ^~~~
a.cc:21:25: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
21 | if (bfs.empty()) break;
| ^~~~~
a.cc:22:17: error: reference to 'data' is ambiguous
22 | data front = bfs.front();
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:23:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
23 | bfs.pop();
| ^~~
a.cc:24:40: error: 'front' was not declared in this scope
24 | string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
| ^~~~~
a.cc:42:33: error: reference to 'data' is ambiguous
42 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:43:38: error: expected unqualified-id before '.' token
43 | array.count = front.count + 1;
| ^
a.cc:44:42: error: missing template arguments before '.' token
44 | x = array.d[zero];
| ^
a.cc:45:38: error: expected unqualified-id before '.' token
45 | array.d[zero] = array.d[zero+4];
| ^
a.cc:46:38: error: expected unqualified-id before '.' token
46 | array.d[zero+4] = x;
| ^
a.cc:47:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
47 | bfs.push(array);
| ^~~~
a.cc:47:47: error: missing template arguments before ')' token
47 | bfs.push(array);
| ^
a.cc:50:41: error: reference to 'data' is ambiguous
50 | data array2 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:51:41: error: 'array2' was not declared in this scope
51 | array2.count = front.count + 1;
| ^~~~~~
a.cc:55:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
55 | bfs.push(array2);
| ^~~~
a.cc:59:41: error: reference to 'data' is ambiguous
59 | data array3 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:60:41: error: 'array3' was not declared in this scope
60 | array3.count = front.count + 1;
| ^~~~~~
a.cc:64:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
64 | bfs.push(array3);
| ^~~~
a.cc:70:33: error: reference to 'data' is ambiguous
70 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'temp |
s449822696 | p00121 | C++ | #include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef struct {
int d[8];
int count;
} data;
map <string,int> memo;
queue <data> bfs;
string to_string(int n) {
string x = n;
return x;
}
int main() {
data first;
for (int i = 0;i < 8;i++) {
first.d[i] = i;
}
first.count = 0;
bfs.push(first);
for (;;) {
if (bfs.empty()) break;
data front = bfs.front();
bfs.pop();
string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
if(memo.find(str) !=memo.end()){
continue;
}
memo[str] = front.count;
//Find Zero
int zero;
for (int i = 0;i < 8;i++) {
if (front.d[i] == 0) {
zero = i;
break;
}
}
//Move
if (zero < 4) {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero+4];
array.d[zero+4] = x;
bfs.push(array);
if (zero>0) {
int y;
data array2 = front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<3) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
else {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero-4];
array.d[zero-4] = x;
bfs.push(array);
if (zero>4) {
int y;
data array2= front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<7) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
}
while(true) {
int puz[8];
if (cin >> puz[0]) {
for (int i = 1;i < 8;i++) {
cin >> puz[i];
}
string str = to_string(puz[0])+to_string(puz[1])+to_string(puz[2])+to_string(puz[3])+to_string(puz[4])+to_string(puz[5])+to_string(puz[6])+to_string(puz[7]);
cout << memo[str] << endl;
}
else break;
}
return 0;
} | a.cc:11:12: error: template argument 1 is invalid
11 | queue <data> bfs;
| ^
a.cc:11:12: error: template argument 2 is invalid
a.cc: In function 'std::string to_string(int)':
a.cc:14:20: error: conversion from 'int' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
14 | string x = n;
| ^
a.cc: In function 'int main()':
a.cc:19:9: error: reference to 'data' is ambiguous
19 | data first;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:21:17: error: 'first' was not declared in this scope
21 | first.d[i] = i;
| ^~~~~
a.cc:23:9: error: 'first' was not declared in this scope
23 | first.count = 0;
| ^~~~~
a.cc:24:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
24 | bfs.push(first);
| ^~~~
a.cc:26:25: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
26 | if (bfs.empty()) break;
| ^~~~~
a.cc:27:17: error: reference to 'data' is ambiguous
27 | data front = bfs.front();
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:28:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
28 | bfs.pop();
| ^~~
a.cc:29:40: error: 'front' was not declared in this scope
29 | string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
| ^~~~~
a.cc:47:33: error: reference to 'data' is ambiguous
47 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:48:38: error: expected unqualified-id before '.' token
48 | array.count = front.count + 1;
| ^
a.cc:49:42: error: missing template arguments before '.' token
49 | x = array.d[zero];
| ^
a.cc:50:38: error: expected unqualified-id before '.' token
50 | array.d[zero] = array.d[zero+4];
| ^
a.cc:51:38: error: expected unqualified-id before '.' token
51 | array.d[zero+4] = x;
| ^
a.cc:52:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
52 | bfs.push(array);
| ^~~~
a.cc:52:47: error: missing template arguments before ')' token
52 | bfs.push(array);
| ^
a.cc:55:41: error: reference to 'data' is ambiguous
55 | data array2 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:56:41: error: 'array2' was not declared in this scope
56 | array2.count = front.count + 1;
| ^~~~~~
a.cc:60:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
60 | bfs.push(array2);
| ^~~~
a.cc:64:41: error: reference to 'data' is ambiguous
64 | data array3 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:65:41: error: 'array3' was not declared in this scope
65 | array3.count = front.count + 1;
| ^~~~~~
a.cc:69:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
69 | bfs.push(array3);
| ^~~~
a.cc:75:33: error: reference to 'data' is ambiguous
75 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> c |
s964040202 | p00121 | C++ | #include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef struct {
int d[8];
int count;
} data;
map <string,int> memo;
queue <data> bfs;
string to_string(int n) {
char a = n;
string b = a;
return b;
}
int main() {
data first;
for (int i = 0;i < 8;i++) {
first.d[i] = i;
}
first.count = 0;
bfs.push(first);
for (;;) {
if (bfs.empty()) break;
data front = bfs.front();
bfs.pop();
string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
if(memo.find(str) !=memo.end()){
continue;
}
memo[str] = front.count;
//Find Zero
int zero;
for (int i = 0;i < 8;i++) {
if (front.d[i] == 0) {
zero = i;
break;
}
}
//Move
if (zero < 4) {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero+4];
array.d[zero+4] = x;
bfs.push(array);
if (zero>0) {
int y;
data array2 = front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<3) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
else {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero-4];
array.d[zero-4] = x;
bfs.push(array);
if (zero>4) {
int y;
data array2= front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<7) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
}
while(true) {
int puz[8];
if (cin >> puz[0]) {
for (int i = 1;i < 8;i++) {
cin >> puz[i];
}
string str = to_string(puz[0])+to_string(puz[1])+to_string(puz[2])+to_string(puz[3])+to_string(puz[4])+to_string(puz[5])+to_string(puz[6])+to_string(puz[7]);
cout << memo[str] << endl;
}
else break;
}
return 0;
} | a.cc:11:12: error: template argument 1 is invalid
11 | queue <data> bfs;
| ^
a.cc:11:12: error: template argument 2 is invalid
a.cc: In function 'std::string to_string(int)':
a.cc:15:20: error: conversion from 'char' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
15 | string b = a;
| ^
a.cc: In function 'int main()':
a.cc:20:9: error: reference to 'data' is ambiguous
20 | data first;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:22:17: error: 'first' was not declared in this scope
22 | first.d[i] = i;
| ^~~~~
a.cc:24:9: error: 'first' was not declared in this scope
24 | first.count = 0;
| ^~~~~
a.cc:25:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
25 | bfs.push(first);
| ^~~~
a.cc:27:25: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
27 | if (bfs.empty()) break;
| ^~~~~
a.cc:28:17: error: reference to 'data' is ambiguous
28 | data front = bfs.front();
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:29:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
29 | bfs.pop();
| ^~~
a.cc:30:40: error: 'front' was not declared in this scope
30 | string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
| ^~~~~
a.cc:48:33: error: reference to 'data' is ambiguous
48 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:49:38: error: expected unqualified-id before '.' token
49 | array.count = front.count + 1;
| ^
a.cc:50:42: error: missing template arguments before '.' token
50 | x = array.d[zero];
| ^
a.cc:51:38: error: expected unqualified-id before '.' token
51 | array.d[zero] = array.d[zero+4];
| ^
a.cc:52:38: error: expected unqualified-id before '.' token
52 | array.d[zero+4] = x;
| ^
a.cc:53:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
53 | bfs.push(array);
| ^~~~
a.cc:53:47: error: missing template arguments before ')' token
53 | bfs.push(array);
| ^
a.cc:56:41: error: reference to 'data' is ambiguous
56 | data array2 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:57:41: error: 'array2' was not declared in this scope
57 | array2.count = front.count + 1;
| ^~~~~~
a.cc:61:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
61 | bfs.push(array2);
| ^~~~
a.cc:65:41: error: reference to 'data' is ambiguous
65 | data array3 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:66:41: error: 'array3' was not declared in this scope
66 | array3.count = front.count + 1;
| ^~~~~~
a.cc:70:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
70 | bfs.push(array3);
| ^~~~
a.cc:76:33: error: reference to 'data' is ambiguous
76 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> |
s741103408 | p00121 | C++ | #include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef struct {
int d[8];
int count;
} data;
map <string,int> memo;
queue <data> bfs;
char to_string(int n) {
char a = n;
string b = a;
return a;
}
int main() {
data first;
for (int i = 0;i < 8;i++) {
first.d[i] = i;
}
first.count = 0;
bfs.push(first);
for (;;) {
if (bfs.empty()) break;
data front = bfs.front();
bfs.pop();
string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
if(memo.find(str) !=memo.end()){
continue;
}
memo[str] = front.count;
//Find Zero
int zero;
for (int i = 0;i < 8;i++) {
if (front.d[i] == 0) {
zero = i;
break;
}
}
//Move
if (zero < 4) {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero+4];
array.d[zero+4] = x;
bfs.push(array);
if (zero>0) {
int y;
data array2 = front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<3) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
else {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero-4];
array.d[zero-4] = x;
bfs.push(array);
if (zero>4) {
int y;
data array2= front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<7) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
}
while(true) {
int puz[8];
if (cin >> puz[0]) {
for (int i = 1;i < 8;i++) {
cin >> puz[i];
}
string str = to_string(puz[0])+to_string(puz[1])+to_string(puz[2])+to_string(puz[3])+to_string(puz[4])+to_string(puz[5])+to_string(puz[6])+to_string(puz[7]);
cout << memo[str] << endl;
}
else break;
}
return 0;
} | a.cc:11:12: error: template argument 1 is invalid
11 | queue <data> bfs;
| ^
a.cc:11:12: error: template argument 2 is invalid
a.cc: In function 'char to_string(int)':
a.cc:15:20: error: conversion from 'char' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
15 | string b = a;
| ^
a.cc: In function 'int main()':
a.cc:20:9: error: reference to 'data' is ambiguous
20 | data first;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:22:17: error: 'first' was not declared in this scope
22 | first.d[i] = i;
| ^~~~~
a.cc:24:9: error: 'first' was not declared in this scope
24 | first.count = 0;
| ^~~~~
a.cc:25:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
25 | bfs.push(first);
| ^~~~
a.cc:27:25: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
27 | if (bfs.empty()) break;
| ^~~~~
a.cc:28:17: error: reference to 'data' is ambiguous
28 | data front = bfs.front();
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:29:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
29 | bfs.pop();
| ^~~
a.cc:30:40: error: 'front' was not declared in this scope
30 | string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
| ^~~~~
a.cc:48:33: error: reference to 'data' is ambiguous
48 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:49:38: error: expected unqualified-id before '.' token
49 | array.count = front.count + 1;
| ^
a.cc:50:42: error: missing template arguments before '.' token
50 | x = array.d[zero];
| ^
a.cc:51:38: error: expected unqualified-id before '.' token
51 | array.d[zero] = array.d[zero+4];
| ^
a.cc:52:38: error: expected unqualified-id before '.' token
52 | array.d[zero+4] = x;
| ^
a.cc:53:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
53 | bfs.push(array);
| ^~~~
a.cc:53:47: error: missing template arguments before ')' token
53 | bfs.push(array);
| ^
a.cc:56:41: error: reference to 'data' is ambiguous
56 | data array2 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:57:41: error: 'array2' was not declared in this scope
57 | array2.count = front.count + 1;
| ^~~~~~
a.cc:61:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
61 | bfs.push(array2);
| ^~~~
a.cc:65:41: error: reference to 'data' is ambiguous
65 | data array3 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:66:41: error: 'array3' was not declared in this scope
66 | array3.count = front.count + 1;
| ^~~~~~
a.cc:70:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
70 | bfs.push(array3);
| ^~~~
a.cc:76:33: error: reference to 'data' is ambiguous
76 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constex |
s825500658 | p00121 | C++ | #include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef struct {
int d[8];
int count;
} data;
map <string,int> memo;
queue <data> bfs;
char to_string(int n) {
for (int i = 0;i < 10;i++) {
if (n==i) return i;
}
}
int main() {
data first;
for (int i = 0;i < 8;i++) {
first.d[i] = i;
}
first.count = 0;
bfs.push(first);
for (;;) {
if (bfs.empty()) break;
data front = bfs.front();
bfs.pop();
string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
if(memo.find(str) !=memo.end()){
continue;
}
memo[str] = front.count;
//Find Zero
int zero;
for (int i = 0;i < 8;i++) {
if (front.d[i] == 0) {
zero = i;
break;
}
}
//Move
if (zero < 4) {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero+4];
array.d[zero+4] = x;
bfs.push(array);
if (zero>0) {
int y;
data array2 = front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<3) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
else {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero-4];
array.d[zero-4] = x;
bfs.push(array);
if (zero>4) {
int y;
data array2= front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<7) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
}
while(true) {
int puz[8];
if (cin >> puz[0]) {
for (int i = 1;i < 8;i++) {
cin >> puz[i];
}
string str = to_string(puz[0])+to_string(puz[1])+to_string(puz[2])+to_string(puz[3])+to_string(puz[4])+to_string(puz[5])+to_string(puz[6])+to_string(puz[7]);
cout << memo[str] << endl;
}
else break;
}
return 0;
} | a.cc:11:12: error: template argument 1 is invalid
11 | queue <data> bfs;
| ^
a.cc:11:12: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:20:9: error: reference to 'data' is ambiguous
20 | data first;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:22:17: error: 'first' was not declared in this scope
22 | first.d[i] = i;
| ^~~~~
a.cc:24:9: error: 'first' was not declared in this scope
24 | first.count = 0;
| ^~~~~
a.cc:25:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
25 | bfs.push(first);
| ^~~~
a.cc:27:25: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
27 | if (bfs.empty()) break;
| ^~~~~
a.cc:28:17: error: reference to 'data' is ambiguous
28 | data front = bfs.front();
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:29:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
29 | bfs.pop();
| ^~~
a.cc:30:40: error: 'front' was not declared in this scope
30 | string str = to_string(front.d[0])+to_string(front.d[1])+to_string(front.d[2])+to_string(front.d[3])+to_string(front.d[4])+to_string(front.d[5])+to_string(front.d[6])+to_string(front.d[7]);
| ^~~~~
a.cc:48:33: error: reference to 'data' is ambiguous
48 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:49:38: error: expected unqualified-id before '.' token
49 | array.count = front.count + 1;
| ^
a.cc:50:42: error: missing template arguments before '.' token
50 | x = array.d[zero];
| ^
a.cc:51:38: error: expected unqualified-id before '.' token
51 | array.d[zero] = array.d[zero+4];
| ^
a.cc:52:38: error: expected unqualified-id before '.' token
52 | array.d[zero+4] = x;
| ^
a.cc:53:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
53 | bfs.push(array);
| ^~~~
a.cc:53:47: error: missing template arguments before ')' token
53 | bfs.push(array);
| ^
a.cc:56:41: error: reference to 'data' is ambiguous
56 | data array2 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:57:41: error: 'array2' was not declared in this scope
57 | array2.count = front.count + 1;
| ^~~~~~
a.cc:61:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
61 | bfs.push(array2);
| ^~~~
a.cc:65:41: error: reference to 'data' is ambiguous
65 | data array3 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:66:41: error: 'array3' was not declared in this scope
66 | array3.count = front.count + 1;
| ^~~~~~
a.cc:70:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
70 | bfs.push(array3);
| ^~~~
a.cc:76:33: error: reference to 'data' is ambiguous
76 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'temp |
s474007250 | p00121 | C++ | #include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef struct {
int d[8];
int count;
} data;
map <string,int> memo;
queue <data> bfs;
string tto_string(int n) {
std::stringstream ss;
ss << n;
std::string str = ss.str();
return str;
}
int main() {
data first;
for (int i = 0;i < 8;i++) {
first.d[i] = i;
}
first.count = 0;
bfs.push(first);
for (;;) {
if (bfs.empty()) break;
data front = bfs.front();
bfs.pop();
string str = tto_string(front.d[0])+tto_string(front.d[1])+tto_string(front.d[2])+tto_string(front.d[3])+tto_string(front.d[4])+tto_string(front.d[5])+tto_string(front.d[6])+tto_string(front.d[7]);
if(memo.find(str) !=memo.end()){
continue;
}
memo[str] = front.count;
//Find Zero
int zero;
for (int i = 0;i < 8;i++) {
if (front.d[i] == 0) {
zero = i;
break;
}
}
//Move
if (zero < 4) {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero+4];
array.d[zero+4] = x;
bfs.push(array);
if (zero>0) {
int y;
data array2 = front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<3) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
else {
//???????????\?????????
int x;
data array = front;
array.count = front.count + 1;
x = array.d[zero];
array.d[zero] = array.d[zero-4];
array.d[zero-4] = x;
bfs.push(array);
if (zero>4) {
int y;
data array2= front;
array2.count = front.count + 1;
y = array2.d[zero];
array2.d[zero] = array2.d[zero-1];
array2.d[zero-1] = y;
bfs.push(array2);
}
if(zero<7) {
int z;
data array3 = front;
array3.count = front.count + 1;
z = array3.d[zero];
array3.d[zero] = array3.d[zero+1];
array3.d[zero+1] = z;
bfs.push(array3);
}
}
}
while(true) {
int puz[8];
if (cin >> puz[0]) {
for (int i = 1;i < 8;i++) {
cin >> puz[i];
}
string str = tto_string(puz[0])+tto_string(puz[1])+tto_string(puz[2])+tto_string(puz[3])+tto_string(puz[4])+tto_string(puz[5])+tto_string(puz[6])+tto_string(puz[7]);
cout << memo[str] << endl;
}
else break;
}
return 0;
} | a.cc:11:12: error: template argument 1 is invalid
11 | queue <data> bfs;
| ^
a.cc:11:12: error: template argument 2 is invalid
a.cc: In function 'std::string tto_string(int)':
a.cc:14:19: error: aggregate 'std::stringstream ss' has incomplete type and cannot be defined
14 | std::stringstream ss;
| ^~
a.cc: In function 'int main()':
a.cc:21:9: error: reference to 'data' is ambiguous
21 | data first;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:23:17: error: 'first' was not declared in this scope
23 | first.d[i] = i;
| ^~~~~
a.cc:25:9: error: 'first' was not declared in this scope
25 | first.count = 0;
| ^~~~~
a.cc:26:13: error: request for member 'push' in 'bfs', which is of non-class type 'int'
26 | bfs.push(first);
| ^~~~
a.cc:28:25: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
28 | if (bfs.empty()) break;
| ^~~~~
a.cc:29:17: error: reference to 'data' is ambiguous
29 | data front = bfs.front();
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:30:21: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
30 | bfs.pop();
| ^~~
a.cc:31:41: error: 'front' was not declared in this scope
31 | string str = tto_string(front.d[0])+tto_string(front.d[1])+tto_string(front.d[2])+tto_string(front.d[3])+tto_string(front.d[4])+tto_string(front.d[5])+tto_string(front.d[6])+tto_string(front.d[7]);
| ^~~~~
a.cc:49:33: error: reference to 'data' is ambiguous
49 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:50:38: error: expected unqualified-id before '.' token
50 | array.count = front.count + 1;
| ^
a.cc:51:42: error: missing template arguments before '.' token
51 | x = array.d[zero];
| ^
a.cc:52:38: error: expected unqualified-id before '.' token
52 | array.d[zero] = array.d[zero+4];
| ^
a.cc:53:38: error: expected unqualified-id before '.' token
53 | array.d[zero+4] = x;
| ^
a.cc:54:37: error: request for member 'push' in 'bfs', which is of non-class type 'int'
54 | bfs.push(array);
| ^~~~
a.cc:54:47: error: missing template arguments before ')' token
54 | bfs.push(array);
| ^
a.cc:57:41: error: reference to 'data' is ambiguous
57 | data array2 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:58:41: error: 'array2' was not declared in this scope
58 | array2.count = front.count + 1;
| ^~~~~~
a.cc:62:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
62 | bfs.push(array2);
| ^~~~
a.cc:66:41: error: reference to 'data' is ambiguous
66 | data array3 = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:3: note: 'typedef struct data data'
9 | } data;
| ^~~~
a.cc:67:41: error: 'array3' was not declared in this scope
67 | array3.count = front.count + 1;
| ^~~~~~
a.cc:71:45: error: request for member 'push' in 'bfs', which is of non-class type 'int'
71 | bfs.push(array3);
| ^~~~
a.cc:77:33: error: reference to 'data' is ambiguous
77 | data array = front;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__ |
s554360712 | p00121 | C++ | #include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
cin >> a
cout << a << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:8:9: error: expected ';' before 'cout'
8 | cin >> a
| ^
| ;
9 | cout << a << endl;
| ~~~~
|
s677693940 | p00121 | C++ | テ」ツつ?」ツつ?
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define INF 999999999
#define MAX_V 100
unsigned int dp[8][8][8][8][8][8][8];
int d[]={-1,1,-4,+4};
vector<vector<int>> makeNext(vector<int> board){
int zero;
rep(i,8){
if(board[i]==0)zero=i;
}
vector<vector<int>> ret;
rep(i,4){
vector<int> tmp = board;
int dd = zero+d[i];
if(dd>=0 && dd<8){
if(zero==3&&d[i]==1 )continue;
if(zero==4&&d[i]==-1)continue;
swap( tmp[zero],tmp[dd] );
cout<<"---"<<zero<<" "<<dd<<":";;rep(j,tmp.size())cout<<tmp[j]<<" ";cout<<endl;cout<<endl;
ret.pb(tmp);
}
}
return ret;
}
bool is(vector<int> board){
rep(i,7){
if(board[i]+1!=board[i+1])return false;
}
return true;
}
int dfs(vector<int> board,int f){
if(f>10)return 65535;
if(is(board)){
dp[ board[0] ][ board[1] ][ board[2] ][ board[3] ][ board[4] ][ board[5] ][ board[6] ] = f;
return f;
}
if(dp[ board[0] ][ board[1] ][ board[2] ][ board[3] ][ board[4] ][ board[5] ][ board[6] ]!=65535){
return dp[ board[0] ][ board[1] ][ board[2] ][ board[3] ][ board[4] ][ board[5] ][ board[6] ];
}
vector<vector<int>> next = makeNext(board);
rep(i,next.size()){rep(j,next[i].size()){cout<<next[i][j]<<" ";}cout<<endl;}cout<<endl;
int mini =INF;
rep(i,next.size()){
mini = min(mini,dfs(board,f+1));
}
dp[ board[0] ][ board[1] ][ board[2] ][ board[3] ][ board[4] ][ board[5] ][ board[6] ] = mini;
return mini;
}
int main(){
rep(i0,8)rep(i1,8)rep(i2,8)rep(i3,8)rep(i4,8)rep(i5,8)rep(i6,8)dp[i0][i1][i2][i3][i4][i5][i6] = 65535;
vector<int> data(8);
rep(i,8)cin>>data[i];
dp[ data[0] ][ data[1] ][ data[2] ][ data[3] ][ data[4] ][ data[5] ][ data[6] ] = 0;
int mini = INF;
vector<vector<int>> next = makeNext(data);
rep(i,next.size()){
mini = min(mini,dfs(next[i],1));
}
cout<<mini<<endl;
} | a.cc:1:1: error: extended character 」 is not valid in an identifier
1 | テ」ツつ?」ツつ?
| ^
a.cc:1:10: error: extended character 」 is not valid in an identifier
1 | テ」ツつ?」ツつ?
| ^
a.cc:1:1: error: '\U000030c6\U0000300d\U000030c4\U00003064' does not name a type
1 | テ」ツつ?」ツつ?
| ^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared he |
s729963408 | p00121 | C++ | #include <cstdio>
#include <iostream>
#include <string>
#include <queue>
using namespace std;
typedef struct node {
int seq[8];
int id;
int s;
int step;
} item;
int idBox[40400];
int idCnt;
int dmove[] = {-1, -4, +1, +4};
int ans[] = {0,1,2,3,4,5,6,7};
int bfs(item n);
bool isUnique(int id);
int main() {
while (1) {
item start;
start.step = 0;
for (int i = 0; i<8; i++) {
if (scanf("%d", &start.seq[i])==EOF) return 0;
if (start.seq[i]==0) start.s = i;
}
for (int i = 0; i<8; i++)
start.id = start.id*10+start.seq[i];
isUnique(start.id);
cout<<bfs(start)<<endl;
memset(idBox, 0, sizeof(idBox));
idCnt = 0;
}
return 0;
}
bool isUnique(int id) {
//??????idBox????????????id??????????°±??????id??°idBox???
for (int i = 0; i<idCnt; i++)
if (id==idBox[i]) return false;
idBox[idCnt++] = id;
return true;
}
int bfs(item n) {
queue<item> Q;
Q.push(n);
while (Q.size()) {
item now = Q.front();
Q.pop();
if (memcmp(ans, now.seq, sizeof(ans))==0)
return now.step;
for (int i = 0; i<4; i++) {
int ns = now.s + dmove[i];
if (ns>=0 && ns<=7 && !(now.s==3 && ns==4) && !(now.s==4 && ns==3)) {
item tmp;//???????????¨????????????????????°????????????????\????
memset(&tmp, 0, sizeof(tmp));
for (int i = 0; i<8; i++)
tmp.seq[i] = now.seq[i];
tmp.seq[ns] = now.seq[now.s];
tmp.seq[now.s] = now.seq[ns];
//?????¢0???ns???????????°??????
for (int i = 0; i<8; i++)
tmp.id = tmp.id*10+tmp.seq[i];
//??????id
tmp.s = ns; tmp.step = now.step+1;
//??????????????¶????????°
if (isUnique(tmp.id)) Q.push(tmp);
}
}
}
return -1;
} | a.cc: In function 'int main()':
a.cc:40:17: error: 'memset' was not declared in this scope
40 | memset(idBox, 0, sizeof(idBox));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <queue>
+++ |+#include <cstring>
5 | using namespace std;
a.cc: In function 'int bfs(item)':
a.cc:64:21: error: 'memcmp' was not declared in this scope
64 | if (memcmp(ans, now.seq, sizeof(ans))==0)
| ^~~~~~
a.cc:64:21: note: 'memcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:71:33: error: 'memset' was not declared in this scope
71 | memset(&tmp, 0, sizeof(tmp));
| ^~~~~~
a.cc:71:33: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s173648202 | p00121 | C++ | #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-7;
vi d(8, 0), t;
vi a(8, 0);
set<vi> s;
pair<int ,vi> p;
int ans = 0;
int c;
bool check(vi v){
for(int i = 0; i < 8; i++){
if(v[i]!=i) return false;
}
return true;
}
int main(){
rep(i, 8) a[i]=i;
int cnt = 0;
while(/*cin>>d[0]*/scanf("%d", &d[i])!=EOF){
//rep(i, 7) cin>>d[i+1];
rep(i, 7){
scanf("%d", &d[i+1]);
}
s.clear();
queue<pair<int ,vi> > q;
q.push(mp(0, d));
s.insert(d);
cnt = 0;
while(!q.empty()){
//cout<<cnt++<<endl;
cnt++;
p = q.front(); q.pop();
c = p.fi;
t = p.se;
// if(cnt == 0){
// for(int i = 0; i < 8; i++){
// cout<<" "<<t[i];
// }
// cout<<endl;
// }
if(check(t)){
//cout<<c<<endl;
printf("%d\n", c);
break;
}
for(int i = 0; i < 8; i++){
//cout<<" "<<i<<endl;
if(p.se[i] == 0){
if(i%4!=0){
t = p.se;
swap(t[i], t[i-1]);
if(s.count(t)==0){
q.push(mp(c+1, t));
s.insert(t);
}
}
if(i%4!=3){
t = p.se;
swap(t[i], t[i+1]);
if(s.count(t)==0){
q.push(mp(c+1, t));
s.insert(t);
}
}
if(i/4==0){
t = p.se;
swap(t[i], t[i+4]);
if(s.count(t)==0){
q.push(mp(c+1, t));
s.insert(t);
}
}
else{
t = p.se;
swap(t[i], t[i-4]);
if(s.count(t)==0){
q.push(mp(c+1, t));
s.insert(t);
}
}
break;
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:68:43: error: 'i' was not declared in this scope; did you mean 'vi'?
68 | while(/*cin>>d[0]*/scanf("%d", &d[i])!=EOF){
| ^
| vi
|
s963259904 | p00121 | C++ | // test.cpp : 定?控制台?用程序的入口点。
//
#include "stdafx.h"
#include<stdio.h>
#include<map>
#include<queue>
using namespace std;
int a[8] = {0};
int direction[4][2] = {{-1,0},{1,0},{0,-1},{0,1}};
map<int,int> exitmap;
struct array{
int map[2][4];
int step;
};
bool isInMap(int x,int y){
if(x<0 || x>=2)return 0;
if(y<0 || y>=4)return 0;
else return 1;
}
void bfs(){
array begin = {{0,1,2,3,4,5,6,7},0};
queue<array> que;
que.push(begin);
exitmap.insert(make_pair(1234567,0));
while(!que.empty()){
int x,y;
array temp = que.front();
que.pop();
for(int i = 0; i < 2; i++)
for(int j = 0; j < 4; j++)
if(temp.map[i][j] == 0)
{x = i;y = j;}
for(int k = 0; k < 4; k++)
{
if(isInMap(x+direction[k][0],y+direction[k][1])){
array newarray = temp;
int r = newarray.map[x][y];
newarray.map[x][y] = newarray.map[x+direction[k][0]][y+direction[k][1]];
newarray.map[x+direction[k][0]][y+direction[k][1]] = r;
newarray.step = temp.step + 1;
int num = 0;
for(int i = 0; i < 2; i++)
for(int j = 0; j < 4; j++)
num = num * 10 + newarray.map[i][j];
if(exitmap.find(num) == exitmap.end())
{
que.push(newarray);
exitmap.insert(make_pair(num,newarray.step));
}
}
}
}
}
int main(){
bfs();
int temp;
while (~scanf("%d",&temp))
{
int num = temp;
for(int i = 1; i < 8; i++)
{
scanf("%d",&temp);
num = num * 10 + temp;
}
printf("%d\n",exitmap[num]);
}
return 0;
} | a.cc:4:10: fatal error: stdafx.h: No such file or directory
4 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
|
s308343359 | p00121 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef pair<string, int> P;
map<string, int> m;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
queue<P> q;
q.push(P("01234567", 0));
m["01234567"] = 0;
while(!q.empty()) {
P p = q.front();
q.pop();
if(m[p.first] != p.second) continue;
string s = p.first;
int d[] = { 1, -1 4, -4 };
for(int i = 0; i < 8; i++) {
if(s[i] != '0') continue;
for(int j = 0; j < 4; j++) {
if(i + d[j] < 0 || 8 <= i + d[j]) continue;
if(d[j] == 1 && i == 3) continue;
swap(s[i], s[i + d[j]]);
if(m.find(s) == m.end() || p.second + 1 < m[s]) {
m[s] = p.second + 1;
q.push(P(s, p.second + 1));
}
swap(s[i], s[i + d[j]]);
}
}
}
string s;
while(getline(cin, s)) {
string ss;
for(int i = 0; i < 8; i++) {
ss += s[2 * i];
}
cout << m[ss] << endl;
}
} | a.cc: In function 'int main()':
a.cc:23:35: error: expected '}' before numeric constant
23 | int d[] = { 1, -1 4, -4 };
| ~ ^
a.cc:23:35: error: expected ',' or ';' before numeric constant
a.cc:25:28: error: 's' was not declared in this scope
25 | if(s[i] != '0') continue;
| ^
a.cc:27:40: error: 'd' was not declared in this scope
27 | if(i + d[j] < 0 || 8 <= i + d[j]) continue;
| ^
a.cc:28:36: error: 'd' was not declared in this scope
28 | if(d[j] == 1 && i == 3) continue;
| ^
a.cc:29:38: error: 's' was not declared in this scope
29 | swap(s[i], s[i + d[j]]);
| ^
a.cc:29:50: error: 'd' was not declared in this scope
29 | swap(s[i], s[i + d[j]]);
| ^
a.cc:30:60: error: 'p' was not declared in this scope
30 | if(m.find(s) == m.end() || p.second + 1 < m[s]) {
| ^
a.cc: At global scope:
a.cc:40:9: error: expected unqualified-id before 'while'
40 | while(getline(cin, s)) {
| ^~~~~
a.cc:47:1: error: expected declaration before '}' token
47 | }
| ^
|
s044303942 | p00121 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
map<vector<int>, int>MVII;
vector<int>D(8);
for(int i = 0;i < 8; i++){
D[i]=i;
}
queue<vector<int>>que;
que.push(D);
while(que.size()){
auto now = que.front(); que.pop();
for(int i = 0;i < 4; i++){
auto E = now;
swap(E[i], E[i+4]);
if(MVII[E]==0){
MVII[E]=MVII(now)+1;
que.push(E);
}
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 2; j++){
auto E = now;
swap(E[j*4+i],E[j*4+i+1]);
if(MVII[E]==0){
MVII[E]=MVII(now)+1;
que.push(E);
}
}
}
while(cin>>D[0]){
for(int i = 1;i<8;i++){
cin>>D[i];
}
cout<<MVII[D]<<endl;
}
} | a.cc: In function 'int main()':
a.cc:21:21: error: no match for call to '(std::map<std::vector<int>, int>) (std::vector<int>&)'
21 | MVII[E]=MVII(now)+1;
| ~~~~^~~~~
a.cc:30:21: error: no match for call to '(std::map<std::vector<int>, int>) (std::vector<int>&)'
30 | MVII[E]=MVII(now)+1;
| ~~~~^~~~~
a.cc:42:2: error: expected '}' at end of input
42 | }
| ^
a.cc:5:11: note: to match this '{'
5 | int main(){
| ^
|
s137484947 | p00121 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
map<vector<int>, int>MVII;
vector<int>D(8);
for(int i = 0;i < 8; i++){
D[i]=i;
}
queue<vector<int>>que;
que.push(D);
while(que.size()){
vector<int> now = que.front(); que.pop();
for(int i = 0;i < 4; i++){
auto E = now;
swap(E[i], E[i+4]);
if(MVII[E]==0){
MVII[E]=MVII(now)+1;
que.push(E);
}
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 2; j++){
auto E = now;
swap(E[j*4+i],E[j*4+i+1]);
if(MVII[E]==0){
MVII[E]=MVII(now)+1;
que.push(E);
}
}
}
while(cin>>D[0]){
for(int i = 1;i<8;i++){
cin>>D[i];
}
cout<<MVII[D]<<endl;
}
} | a.cc: In function 'int main()':
a.cc:21:21: error: no match for call to '(std::map<std::vector<int>, int>) (std::vector<int>&)'
21 | MVII[E]=MVII(now)+1;
| ~~~~^~~~~
a.cc:30:21: error: no match for call to '(std::map<std::vector<int>, int>) (std::vector<int>&)'
30 | MVII[E]=MVII(now)+1;
| ~~~~^~~~~
a.cc:42:2: error: expected '}' at end of input
42 | }
| ^
a.cc:5:11: note: to match this '{'
5 | int main(){
| ^
|
s695083057 | p00121 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
map<vector<int>, int>MVII;
vector<int>D(8);
for(int i = 0;i < 8; i++){
D[i]=i;
}
queue<vector<int>>que;
que.push(D);
while(que.size()){
vector<int> now = que.front(); que.pop();
for(int i = 0;i < 4; i++){
auto E = now;
swap(E[i], E[i+4]);
if(MVII[E]==0){
MVII[E]=MVII[now]+1;
que.push(E);
}
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 2; j++){
auto E = now;
swap(E[j*4+i],E[j*4+i+1]);
if(MVII[E]==0){
MVII[E]=MVII[now]+1;
que.push(E);
}
}
while(cin>>D[0]){
for(int i = 1;i<8;i++){
cin>>D[i];
}
cout<<MVII[D]<<endl;
}
} | a.cc: In function 'int main()':
a.cc:42:2: error: expected '}' at end of input
42 | }
| ^
a.cc:14:18: note: to match this '{'
14 | while(que.size()){
| ^
a.cc:42:2: error: expected '}' at end of input
42 | }
| ^
a.cc:5:11: note: to match this '{'
5 | int main(){
| ^
|
s891339402 | p00121 | C++ | #include <cstdio>
#include <map>
#include <queue>
#define PRINTF(...)
using namespace std;
int puzzles[1000][8];
int goal[8] = {0, 1, 2, 3, 4, 5, 6, 7};
int n;
static inline int encode(int arg[8]) {
int ret = 0;
for (int i = 0; i < 8; i++) {
ret += arg[i] * (1 << (3 * (7 - i)));
}
return ret;
}
void decode(int e, int *ret) {
for (int i = 0; i < 8; i++) {
ret[7 - i] = (e >> (3 * i)) & 7;
}
}
int egoal = encode(goal);
int solve(int p[8]) {
map<int, int> mp;
queue<int> q;
int count = 0;
int e = encode(p);
q.push(e);
mp[e] = 0;
while (q.size()) {
int cp[8];
int ce = q.front(); q.pop();
decode(ce, cp);
int cn = mp[ce];
if (ce == egoal) {
break;
}
PRINTF("now cp: \n");
for (int j = 0; j < 8; j++) {
PRINTF("%d", cp[j]);
if (j == 3)
PRINTF("\n");
}
PRINTF("\n");
// Find zero
int z = 0;
for (int i = 0; i < 8; i++) {
if (cp[i] == 0) {
z = i;
break;
}
}
PRINTF("zero is %d\n", z);
int zy = (z >= 4);
int zx = z % 4;
//PRINTF(" z: %d, zy: %d, zx: %d\n", z, zy, zx);
int dirs[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
for (int i = 0; i < 4; i++) {
int ny = zy + dirs[i][0];
int nx = zx + dirs[i][1];
int nz = z + dirs[i][0] * 4 + dirs[i][1];
if (nx >= 0 && nx < 4 && ny >= 0 && ny < 2) {
int np[8];
memcpy(np, cp, sizeof(np));
// Swap
//PRINTF(" swapping %d:[%d, %d] %d:[%d, %d]\n", z, zy, zx, nz, ny, nx);
int tmp = np[z];
np[z] = np[nz];
np[nz] = tmp;
//PRINTF(" swapped \n ");
for (int j = 0; j < 8; j++) {
//PRINTF("%d", np[j]);
}
//PRINTF("\n");
int ne = encode(np);
auto itr = mp.find(ne);
if (itr == mp.end() || cn + 1 < itr->second) {
//PRINTF(" not found or not min. cn:%d, sec:%d\n", cn, itr->second);
q.push(ne);
mp[ne] = cn + 1;
} else {
//PRINTF(" found or min. cn:%d\n", cn);
if (itr != mp.end()) {
//PRINTF(" sec:%d\n", itr->second);
}
}
}
}
}
return mp[egoal];
}
int main() {
while (true) {
for (int i = 0; i < 8; i++) {
if (scanf(" %d", &puzzles[n][i]) == EOF)
return 0;
}
PRINTF("solving: ");
for (int i = 0; i < 8; i++) {
PRINTF("%d ", puzzles[n][i]);
}
PRINTF("\n");
printf("%d\n", solve(puzzles[n++]));
}
} | a.cc: In function 'int solve(int*)':
a.cc:76:17: error: 'memcpy' was not declared in this scope
76 | memcpy(np, cp, sizeof(np));
| ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <queue>
+++ |+#include <cstring>
4 |
|
s462964153 | p00121 | C++ | import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) throws Exception{
try(Scanner sc = new Scanner(System.in)){
while(sc.hasNextInt()){
Queue<State> queue = new LinkedList<>();
Set<Integer> set = new HashSet<>();
int[][] firstNums = new int[2][4];
int firstZeroX = -1;
int firstZeroY = -1;
for(int y = 0; y < 2; y++){
for(int x = 0; x < 4; x++){
firstNums[y][x] = sc.nextInt();
if(firstNums[y][x] == 0){
firstZeroY = y;
firstZeroX = x;
}
}
}
State firstState = new State(firstNums, firstZeroY, firstZeroX, 0);
set.add(firstState.hashCode());
queue.add(firstState);
while(!queue.isEmpty()){
State nowState = queue.poll();
if(nowState.hashCode() == 1234567){
System.out.println(nowState.getDepth());
break;
}
for(State nextState : nowState.nextMove()){
if(!set.contains(nextState.hashCode())){
set.add(nextState.hashCode());
queue.add(nextState);
}
}
}
}
}
}
}
class State {
private static final int[] vy = new int[]{0, 1, 0, -1};
private static final int[] vx = new int[]{1, 0, -1, 0};
private int[][] nums;
private int zeroX;
private int zeroY;
private int hash;
private int depth;
public State(int[][] nums, int zeroY, int zeroX, int depth){
this.nums = nums;
this.zeroY = zeroY;
this.zeroX = zeroX;
this.depth = depth;
this.hash = -1;
}
public int getDepth(){
return depth;
}
public LinkedList<State> nextMove(){
LinkedList<State> list = new LinkedList<>();
for(int i = 0; i < 4; i++){
int nextZeroY = zeroY + vy[i];
int nextZeroX = zeroX + vx[i];
if(nextZeroY < 0 || nextZeroY >= 2) continue;
if(nextZeroX < 0 || nextZeroX >= 4) continue;
int[][] nextNums = new int[2][4];
for(int y = 0; y < 2; y++){
for(int x = 0; x < 4; x++){
nextNums[y][x] = nums[y][x];
}
}
nextNums[nextZeroY][nextZeroX] = 0;
nextNums[zeroY][zeroX] = nums[nextZeroY][nextZeroX];
list.add(new State(nextNums, nextZeroY, nextZeroX, depth + 1));
}
return list;
}
@Override
public int hashCode(){
if(hash != -1) return hash;
hash = 0;
for(int y = 0; y < 2; y++){
for(int x = 0; x < 4; x++){
hash *= 10;
hash += nums[y][x];
}
}
return hash;
}
} | a.cc:93:9: error: stray '@' in program
93 | @Override
| ^
a.cc:1:1: error: 'import' does not name a type
1 | import java.util.HashSet;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.util.LinkedList;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.Queue;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.Scanner;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.Set;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
7 | public class Main {
| ^~~~~~
a.cc:51:16: error: expected ':' before 'static'
51 | private static final int[] vy = new int[]{0, 1, 0, -1};
| ^~~~~~~
| :
a.cc:51:24: error: 'final' does not name a type
51 | private static final int[] vy = new int[]{0, 1, 0, -1};
| ^~~~~
a.cc:52:16: error: expected ':' before 'static'
52 | private static final int[] vx = new int[]{1, 0, -1, 0};
| ^~~~~~~
| :
a.cc:52:24: error: 'final' does not name a type
52 | private static final int[] vx = new int[]{1, 0, -1, 0};
| ^~~~~
a.cc:54:16: error: expected ':' before 'int'
54 | private int[][] nums;
| ^~~~
| :
a.cc:54:20: error: expected unqualified-id before '[' token
54 | private int[][] nums;
| ^
a.cc:55:16: error: expected ':' before 'int'
55 | private int zeroX;
| ^~~~
| :
a.cc:56:16: error: expected ':' before 'int'
56 | private int zeroY;
| ^~~~
| :
a.cc:57:16: error: expected ':' before 'int'
57 | private int hash;
| ^~~~
| :
a.cc:58:16: error: expected ':' before 'int'
58 | private int depth;
| ^~~~
| :
a.cc:60:15: error: expected ':' before 'State'
60 | public State(int[][] nums, int zeroY, int zeroX, int depth){
| ^~~~~~
| :
a.cc:60:28: error: multidimensional array must have bounds for all dimensions except the first
60 | public State(int[][] nums, int zeroY, int zeroX, int depth){
| ^
a.cc:60:30: error: expected ',' or '...' before 'nums'
60 | public State(int[][] nums, int zeroY, int zeroX, int depth){
| ^~~~
a.cc:68:15: error: expected ':' before 'int'
68 | public int getDepth(){
| ^~~~
| :
a.cc:72:15: error: expected ':' before 'LinkedList'
72 | public LinkedList<State> nextMove(){
| ^~~~~~~~~~~
| :
a.cc:72:16: error: 'LinkedList' does not name a type
72 | public LinkedList<State> nextMove(){
| ^~~~~~~~~~
a.cc:93:10: error: 'Override' does not name a type
93 | @Override
| ^~~~~~~~
a.cc:106:2: error: expected ';' after class definition
106 | }
| ^
| ;
a.cc: In constructor 'State::State(...)':
a.cc:61:22: error: request for member 'nums' in '(State*)this', which is of pointer type 'State*' (maybe you meant to use '->' ?)
61 | this.nums = nums;
| ^~~~
a.cc:61:29: error: 'nums' was not declared in this scope
61 | this.nums = nums;
| ^~~~
a.cc:62:22: error: request for member 'zeroY' in '(State*)this', which is of pointer type 'State*' (maybe you meant to use '->' ?)
62 | this.zeroY = zeroY;
| ^~~~~
a.cc:63:22: error: request for member 'zeroX' in '(State*)this', which is of pointer type 'State*' (maybe you meant to use '->' ?)
63 | this.zeroX = zeroX;
| ^~~~~
a.cc:64:22: error: request for member 'depth' in '(State*)this', which is of pointer type 'State*' (maybe you meant to use '->' ?)
64 | this.depth = depth;
| ^~~~~
a.cc:65:22: error: request for member 'hash' in '(State*)this', which is of pointer type 'State*' (maybe you meant to use '->' ?)
65 | this.hash = -1;
| ^~~~
|
s866778051 | p00121 | C++ | #include <cstdio>
#include <set>
#include <vector>
#include <ctype.h>
#include <iostream>
bool is_find(std::vector<int> pieace,std::vector<int> cadidate)
{
for(int i=0;i<8;i++)
if(pieace[i]!=cadidate[i]) return false;
return true;
}
int solve(std::vector<int> init_pieace)
{
int total_step = 0;
std::vector<int> target_list = {0,1,2,3,4,5,6,7};
std::set<std::vector<int>> frontier;
frontier.insert(init_pieace);
std::set<std::vector<int>> previous_frontier;
int step = 0;
while(true)
{
std::set<std::vector<int>> next_frontier;
// std::cout << "step1:"<< step << "\t" << frontier.size() << "\t" << next_frontier.size() << "\t" << previous_frontier.size() << std::endl;
for(auto p : frontier)
{
/*
for(auto x : p)
std::cout << x << ',';
std::cout << std::endl;
*/
if(is_find(target_list,p)) return step;
int zero_position=0;
for(int i=0;i<8;i++)
{
if(p[i]==0)
{
zero_position = i;
break;
}
}
// std::cout << "zero:" << zero_position << std::endl;
int relative = zero_position%4;
std::vector<int> new_peiace=p;
int swap = new_peiace[relative];
new_peiace[relative] = new_peiace[relative+4];
new_peiace[relative+4] = swap;
// if(previous_frontier.count(new_peiace)==0)
if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
next_frontier.insert(new_peiace);
if(0<=relative && relative<3)
{
std::vector<int> new_peiace=p;
int swap = new_peiace[zero_position];
new_peiace[zero_position] = new_peiace[zero_position+1];
new_peiace[zero_position+1] = swap;
// if(previous_frontier.count(new_peiace)==0)
if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
next_frontier.insert(new_peiace);
}
if(0<relative && relative<=3)
{
std::vector<int> new_peiace=p;
int swap = new_peiace[zero_position];
new_peiace[zero_position] = new_peiace[zero_position-1];
new_peiace[zero_position-1] = swap;
// if(previous_frontier.count(new_peiace)==0)
if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
next_frontier.insert(new_peiace);
}
}
/*
if(next_frontier.size()==0)
{
std::cout << "somwthing wrong" << std::endl;
exit(1);
}
std::cout << "------------------------------------------------------------------------------" << std::endl;
for(auto p : next_frontier)
{
for(auto x : p)
std::cout << x << ',';
std::cout << std::endl;
}
std::cout << "==============================================================================" << std::endl;
std::cout << "step2:"<< step << "\t" << frontier.size() << "\t" << next_frontier.size() << "\t" << previous_frontier.size() << std::endl;
*/
previous_frontier = frontier;
frontier = next_frontier;
step++;
}
}
int main()
{
char cline[16];
std::cin.getline(cline, sizeof(cline));
while(0<=cline[0]-'0' && cline[0]-'0'<8)
{
std::vector<int> pieace(8);
int cp = 0;
for(int i=0;i<16;i++)
if(isdigit(cline[i]))
pieace[cp++]=cline[i]-'0';
std::cout << solve(pieace) << std::endl;
std::cin.getline(cline, sizeof(cline));
}
} | a.cc: In function 'int solve(std::vector<int>)':
a.cc:52:37: error: no matching function for call to 'find(std::set<std::vector<int> >::iterator, std::set<std::vector<int> >::iterator, std::vector<int>&)'
52 | if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:5:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:52:37: note: 'std::_Rb_tree_const_iterator<std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >'
52 | if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:62:45: error: no matching function for call to 'find(std::set<std::vector<int> >::iterator, std::set<std::vector<int> >::iterator, std::vector<int>&)'
62 | if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:62:45: note: 'std::_Rb_tree_const_iterator<std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >'
62 | if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:73:45: error: no matching function for call to 'find(std::set<std::vector<int> >::iterator, std::set<std::vector<int> >::iterator, std::vector<int>&)'
73 | if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:73:45: note: 'std::_Rb_tree_const_iterator<std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT, std::char_traits<_CharT> >'
73 | if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s570273368 | p00121 | C++ | #include <cstdio>
#include <set>
#include <vector>
#include <ctype.h>
#include <iostream>
#include <<algorithm>
bool is_find(std::vector<int> pieace,std::vector<int> cadidate)
{
for(int i=0;i<8;i++)
if(pieace[i]!=cadidate[i]) return false;
return true;
}
int solve(std::vector<int> init_pieace)
{
int total_step = 0;
std::vector<int> target_list = {0,1,2,3,4,5,6,7};
std::set<std::vector<int>> frontier;
frontier.insert(init_pieace);
std::set<std::vector<int>> previous_frontier;
int step = 0;
while(true)
{
std::set<std::vector<int>> next_frontier;
for(auto p : frontier)
{
if(is_find(target_list,p)) return step;
int zero_position=0;
for(int i=0;i<8;i++)
{
if(p[i]==0)
{
zero_position = i;
break;
}
}
int relative = zero_position%4;
std::vector<int> new_peiace=p;
int swap = new_peiace[relative];
new_peiace[relative] = new_peiace[relative+4];
new_peiace[relative+4] = swap;
if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
next_frontier.insert(new_peiace);
if(0<=relative && relative<3)
{
std::vector<int> new_peiace=p;
int swap = new_peiace[zero_position];
new_peiace[zero_position] = new_peiace[zero_position+1];
new_peiace[zero_position+1] = swap;
if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
next_frontier.insert(new_peiace);
}
if(0<relative && relative<=3)
{
std::vector<int> new_peiace=p;
int swap = new_peiace[zero_position];
new_peiace[zero_position] = new_peiace[zero_position-1];
new_peiace[zero_position-1] = swap;
if(std::find(previous_frontier.begin(), previous_frontier.end(), new_peiace) == previous_frontier.end())
next_frontier.insert(new_peiace);
}
}
previous_frontier = frontier;
frontier = next_frontier;
step++;
}
}
int main()
{
char cline[16];
std::cin.getline(cline, sizeof(cline));
while(0<=cline[0]-'0' && cline[0]-'0'<8)
{
std::vector<int> pieace(8);
int cp = 0;
for(int i=0;i<16;i++)
if(isdigit(cline[i]))
pieace[cp++]=cline[i]-'0';
std::cout << solve(pieace) << std::endl;
std::cin.getline(cline, sizeof(cline));
}
} | a.cc:6:10: fatal error: <algorithm: No such file or directory
6 | #include <<algorithm>
| ^~~~~~~~~~~~
compilation terminated.
|
s660343989 | p00121 | C++ | #include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
using Point = pair<int, int>;
const int MAX_N = 8;
const int MAX_ID = 40320;
const int GOAL_ID = 0;
const int INF = 0x3f3f3f3f;
const int RULE_NUM = 3;
const int RULE[MAX_N][RULE_NUM] = {{1, 4, -1}, {0, 2, 5}, {1, 3, 6}, {2, 7, -1},
{0, 5, -1}, {1, 4, 6}, {2, 5, 7}, {3, 6, -1}};
const int FACTORS[MAX_N] = {1, 1, 2, 6, 24, 120, 720, 5040};
int ConvertVectorToId(const vector<int>& numbers) {
bool is_used[MAX_N];
memset(is_used, false, sizeof(is_used));
int id = 0;
for (size_t i = 0; i < MAX_N; i++) {
int rank = 0;
for (size_t j = 0; j < numbers[i]; j++) {
if (!is_used[j]) { rank++; }
}
id += rank * FACTORS[MAX_N - i - 1];
is_used[numbers[i]] = true;
}
return id;
}
vector<int> ConvertIdToVector(int id) {
bool is_used[MAX_N];
memset(is_used, false, sizeof(is_used));
vector<int> numbers;
for (int i = MAX_N - 1; i >= 0; i--) {
int rank = id / FACTORS[i];
id %= FACTORS[i];
int count = 0;
int num = 0;
while (count < rank) {
if (!is_used[num++]) { count++; }
}
while (is_used[num]) { num++; }
numbers.push_back(num);
is_used[num] = true;
}
return numbers;
}
int BFS(vector<int>& numbers, int zero_pos) {
int id = ConvertVectorToId(numbers);
int dists[MAX_ID];
int paths[MAX_ID];
for (int i = 0; i < MAX_ID; i++) {
dists[i] = INF;
paths[i] = -1;
}
queue<int> que;
que.push(id);
dists[id] = 0;
paths[id] = -2;
while (que.size()) {
id = que.front();
numbers = ConvertIdToVector(id);
que.pop();
if (id == GOAL_ID) { break; }
zero_pos = distance(numbers.begin(), find(numbers.begin(), numbers.end(), 0));
for (size_t i = 0; i < RULE_NUM; i++) {
int new_zero_pos = RULE[zero_pos][i];
if (new_zero_pos < 0) { continue; }
vector<int> new_numbers = numbers;
swap(new_numbers[zero_pos], new_numbers[new_zero_pos]);
int new_id = ConvertVectorToId(new_numbers);
if (dists[new_id] == INF) {
que.push(new_id);
dists[new_id] = dists[id] + 1;
paths[new_id] = id;
}
}
}
return dists[GOAL_ID];
}
int main() {
string line;
while (getline(cin, line)) {
stringstream ss;
ss << line;
vector<int> numbers(MAX_N);
int zero_pos = 0;
for (size_t i = 0; i < MAX_N; i++) {
ss >> numbers[i];
if (numbers[i] == 0) {
zero_pos = i;
}
}
cout << BFS(numbers, zero_pos) << endl;
}
return 0;
} | a.cc: In function 'int ConvertVectorToId(const std::vector<int>&)':
a.cc:24:5: error: 'memset' was not declared in this scope
24 | memset(is_used, false, sizeof(is_used));
| ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
7 | #include <utility>
+++ |+#include <cstring>
8 |
a.cc: In function 'std::vector<int> ConvertIdToVector(int)':
a.cc:41:5: error: 'memset' was not declared in this scope
41 | memset(is_used, false, sizeof(is_used));
| ^~~~~~
a.cc:41:5: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s092798299 | p00121 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <set>
#include <utility>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
typedef pair<string,int> P;
string str;
map<string,int> table;
int dir[]= {-1,1,-4,4}; //移?方向
void bfs()
{
queue<P> q;
string s,s_next;
P temp;
int cur,next;
q.push(P("01234567",0));
table["01234567"]=0;
while(!q.empty())
{
temp=q.front();
q.pop();
s=temp.first;
cur=temp.second;
for(int i=0; i<4; i++)//将0向四个方向移?
{
next=cur+dir[i];
str=s;
swap(str[cur],str[next]);
if(next>=0&&next<8&&!(cur==3&&next==4)&&!(cur==4&&next==3)&&table.find(str)==table.end())
{ //判断移?是否合法及?状?是否已存在
table[str]=table[s]+1;
q.push(P(str,next));
}
}
}
}
int main()
{
//freopen("input.txt","r",stdin);
char sstr[50];
bfs();
while(gets(sstr))
{
for(int i=1; i<8; i++)
sstr[i]=sstr[i*2];
sstr[8]='\0';
str=sstr;
printf("%d\n",table[str]);
}
} | a.cc: In function 'int main()':
a.cc:54:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
54 | while(gets(sstr))
| ^~~~
| getw
|
s999442251 | p00121 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <set>
#include <utility>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
typedef pair<string,int> P;
string str;
map<string,int> table;
int dir[]= {-1,1,-4,4}; //移?方向
void bfs()
{
queue<P> q;
string s,s_next;
P temp;
int cur,next;
q.push(P("01234567",0));
table["01234567"]=0;
while(!q.empty())
{
temp=q.front();
q.pop();
s=temp.first;
cur=temp.second;
for(int i=0; i<4; i++)//将0向四个方向移?
{
next=cur+dir[i];
str=s;
swap(str[cur],str[next]);
if(next>=0&&next<8&&!(cur==3&&next==4)&&!(cur==4&&next==3)&&table.find(str)==table.end())
{ //判断移?是否合法及?状?是否已存在
table[str]=table[s]+1;
q.push(P(str,next));
}
}
}
}
int main()
{
//freopen("input.txt","r",stdin);
char sstr[50];
bfs();
while(gets(sstr))
{
for(int i=1; i<8; i++)
sstr[i]=sstr[i*2];
sstr[8]='\0';
str=sstr;
printf("%d\n",table[str]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:54:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
54 | while(gets(sstr))
| ^~~~
| getw
|
s904212631 | p00121 | C++ | #include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
using namespace std;
struct Node {
int start;
string buf;
Node(int index, string s): start(index), buf(s) {}
};
int dir[4] = {-1, 1, -4, 4};
unordered_map<string, int> dp;
void solve() {
dp["01234567"] = 0;
int step = 0;
queue<Node> q;
q.push(Node(0, "01234567"));
while (!q.empty()) {
int size = q.size();
step++;
while (size-- > 0) {
Node cur = q.front();
q.pop();
for (int i = 0; i < 4; ++i) {
int next_p = cur.start + dir[i];
if (next_p >= 0 && next_p < 8
&& !(cur.start == 4 && i == 0)
&& !(cur.start == 3 && i == 1)) {
string next = cur.buf;
swap(next[cur.start], next[next_p]);
if (dp.count(next) == 0) {
dp[next] = step;
q.push(Node(next_p, next));
}
}
}
}
}
}
int main() {
solve();
string input;
char c;
while (cin >> c) {
input.clear();
input.append(1, c);
for (int i = 0; i < 7; ++i) {
cin >> c;
input.append(c);
}
cout << dp[input] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:55:21: error: no matching function for call to 'std::__cxx11::basic_string<char>::append(char&)'
55 | input.append(c);
| ~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:1480:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' (near match)
1480 | append(const _CharT* __s)
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1480:7: note: conversion of argument 1 would be ill-formed:
a.cc:55:22: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
55 | input.append(c);
| ^
| |
| char
/usr/include/c++/14/bits/basic_string.h:1529:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
1529 | append(_InputIterator __first, _InputIterator __last)
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1529:9: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1541:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
1541 | append(const _Tp& __svt)
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1541:9: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/move.h:37,
from /usr/include/c++/14/bits/exception_ptr.h:41,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/14/bits/basic_string.h:149:8: required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = char; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
149 | using _If_sv = enable_if_t<
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1541:9: required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::append(const _Tp&) [with _Tp = char]'
1541 | append(const _Tp& __svt)
| ^~~~~~
a.cc:55:21: required from here
55 | input.append(c);
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
2711 | using enable_if_t = typename enable_if<_Cond, _Tp>::type;
| ^~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1557:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
1557 | append(const _Tp& __svt, size_type __pos, size_type __n = npos)
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1557:9: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1435:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
1435 | append(const basic_string& __str)
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1435:34: note: no known conversion for argument 1 from 'char' to 'const std::__cxx11::basic_string<char>&'
1435 | append(const basic_string& __str)
| ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:1453:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
1453 | append(const basic_string& __str, size_type __pos, size_type __n = npos)
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1453:7: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1466:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
1466 | append(const _CharT* __s, size_type __n)
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1466:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1498:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
1498 | append(size_type __n, _CharT __c)
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1498:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:1509:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::append(std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
1509 | append(initializer_list<_CharT> __l)
| ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1509:39: note: no known conversion for argument 1 from 'char' to 'std::initializer_list<char>'
1509 | append(initializer_list<_CharT> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
|
s362156117 | p00121 | C++ | #include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
string data;
char goal[9] = "01234567";
queue<string> qu;
map<string,int> mp;
int d[4] = {-4,-1,1,4};
int pos;
int ans[1000];
char tmp;
int solve(){
mp[data] = 0;
qu.push(data);
string pre_data;
while(qu.size()){
data = qu.front();
pre_data = data;
qu.pop();
if(data == goal)
return mp[data];
pos = data.find('0');
for(int i = 0; i < 4; i++){
if(pos + d[i] >= 0 && pos + d[i] < 8){
swap(data[pos],data[pos+d[i]]);
if(mp.find(data) == mp.end()){
mp[data] = mp[pre_data] + 1;
qu.push(data);
}
}
}
}
return mp[goal];
}
int main(){
int n = 0;
size_t c;
while(getline(cin, data)){
while((c = data.find_first_of(" ")) != string::npos){
data.erase(c,1);
}
ans[n++] = solve();
mp.clear();
}
for(int i = 0; i < n; i++)
printf("%d\n", ans[i]);
} | a.cc: In function 'int solve()':
a.cc:20:6: error: reference to 'data' is ambiguous
20 | mp[data] = 0;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:8: note: 'std::string data'
9 | string data;
| ^~~~
a.cc:21:11: error: reference to 'data' is ambiguous
21 | qu.push(data);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:8: note: 'std::string data'
9 | string data;
| ^~~~
a.cc:24:5: error: reference to 'data' is ambiguous
24 | data = qu.front();
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:8: note: 'std::string data'
9 | string data;
| ^~~~
a.cc:25:16: error: reference to 'data' is ambiguous
25 | pre_data = data;
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:8: note: 'std::string data'
9 | string data;
| ^~~~
a.cc:27:8: error: reference to 'data' is ambiguous
27 | if(data == goal)
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:8: note: 'std::string data'
9 | string data;
| ^~~~
a.cc:28:17: error: reference to 'data' is ambiguous
28 | return mp[data];
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:8: note: 'std::string data'
9 | string data;
| ^~~~
a.cc:29:11: error: reference to 'data' is ambiguous
29 | pos = data.find('0');
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:8: note: 'std::string data'
9 | string data;
| ^~~~
a.cc:32:14: error: reference to 'data' is ambiguous
32 | swap(data[pos],data[pos+d[i]]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:9:8: note: 'std::string data'
9 | string data;
| ^~~~
a.cc:32:24: error: reference to 'data' is ambiguous
32 | swap(data[pos],data[pos+d[i]]);
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexc |
s772701644 | p00121 | C++ | //AOJ0121
#include <iostream>
#include <queue>
using namespace std;
const int INF = 100000000;
class Point{
public:
int x;
int y;
};
int main(){
char paz[3][5]; //???????????????
int xz, xy; //0?????\??£???????????´???
for(int y=0; y<=3; y++){
for(int x=0; x<5=; x++){
paz[y][x] = '#';
}
}
for(int y=1; y<2; y++){
for(int x=1; x<4; x++){
cin >> paz[y][x]; //???????????????????????????
if(paz[y][x] == 0){ //????????????????????????????????°???0??????
xz == x; //0?????´???????¨????
yz == y;
}
}
}
int count[2][4]; //?????°
for(int y=0; y<2; y++){ //?????°?????§?????????
for(int x=0; x<4; x++){
count[y][x] = INF;
}
}
queue<Point> que;
Point p;
p.x = xz; p.y = xy;
que.push(p); //0?????????????????\???????????\
count[p.y][p.x] = 0; //?????°???0
while!(que.empty()){ //?????\???????????§???????????°?????????
p = que.front(); que.pop(); //?????\?????????????????????
if(paz[0][0]<paz[0][1] && paz[0][1]<paz[0][2] && paz[0][2]<paz[0][3] && paz[0][3]<[1][0] && paz[1][0]<paz[1][1] && paz[1][1]<paz[1][2] && paz[1][2]<paz[1][3]){
cout << count[p.y][p.x] << endl;
break; //??????????????£???????????????????????????????°??????°?????????????????????
}
if(paz[p.y-1][p.x]!='#' && count[p.y-1][p.x]==INF){ //???
Point p;
q.x = p.x; q.y = p.y-1;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
if(paz[p.y+1][p.x]!='#' && count[p.y+1][p.x]==INF){ //???
Point p;
q.x = p.x; q.y = p.y+1;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
if(paz[p.y][p.x-1]!='#' && count[p.y][p.x-1]==INF){ //???
Point p;
q.x = p.x-1; q.y = p.y;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
if(paz[p.y][p.x+1]!='#' && count[p.y][p.x+1]==INF){ //???
Point p;
q.x = p.x+1; q.y = p.y;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
return 0;
}
} | a.cc: In function 'int main()':
a.cc:20:22: error: expected primary-expression before ';' token
20 | for(int x=0; x<5=; x++){
| ^
a.cc:30:9: error: 'yz' was not declared in this scope; did you mean 'y'?
30 | yz == y;
| ^~
| y
a.cc:49:6: error: expected '(' before '!' token
49 | while!(que.empty()){ //?????\???????????§???????????°?????????
| ^
| (
a.cc:49:20: error: expected ')' before '{' token
49 | while!(que.empty()){ //?????\???????????§???????????°?????????
| ~ ^
| )
a.cc:52:86: error: expected identifier before numeric constant
52 | if(paz[0][0]<paz[0][1] && paz[0][1]<paz[0][2] && paz[0][2]<paz[0][3] && paz[0][3]<[1][0] && paz[1][0]<paz[1][1] && paz[1][1]<paz[1][2] && paz[1][2]<paz[1][3]){
| ^
a.cc: In lambda function:
a.cc:52:88: error: expected '{' before '[' token
52 | if(paz[0][0]<paz[0][1] && paz[0][1]<paz[0][2] && paz[0][2]<paz[0][3] && paz[0][3]<[1][0] && paz[1][0]<paz[1][1] && paz[1][1]<paz[1][2] && paz[1][2]<paz[1][3]){
| ^
a.cc: In function 'int main()':
a.cc:52:88: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
a.cc:59:5: error: 'q' was not declared in this scope
59 | q.x = p.x; q.y = p.y-1;
| ^
a.cc:65:5: error: 'q' was not declared in this scope
65 | q.x = p.x; q.y = p.y+1;
| ^
a.cc:71:5: error: 'q' was not declared in this scope
71 | q.x = p.x-1; q.y = p.y;
| ^
a.cc:77:5: error: 'q' was not declared in this scope
77 | q.x = p.x+1; q.y = p.y;
| ^
|
s692937848 | p00121 | C++ | //AOJ0121
#include <iostream>
#include <queue>
using namespace std;
const int INF = 100000000;
class Point{
public:
int x;
int y;
};
int main(){
char paz[3][5]; //???????????????
int xz, yz; //0?????\??£???????????´???
for(int y=0; y<=3; y++){
for(int x=0; x<5=; x++){
paz[y][x] = '#';
}
}
for(int y=1; y<2; y++){
for(int x=1; x<4; x++){
cin >> paz[y][x]; //???????????????????????????
if(paz[y][x] == 0){ //????????????????????????????????°???0??????
xz == x; //0?????´???????¨????
yz == y;
}
}
}
int count[2][4]; //?????°
for(int y=0; y<2; y++){ //?????°?????§?????????
for(int x=0; x<4; x++){
count[y][x] = INF;
}
}
queue<Point> que;
Point p;
p.x = xz; p.y = xy;
que.push(p); //0?????????????????\???????????\
count[p.y][p.x] = 0; //?????°???0
while(!que.empty()){ //?????\???????????§???????????°?????????
p = que.front(); que.pop(); //?????\?????????????????????
if(paz[0][0]<paz[0][1] && paz[0][1]<paz[0][2] && paz[0][2]<paz[0][3] && paz[0][3]<[1][0] && paz[1][0]<paz[1][1] && paz[1][1]<paz[1][2] && paz[1][2]<paz[1][3]){
cout << count[p.y][p.x] << endl;
break; //??????????????£???????????????????????????????°??????°?????????????????????
}
if(paz[p.y-1][p.x]!='#' && count[p.y-1][p.x]==INF){ //???
Point p;
q.x = p.x; q.y = p.y-1;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
if(paz[p.y+1][p.x]!='#' && count[p.y+1][p.x]==INF){ //???
Point p;
q.x = p.x; q.y = p.y+1;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
if(paz[p.y][p.x-1]!='#' && count[p.y][p.x-1]==INF){ //???
Point p;
q.x = p.x-1; q.y = p.y;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
if(paz[p.y][p.x+1]!='#' && count[p.y][p.x+1]==INF){ //???
Point p;
q.x = p.x+1; q.y = p.y;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
return 0;
}
} | a.cc: In function 'int main()':
a.cc:20:22: error: expected primary-expression before ';' token
20 | for(int x=0; x<5=; x++){
| ^
a.cc:45:17: error: 'xy' was not declared in this scope; did you mean 'xz'?
45 | p.x = xz; p.y = xy;
| ^~
| xz
a.cc:52:86: error: expected identifier before numeric constant
52 | if(paz[0][0]<paz[0][1] && paz[0][1]<paz[0][2] && paz[0][2]<paz[0][3] && paz[0][3]<[1][0] && paz[1][0]<paz[1][1] && paz[1][1]<paz[1][2] && paz[1][2]<paz[1][3]){
| ^
a.cc: In lambda function:
a.cc:52:88: error: expected '{' before '[' token
52 | if(paz[0][0]<paz[0][1] && paz[0][1]<paz[0][2] && paz[0][2]<paz[0][3] && paz[0][3]<[1][0] && paz[1][0]<paz[1][1] && paz[1][1]<paz[1][2] && paz[1][2]<paz[1][3]){
| ^
a.cc: In function 'int main()':
a.cc:52:88: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
a.cc:59:5: error: 'q' was not declared in this scope
59 | q.x = p.x; q.y = p.y-1;
| ^
a.cc:65:5: error: 'q' was not declared in this scope
65 | q.x = p.x; q.y = p.y+1;
| ^
a.cc:71:5: error: 'q' was not declared in this scope
71 | q.x = p.x-1; q.y = p.y;
| ^
a.cc:77:5: error: 'q' was not declared in this scope
77 | q.x = p.x+1; q.y = p.y;
| ^
|
s878593235 | p00121 | C++ | //AOJ0121
#include <iostream>
#include <queue>
using namespace std;
const int INF = 100000000;
class Point{
public:
int x;
int y;
};
int main(){
char paz[3][5]; //???????????????
int xz, yz; //0?????\??£???????????´???
for(int y=0; y<=3; y++){
for(int x=0; x<5=; x++){
paz[y][x] = '#';
}
}
for(int y=1; y<2; y++){
for(int x=1; x<4; x++){
cin >> paz[y][x]; //???????????????????????????
if(paz[y][x] == 0){ //????????????????????????????????°???0??????
xz == x; //0?????´???????¨????
yz == y;
}
}
}
int count[2][4]; //?????°
for(int y=0; y<2; y++){ //?????°?????§?????????
for(int x=0; x<4; x++){
count[y][x] = INF;
}
}
queue<Point> que;
Point p;
p.x = xz; p.y = xy;
que.push(p); //0?????????????????\???????????\
count[p.y][p.x] = 0; //?????°???0
while(!que.empty()){ //?????\???????????§???????????°?????????
p = que.front(); que.pop(); //?????\?????????????????????
if(paz[0][0]<paz[0][1] && paz[0][1]<paz[0][2] && paz[0][2]<paz[0][3] && paz[0][3]<[1][0] && paz[1][0]<paz[1][1] && paz[1][1]<paz[1][2] && paz[1][2]<paz[1][3]){
cout << count[p.y][p.x] << endl;
break; //??????????????£???????????????????????????????°??????°?????????????????????
}
if(paz[p.y-1][p.x]!='#' && count[p.y-1][p.x]==INF){ //???
Point p;
q.x = p.x; q.y = p.y-1;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
if(paz[p.y+1][p.x]!='#' && count[p.y+1][p.x]==INF){ //???
Point p;
q.x = p.x; q.y = p.y+1;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
if(paz[p.y][p.x-1]!='#' && count[p.y][p.x-1]==INF){ //???
Point p;
q.x = p.x-1; q.y = p.y;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
if(paz[p.y][p.x+1]!='#' && count[p.y][p.x+1]==INF){ //???
Point p;
q.x = p.x+1; q.y = p.y;
que.push(q);
count[q.y][q.x] = count[q.y][q.x]+1;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:20:22: error: expected primary-expression before ';' token
20 | for(int x=0; x<5=; x++){
| ^
a.cc:45:17: error: 'xy' was not declared in this scope; did you mean 'xz'?
45 | p.x = xz; p.y = xy;
| ^~
| xz
a.cc:52:86: error: expected identifier before numeric constant
52 | if(paz[0][0]<paz[0][1] && paz[0][1]<paz[0][2] && paz[0][2]<paz[0][3] && paz[0][3]<[1][0] && paz[1][0]<paz[1][1] && paz[1][1]<paz[1][2] && paz[1][2]<paz[1][3]){
| ^
a.cc: In lambda function:
a.cc:52:88: error: expected '{' before '[' token
52 | if(paz[0][0]<paz[0][1] && paz[0][1]<paz[0][2] && paz[0][2]<paz[0][3] && paz[0][3]<[1][0] && paz[1][0]<paz[1][1] && paz[1][1]<paz[1][2] && paz[1][2]<paz[1][3]){
| ^
a.cc: In function 'int main()':
a.cc:52:88: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
a.cc:59:5: error: 'q' was not declared in this scope
59 | q.x = p.x; q.y = p.y-1;
| ^
a.cc:65:5: error: 'q' was not declared in this scope
65 | q.x = p.x; q.y = p.y+1;
| ^
a.cc:71:5: error: 'q' was not declared in this scope
71 | q.x = p.x-1; q.y = p.y;
| ^
a.cc:77:5: error: 'q' was not declared in this scope
77 | q.x = p.x+1; q.y = p.y;
| ^
|
s817157574 | p00121 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
class Puzzle{
public:
vector<vector<int> > p;
int lastorder;//1 ??? 3?????? 5 ??????
int ordernum;
Puzzle(){
this->p.resize(2);
for(int i=0;i<2;i++){
this->p[i].resize(4);
}
this->lastorder = 60;
this->ordernum = 0;
}
Puzzle& operator=(const Puzzle& p1){
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
this->p[i][j] = p1.p[i][j];
}
}
this->lastorder = p1.lastorder;
this->ordernum = p1.ordernum;
}
~Puzzle(){
vector<int>().swap(p);
}
};
int main(){
while(!cin.eof()){
queue<Puzzle> q;
Puzzle Start;
for(int i=0;i < 2; i++){
for(int j=0;j < 4; j++){
cin >> Start.p[i][j];
}
}
q.push(Start);
while(1){
Puzzle tmp;
tmp = q.front();
q.pop();
bool ok = true;
for(int i=0;i < 2; i++){
for(int j=0;j < 4; j++){
if(tmp.p[i][j] != (i*4 + j)){
ok = false;
break;
}
}
}
if(ok){
cout << tmp.ordernum << endl;
break;
}
int x,y;
for(int i=0;i < 2; i++){
for(int j=0;j < 4; j++){
if(tmp.p[i][j] == 0){
x = j;
y = i;
}
}
}
tmp.ordernum++;
Puzzle Beforetmp = tmp;
//int beforeorder = tmp.lastorder;
if(x != 3 && Beforetmp.lastorder != 3){
swap(tmp.p[y][x],tmp.p[y][x+1]);
tmp.lastorder = 1;
q.push(tmp);
tmp = Beforetmp;
}
if(x != 0 && Beforetmp.lastorder != 1){
swap(tmp.p[y][x],tmp.p[y][x-1]);
tmp.lastorder = 3;
q.push(tmp);
tmp = Beforetmp;
}
if(Beforetmp.lastorder != 5){
swap(tmp.p[0][x],tmp.p[1][x]);
tmp.lastorder = 5;
q.push(tmp);
}
}
}
return 0;
} | a.cc: In member function 'Puzzle& Puzzle::operator=(const Puzzle&)':
a.cc:34:3: warning: no return statement in function returning non-void [-Wreturn-type]
33 | this->ordernum = p1.ordernum;
+++ |+ return *this;
34 | }
| ^
a.cc: In destructor 'Puzzle::~Puzzle()':
a.cc:39:24: error: cannot convert 'std::vector<std::vector<int> >' to 'std::vector<int>&'
39 | vector<int>().swap(p);
| ^
| |
| std::vector<std::vector<int> >
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/queue:63,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1588:20: note: initializing argument 1 of 'void std::vector<_Tp, _Alloc>::swap(std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
1588 | swap(vector& __x) _GLIBCXX_NOEXCEPT
| ~~~~~~~~^~~
|
s562799981 | p00121 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
class Puzzle{
public:
vector<vector<int> > p;
int lastorder;//1 ??? 3?????? 5 ??????
int ordernum;
Puzzle(){
this->p.resize(2);
for(int i=0;i<2;i++){
this->p[i].resize(4);
}
this->lastorder = 60;
this->ordernum = 0;
}
Puzzle& operator=(const Puzzle& p1){
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
this->p[i][j] = p1.p[i][j];
}
}
this->lastorder = p1.lastorder;
this->ordernum = p1.ordernum;
}
~Puzzle(){
vector<vector<int> >().swap(p);
}
};
int main(){
while(!cin.eof()){
queue<Puzzle> q;
Puzzle Start;
for(int i=0;i < 2; i++){
for(int j=0;j < 4; j++){
cin >> Start.p[i][j];
}
}
q.push(Start);
while(1){
Puzzle tmp;
tmp = q.front();
q.pop();
bool ok = true;
for(int i=0;i < 2; i++){
for(int j=0;j < 4; j++){
if(tmp.p[i][j] != (i*4 + j)){
ok = false;
break;
}
}
}
if(ok){
cout << tmp.ordernum << endl;
break;
}
int x,y;
for(int i=0;i < 2; i++){
for(int j=0;j < 4; j++){
if(tmp.p[i][j] == 0){
x = j;
y = i;
}
}
}
tmp.ordernum++;
Puzzle Beforetmp = tmp;
//int beforeorder = tmp.lastorder;
if(x != 3 && Beforetmp.lastorder != 3){
swap(tmp.p[y][x],tmp.p[y][x+1]);
tmp.lastorder = 1;
q.push(tmp);
tmp = Beforetmp;
}
if(x != 0 && Beforetmp.lastorder != 1){
swap(tmp.p[y][x],tmp.p[y][x-1]);
tmp.lastorder = 3;
q.push(tmp);
tmp = Beforetmp;
}
if(Beforetmp.lastorder != 5){
swap(tmp.p[0][x],tmp.p[1][x]);
tmp.lastorder = 5;
q.push(tmp);
}
queue<Puzzle> empty;
}
swap(q, empty);
}
return 0;
} | a.cc: In member function 'Puzzle& Puzzle::operator=(const Puzzle&)':
a.cc:34:3: warning: no return statement in function returning non-void [-Wreturn-type]
33 | this->ordernum = p1.ordernum;
+++ |+ return *this;
34 | }
| ^
a.cc: In function 'int main()':
a.cc:124:9: error: no matching function for call to 'swap(std::queue<Puzzle>&, <unresolved overloaded function type>)'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = queue<Puzzle>; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]'
226 | swap(_Tp& __a, _Tp& __b)
| ^~~~
/usr/include/c++/14/bits/move.h:226:25: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'std::queue<Puzzle>&'
226 | swap(_Tp& __a, _Tp& __b)
| ~~~~~^~~
In file included from /usr/include/c++/14/queue:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_queue.h:445:5: note: candidate: 'typename std::enable_if<std::__is_swappable<_T2>::value>::type std::swap(queue<_Tp, _Seq>&, queue<_Tp, _Seq>&) [with _Tp = Puzzle; _Seq = deque<Puzzle, allocator<Puzzle> >; typename enable_if<__is_swappable<_T2>::value>::type = void]'
445 | swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:445:51: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'std::queue<Puzzle>&'
445 | swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)'
229 | swap(exception_ptr& __lhs, exception_ptr& __rhs)
| ^~~~
/usr/include/c++/14/bits/exception_ptr.h:229:25: note: no known conversion for argument 1 from 'std::queue<Puzzle>' to 'std::__exception_ptr::exception_ptr&'
229 | swap(exception_ptr& __lhs, exception_ptr& __rhs)
| ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])'
250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
| ^~~~
/usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed:
a.cc:124:9: note: mismatched types '_Tp [_Nm]' and 'std::queue<Puzzle>'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)'
1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed:
a.cc:124:9: note: 'std::queue<Puzzle>' is not derived from 'std::pair<_T1, _T2>'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted)
1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
| ^~~~
/usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitution failed:
a.cc:124:9: note: 'std::queue<Puzzle>' is not derived from 'std::pair<_T1, _T2>'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4039 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4039:5: note: template argument deduction/substitution failed:
a.cc:124:9: note: 'std::queue<Puzzle>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)'
2805 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
| ^~~~
/usr/include/c++/14/tuple:2805:5: note: template argument deduction/substitution failed:
a.cc:124:9: note: 'std::queue<Puzzle>' is not derived from 'std::tuple<_UTypes ...>'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
/usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted)
2823 | swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
| ^~~~
/usr/include/c++/14/tuple:2823:5: note: template argument deduction/substitution failed:
a.cc:124:9: note: 'std::queue<Puzzle>' is not derived from 'std::tuple<_UTypes ...>'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/deque:66,
from /usr/include/c++/14/queue:62:
/usr/include/c++/14/bits/stl_deque.h:2370:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(deque<_Tp, _Alloc>&, deque<_Tp, _Alloc>&)'
2370 | swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
| ^~~~
/usr/include/c++/14/bits/stl_deque.h:2370:5: note: template argument deduction/substitution failed:
a.cc:124:9: note: 'std::queue<Puzzle>' is not derived from 'std::deque<_Tp, _Alloc>'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/queue:63:
/usr/include/c++/14/bits/stl_vector.h:2122:5: note: candidate: 'template<class _Tp, class _Alloc> void std::swap(vector<_Tp, _Alloc>&, vector<_Tp, _Alloc>&)'
2122 | swap(vector<_Tp, _Alloc>& __x, vector<_Tp, _Alloc>& __y)
| ^~~~
/usr/include/c++/14/bits/stl_vector.h:2122:5: note: template argument deduction/substitution failed:
a.cc:124:9: note: 'std::queue<Puzzle>' is not derived from 'std::vector<_Tp, _Alloc>'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:834:5: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> typename std::enable_if<std::__and_<std::__is_swappable<_T2>, std::__is_swappable<_Compare> >::value>::type std::swap(priority_queue<_Tp, _Sequence, _Compare>&, priority_queue<_Tp, _Sequence, _Compare>&)'
834 | swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:834:5: note: template argument deduction/substitution failed:
a.cc:124:9: note: 'std::queue<Puzzle>' is not derived from 'std::priority_queue<_Tp, _Sequence, _Compare>'
124 | swap(q, empty);
| ~~~~^~~~~~~~~~
|
s495561307 | p00121 | C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// 2013/11/06 Tazoe
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
struct state{
int p[8];
int t;
};
int main()
{
while(true){
struct state s;
cin >> s.p[0];
if(cin.eof()) // ?????????????????????????????°
break;
for(int i=1; i<8; i++){
cin >> s.p[i];
}
s.t = 0;
if(s.p[0]==0 && s.p[1]==1 && s.p[2]==2 && s.p[3]==3 && s.p[4]==4 && s.p[5]==5 && s.p[6]==6 && s.p[7]==7){
cout << s.t << endl;
continue;
}
bool memo[8][8][8][8][8][8][8]; // ?????¢???????´??????????7?¬????
for(int i0=0; i0<8; i0++){
for(int i1=0; i1<8; i1++){
for(int i2=0; i2<8; i2++){
for(int i3=0; i3<8; i3++){
for(int i4=0; i4<8; i4++){
for(int i5=0; i5<8; i5++){
for(int i6=0; i6<8; i6++){
memo[i0][i1][i2][i3][i4][i5][i6] = false;
}
}
}
}
}
}
}
memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]] = true;
queue<struct state> q;
q.push(s);
while(true){
if(q.empty())
break;
s = q.front();
q.pop();
s.t++;
int I = 0;
while(s.p[I]!=0){ // 0??????????????¢???
I++;
}
if(0<=I && I<=3){ // ???????????°
swap(s.p[I], s.p[I+4]);
if(s.p[0]==0 && s.p[1]==1 && s.p[2]==2 && s.p[3]==3 && s.p[4]==4 && s.p[5]==5 && s.p[6]==6 && s.p[7]==7){
cout << s.t << endl;
break;
}
if(!memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]]){
memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]] = true;
q.push(s);
}
swap(s.p[I], s.p[I+4]);
}
if(4<=I && I<=7){ // ???????????°
swap(s.p[I], s.p[I-4]);
if(s.p[0]==0 && s.p[1]==1 && s.p[2]==2 && s.p[3]==3 && s.p[4]==4 && s.p[5]==5 && s.p[6]==6 && s.p[7]==7){
cout << s.t << endl;
break;
}
if(!memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]]){
memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]] = true;
q.push(s);
}
swap(s.p[I], s.p[I-4]);
}
if(I!=0 && I!=4){ // ????????§???????????°
swap(s.p[I], s.p[I-1]);
if(s.p[0]==0 && s.p[1]==1 && s.p[2]==2 && s.p[3]==3 && s.p[4]==4 && s.p[5]==5 && s.p[6]==6 && s.p[7]==7){
cout << s.t << endl;
break;
}
if(!memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]]){
memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]] = true;
q.push(s);
}
swap(s.p[I], s.p[I-1]);
}
if(I!=3 && I!=7){ // ????????§???????????°
swap(s.p[I], s.p[I+1]);
if(s.p[0]==0 && s.p[1]==1 && s.p[2]==2 && s.p[3]==3 && s.p[4]==4 && s.p[5]==5 && s.p[6]==6 && s.p[7]==7){
cout << s.t << endl;
break;
}
if(!memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]]){
memo[s.p[0]][s.p[1]][s.p[2]][s.p[3]][s.p[4]][s.p[5]][s.p[6]] = true;
q.push(s);
}
swap(s.p[I], s.p[I+1]);
}
}
}
return 0;
} | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 1
| ^
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:128:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
171 | void operator delete(void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared
173 | void operator delete[](void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function
179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
179 | _GLIBCXX_NOD |
s969118588 | p00121 | C++ | #include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
class SP{
public:
int p[2][4];
int n;
bool finish(){
p[0][0]==0 && p[0][1]==1 && p[0][2]==2 && p[0][3]==3&&
p[1][0]==4 && p[1][1]==5 && p[1][2]==6 && p[1][3]==7;
}
void move_right(int x,int y){
if(x!=3)
swap(p[y][x],p[y][x+1])
}
void move_left(int x,int y){
if(x!=0)
swap(p[y][x],p[y][x-1])
}
void move_up(int x,int y){
if(y!=0)
swap(p[y][x],p[y+1][x])
}
void move_down(int x,int y){
if(y!=1)
swap(p[y][x],p[y-1][x])
}
}
int main()
{
SP sp;
sp.n=0;
int zx,zy;
for(y=0;y<2;y++){
for(x=0;x<4;x++){
cin>>sp.p[y][x];
if(sp.p[y][x]==0){
zx=x;
zy=y;
}
}
}
queue<SP> que;
que.push(sp);
while(!que.empty()){
sp=que.front();
que.pop();
if(sp.finish()){
cout<<sp.n<<endl;
break;
}
SP sp1=sp; sp1.move_right(zx,zy); sp1.n++; que.push(sp1);
SP sp2=sp; sp2.move_left(zx,zy); sp2.n++; que.push(sp2);
SP sp3=sp; sp3.move_up(zx,zy); sp3.n++; que.push(sp3);
SP sp4=sp; sp4.move_down(zx,zy); sp4.n++; que.push(sp4);
return 0;
} | a.cc:35:2: error: expected ';' after class definition
35 | }
| ^
| ;
a.cc: In member function 'bool SP::finish()':
a.cc:14:9: warning: no return statement in function returning non-void [-Wreturn-type]
14 | }
| ^
a.cc: In member function 'void SP::move_right(int, int)':
a.cc:19:9: error: expected ';' before '}' token
19 | }
| ^
a.cc: In member function 'void SP::move_left(int, int)':
a.cc:24:9: error: expected ';' before '}' token
24 | }
| ^
a.cc: In member function 'void SP::move_up(int, int)':
a.cc:29:9: error: expected ';' before '}' token
29 | }
| ^
a.cc: In member function 'void SP::move_down(int, int)':
a.cc:34:9: error: expected ';' before '}' token
34 | }
| ^
a.cc: In function 'int main()':
a.cc:44:13: error: 'y' was not declared in this scope; did you mean 'zy'?
44 | for(y=0;y<2;y++){
| ^
| zy
a.cc:45:21: error: 'x' was not declared in this scope; did you mean 'zx'?
45 | for(x=0;x<4;x++){
| ^
| zx
a.cc:72:2: error: expected '}' at end of input
72 | }
| ^
a.cc:38:1: note: to match this '{'
38 | {
| ^
|
s837772091 | p00121 | C++ | #include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
class SP{
public:
int p[2][4];
int n;
bool finish(){
p[0][0]==0 && p[0][1]==1 && p[0][2]==2 && p[0][3]==3&&
p[1][0]==4 && p[1][1]==5 && p[1][2]==6 && p[1][3]==7;
}
void move_right(int x,int y){
if(x!=3)
swap(p[y][x],p[y][x+1])
}
void move_left(int x,int y){
if(x!=0)
swap(p[y][x],p[y][x-1])
}
void move_up(int x,int y){
if(y!=0)
swap(p[y][x],p[y+1][x])
}
void move_down(int x,int y){
if(y!=1)
swap(p[y][x],p[y-1][x])
}
};
int main()
{
SP sp;
sp.n=0;
int zx,zy;
for(y=0;y<2;y++){
for(x=0;x<4;x++){
cin>>sp.p[y][x];
if(sp.p[y][x]==0){
zx=x;
zy=y;
}
}
}
queue<SP> que;
que.push(sp);
while(!que.empty()){
sp=que.front();
que.pop();
if(sp.finish()){
cout<<sp.n<<endl;
break;
}
SP sp1=sp; sp1.move_right(zx,zy); sp1.n++; que.push(sp1);
SP sp2=sp; sp2.move_left(zx,zy); sp2.n++; que.push(sp2);
SP sp3=sp; sp3.move_up(zx,zy); sp3.n++; que.push(sp3);
SP sp4=sp; sp4.move_down(zx,zy); sp4.n++; que.push(sp4);
return 0;
} | a.cc: In member function 'bool SP::finish()':
a.cc:14:9: warning: no return statement in function returning non-void [-Wreturn-type]
14 | }
| ^
a.cc: In member function 'void SP::move_right(int, int)':
a.cc:19:9: error: expected ';' before '}' token
19 | }
| ^
a.cc: In member function 'void SP::move_left(int, int)':
a.cc:24:9: error: expected ';' before '}' token
24 | }
| ^
a.cc: In member function 'void SP::move_up(int, int)':
a.cc:29:9: error: expected ';' before '}' token
29 | }
| ^
a.cc: In member function 'void SP::move_down(int, int)':
a.cc:34:9: error: expected ';' before '}' token
34 | }
| ^
a.cc: In function 'int main()':
a.cc:44:13: error: 'y' was not declared in this scope; did you mean 'zy'?
44 | for(y=0;y<2;y++){
| ^
| zy
a.cc:45:21: error: 'x' was not declared in this scope; did you mean 'zx'?
45 | for(x=0;x<4;x++){
| ^
| zx
a.cc:72:2: error: expected '}' at end of input
72 | }
| ^
a.cc:38:1: note: to match this '{'
38 | {
| ^
|
s305872290 | p00121 | C++ | #include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
class SP{
public:
int p[2][4];
int n;
bool finish(){
p[0][0]==0 && p[0][1]==1 && p[0][2]==2 && p[0][3]==3&&
p[1][0]==4 && p[1][1]==5 && p[1][2]==6 && p[1][3]==7;
}
void move_right(int x,int y){
if(x!=3)
swap(p[y][x],p[y][x+1]);
}
void move_left(int x,int y){
if(x!=0)
swap(p[y][x],p[y][x-1]);
}
void move_up(int x,int y){
if(y!=0)
swap(p[y][x],p[y+1][x]);
}
void move_down(int x,int y){
if(y!=1)
swap(p[y][x],p[y-1][x]);
}
};
int main()
{
SP sp;
sp.n=0;
int zx,zy;
for(y=0;y<2;y++){
for(x=0;x<4;x++){
cin>>sp.p[y][x];
if(sp.p[y][x]==0){
zx=x;
zy=y;
}
}
}
queue<SP> que;
que.push(sp);
while(!que.empty()){
sp=que.front();
que.pop();
if(sp.finish()){
cout<<sp.n<<endl;
break;
}
SP sp1=sp; sp1.move_right(zx,zy); sp1.n++; que.push(sp1);
SP sp2=sp; sp2.move_left(zx,zy); sp2.n++; que.push(sp2);
SP sp3=sp; sp3.move_up(zx,zy); sp3.n++; que.push(sp3);
SP sp4=sp; sp4.move_down(zx,zy); sp4.n++; que.push(sp4);
return 0;
} | a.cc: In member function 'bool SP::finish()':
a.cc:14:9: warning: no return statement in function returning non-void [-Wreturn-type]
14 | }
| ^
a.cc: In function 'int main()':
a.cc:44:13: error: 'y' was not declared in this scope; did you mean 'zy'?
44 | for(y=0;y<2;y++){
| ^
| zy
a.cc:45:21: error: 'x' was not declared in this scope; did you mean 'zx'?
45 | for(x=0;x<4;x++){
| ^
| zx
a.cc:72:2: error: expected '}' at end of input
72 | }
| ^
a.cc:38:1: note: to match this '{'
38 | {
| ^
|
s411664384 | p00121 | C++ | #include <iostream>
#include <map>
#include <string>
using namespace std;
void swap(char *a,char *b){
char temp = *a;
*a = *b;
*b = temp;
}
int main(){
int dx[] = {+1,-1,+4,-4};
string start = "01234567";
queue<string> que;
map<string,int> d;
que.push(start);
d[start] = 0;
while(que.size()){
string q = que.front(); que.pop();
int x = q.find("0");
for(int i=0;i<4;i++){
int next = x + dx[i];
if( next>=0 && next<=7 && !(x==3&&next==4) && !(x==4&&next==3) ){
string nextq = q;
swap(&nextq[x],&nextq[next]);
if(d.find(nextq)==d.end()){
que.push(nextq);
d[nextq] = d[q] + 1;
}
}
}
}
while(1){
string input = "";
char temp;
for(int i=0;i<8;i++){
if(cin >> temp){
input.push_back(temp);
}else{
return 0;
}
}
cout << d[input] << endl;
}
} | a.cc: In function 'int main()':
a.cc:18:3: error: 'queue' was not declared in this scope
18 | queue<string> que;
| ^~~~~
a.cc:3:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
2 | #include <map>
+++ |+#include <queue>
3 | #include <string>
a.cc:18:15: error: expected primary-expression before '>' token
18 | queue<string> que;
| ^
a.cc:18:17: error: 'que' was not declared in this scope
18 | queue<string> que;
| ^~~
|
s667008502 | p00121 | C++ | #include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
class SevenPuzzle{
public:
int p[2][4];
int n;
int zero_x,zero_y;
bool finish(){
return p[0][0]==0&&p[0][1]==1&&p[0][2]==2&&p[0][3]==3&&
p[1][0]==4&&p[1][1]==5&&p[1][2]==6&&p[1][3]==7;
}
void move_right(int x,int y){
if(zero_x!=3){
swap(p[y][x],p[y][x+1]);
zero_x=x+1;
}
}
void move_left(int x,int y){
if(zero_x!=0){
swap(p[y][x],p[y][x-1]);
zero_x=x-1;
}
}
void move_up(int x,int y){
if(zero_y!=0){
swap(p[y][x],p[y-1][x]);
zero_y=y-1;
}
}
void move_down(int x,int y){
if(zero_y!=1){
swap(p[y][x],p[y+1][x]);
zero_y=y+1;
}
}
};
int main(){
for(int a=0;a<1000;a++){
SevenPuzzle SP;;
SP.n=0;
for(int i=0;i<2;i++){A
for(int j=0;j<4;j++){
cin>>SP.p[i][j];
if(SP.p[i][j]==0){
SP.zero_x=j; SP.zero_y=i;
}
}
}
queue<SevenPuzzle> que;
que.push(SP);
while(!que.empty()){
SP=que.front(); que.pop();
if(SP.finish()){
cout<<SP.n<<endl;
break;
}
SevenPuzzle next1=SP; next1.move_right(next1.zero_x,next1.zero_y); next1.n++; que.push(next1);//????§????
SevenPuzzle next2=SP; next2.move_left(next2.zero_x,next2.zero_y); next2.n++; que.push(next2);//????§????
SevenPuzzle next3=SP; next3.move_up(next3.zero_x,next3.zero_y); next3.n++; que.push(next3);//????§????
SevenPuzzle next4=SP; next4.move_down(next4.zero_x,next4.zero_y); next4.n++; que.push(next4);//????§????
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:53:38: error: 'A' was not declared in this scope
53 | for(int i=0;i<2;i++){A
| ^
a.cc:54:37: error: 'j' was not declared in this scope
54 | for(int j=0;j<4;j++){
| ^
|
s482715693 | p00121 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
bool checker[8][8][8][8][8][8][8];
class Puzzle{
public:
short** p;
short lastorder;//1 ??? 3?????? 5 ??????
short ordernum;
Puzzle(){
p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}
this->lastorder = 8;
this->ordernum = 0;
}
Puzzle(const Puzzle* puzzle){
p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
p[i][j] = puzzle->p[i][j];
}
}
this->lastorder = puzzle->lastorder;
this->ordernum = puzzle->ordernum;
}
~Puzzle(){
for(int i=0; i<2; i++){
delete[] p[i];
}
delete[] p;
}
inline bool check(){
return(checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]]);
}
};
int main(){
for(int a=0;i<8;i++){
for(int b=0;b<8;b++){
for(int c=0;c<8;c++){
for(int d=0;d<8;d++){
for(int e=0;e<8;e++){
for(int f=0;f<8;f++){
for(int g=0;g<8;g++){
checker[a][b][c][[d]][e][f][g] = false;
}
}
}
}
}
}
}
while(1){
queue<Puzzle*> q;
Puzzle* Start;
Start = new Puzzle;
for(short i=0;i < 2; i++){
for(short j=0;j < 4; j++){
cin >> Start->p[i][j];
}
}
if(cin.eof()){
break;
}
q.push(Start);
while(!q.empty()){
Puzzle* tmp;
tmp = q.front();
q.pop();
bool ok = false;
if(tmp->p[0][0] == 0 && tmp->p[0][1] == 1 && tmp->p[0][2] == 2 && tmp->p[0][3] == 3 && tmp->p[1][0] == 4 && tmp->p[1][1] == 5 && tmp->p[1][2] == 6)
ok = true;
if(ok){
cout << tmp->ordernum << endl;
delete tmp;
while(!q.empty()){
tmp = q.front();
q.pop();
delete tmp;
}
break;
}
short x,y;
for(short i=0;i < 2; i++){
for(short j=0;j < 4; j++){
if(tmp->p[i][j] == 0){
x = j;
y = i;
}
}
}
tmp->ordernum++;
short Beforeorder = tmp->lastorder;
Puzzle* puzzle;
puzzle = new Puzzle(tmp);
if(x != 3 && Beforeorder != 3 && puzzle->check()){
swap(puzzle->p[y][x],puzzle->p[y][x+1]);
puzzle->lastorder = 1;
q.push(puzzle);
puzzle = new Puzzle(tmp);
}
if(x != 0 && Beforeorder != 1 && puzzle->check()){
swap(puzzle->p[y][x],puzzle->p[y][x-1]);
puzzle->lastorder = 3;
q.push(puzzle);
puzzle = new Puzzle(tmp);
}
if(Beforeorder != 5 && puzzle->check()){
swap(puzzle->p[0][x],puzzle->p[1][x]);
puzzle->lastorder = 5;
q.push(puzzle);
}
delete tmp;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:58:15: error: 'i' was not declared in this scope
58 | for(int a=0;i<8;i++){
| ^
a.cc:65:33: error: two consecutive '[' shall only introduce an attribute before '[' token
65 | checker[a][b][c][[d]][e][f][g] = false;
| ^
|
s377304237 | p00121 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
bool checker[8][8][8][8][8][8][8];
class Puzzle{
public:
short** p;
short lastorder;//1 ??? 3?????? 5 ??????
short ordernum;
Puzzle(){
p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}
this->lastorder = 8;
this->ordernum = 0;
}
Puzzle(const Puzzle* puzzle){
p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
p[i][j] = puzzle->p[i][j];
}
}
this->lastorder = puzzle->lastorder;
this->ordernum = puzzle->ordernum;
}
~Puzzle(){
for(int i=0; i<2; i++){
delete[] p[i];
}
delete[] p;
}
inline bool check(){
return(checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]]);
}
};
int main(){
for(int a=0;a<8;a++){
for(int b=0;b<8;b++){
for(int c=0;c<8;c++){
for(int d=0;d<8;d++){
for(int e=0;e<8;e++){
for(int f=0;f<8;f++){
for(int g=0;g<8;g++){
checker[a][b][c][[d]][e][f][g] = false;
}
}
}
}
}
}
}
while(1){
queue<Puzzle*> q;
Puzzle* Start;
Start = new Puzzle;
for(short i=0;i < 2; i++){
for(short j=0;j < 4; j++){
cin >> Start->p[i][j];
}
}
if(cin.eof()){
break;
}
q.push(Start);
while(!q.empty()){
Puzzle* tmp;
tmp = q.front();
q.pop();
bool ok = false;
if(tmp->p[0][0] == 0 && tmp->p[0][1] == 1 && tmp->p[0][2] == 2 && tmp->p[0][3] == 3 && tmp->p[1][0] == 4 && tmp->p[1][1] == 5 && tmp->p[1][2] == 6)
ok = true;
if(ok){
cout << tmp->ordernum << endl;
delete tmp;
while(!q.empty()){
tmp = q.front();
q.pop();
delete tmp;
}
break;
}
short x,y;
for(short i=0;i < 2; i++){
for(short j=0;j < 4; j++){
if(tmp->p[i][j] == 0){
x = j;
y = i;
}
}
}
tmp->ordernum++;
short Beforeorder = tmp->lastorder;
Puzzle* puzzle;
puzzle = new Puzzle(tmp);
if(x != 3 && Beforeorder != 3 && puzzle->check()){
swap(puzzle->p[y][x],puzzle->p[y][x+1]);
puzzle->lastorder = 1;
q.push(puzzle);
puzzle = new Puzzle(tmp);
}
if(x != 0 && Beforeorder != 1 && puzzle->check()){
swap(puzzle->p[y][x],puzzle->p[y][x-1]);
puzzle->lastorder = 3;
q.push(puzzle);
puzzle = new Puzzle(tmp);
}
if(Beforeorder != 5 && puzzle->check()){
swap(puzzle->p[0][x],puzzle->p[1][x]);
puzzle->lastorder = 5;
q.push(puzzle);
}
delete tmp;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:65:33: error: two consecutive '[' shall only introduce an attribute before '[' token
65 | checker[a][b][c][[d]][e][f][g] = false;
| ^
|
s052382246 | p00121 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
bool checker[8][8][8][8][8][8][8];
class Puzzle{
public:
short p[2][4];
short lastorder;//1 ??? 3?????? 5 ??????
short ordernum;
Puzzle(){
/*p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}*/
this->lastorder = 8;
this->ordernum = 0;
}
/*Puzzle(const Puzzle& puzzle){
p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
p[i][j] = puzzle.p[i][j];
}
}
this->lastorder = puzzle.lastorder;
this->ordernum = puzzle.ordernum;
}*/
/*~Puzzle(){
for(int i=0; i<2; i++){
delete[] p[i];
}
delete[] p;*/
}
/*inline bool check(){
return(checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]]);
}
inline void throughpuzzle(){
checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]] = false;
}*/
};
int main(){
while(1){
for(int a=0;a<8;a++){
for(int b=0;b<8;b++){
for(int c=0;c<8;c++){
for(int d=0;d<8;d++){
for(int e=0;e<8;e++){
for(int f=0;f<8;f++){
for(int g=0;g<8;g++){
checker[a][b][c][d][e][f][g] = true;
}
}
}
}
}
}
}
queue<Puzzle> q;
Puzzle Start;
cin >> Start.p[0][0];
if(cin.eof()){
break;
}
cin >> Start.p[0][1] >> Start.p[0][2] >> Start.p[0][3] >> Start.p[1][0] >> Start.p[1][1] >> Start.p[1][2] >> Start.p[1][3];
q.push(Start);
while(!q.empty()){
Puzzle tmp;
tmp = q.front();
q.pop();
if(tmp.p[0][0] == 0 && tmp.p[0][1] == 1 && tmp.p[0][2] == 2 && tmp.p[0][3] == 3 && tmp.p[1][0] == 4 && tmp.p[1][1] == 5 && tmp.p[1][2] == 6){
cout << tmp.ordernum << endl;
while(!q.empty()){
tmp = q.front();
q.pop();
}
break;
}
short x,y;
for(short i=0;i < 2; i++){
for(short j=0;j < 4; j++){
if(tmp.p[i][j] == 0){
x = j;
y = i;
i=500;
}
}
}
tmp.ordernum++;
short Beforeorder = tmp.lastorder;
Puzzle puzzle = tmp;
short t;
if(x != 3 && Beforeorder != 3){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x+1];
puzzle.p[y][x+1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 1;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
}
puzzle = tmp;
}
if(x != 0 && Beforeorder != 1){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x-1];
puzzle.p[y][x-1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 3;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
}
puzzle = tmp;
}
if(Beforeorder != 5){
t = puzzle.p[0][x];
puzzle.p[0][x] = puzzle.p[1][x];
puzzle.p[1][x] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 5;
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
q.push(puzzle);
}
}
}
}
return 0;
} | a.cc:44:4: error: expected ';' after class definition
44 | }
| ^
| ;
a.cc:54:1: error: expected declaration before '}' token
54 | };
| ^
|
s937344743 | p00121 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
bool checker[8][8][8][8][8][8][8];
class Puzzle{
public:
short p[2][4];
short lastorder;//1 ??? 3?????? 5 ??????
short ordernum;
Puzzle(){
/*p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}*/
this->lastorder = 8;
this->ordernum = 0;
}
/*Puzzle(const Puzzle& puzzle){
p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
p[i][j] = puzzle.p[i][j];
}
}
this->lastorder = puzzle.lastorder;
this->ordernum = puzzle.ordernum;
}*/
~Puzzle(){
/*for(int i=0; i<2; i++){
delete[] p[i];
}
delete[] p;*/
}
/*inline bool check(){
return(checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]]);
}
inline void throughpuzzle(){
checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]] = false;
}*/
};
int main(){
while(1){
for(int a=0;a<8;a++){
for(int b=0;b<8;b++){
for(int c=0;c<8;c++){
for(int d=0;d<8;d++){
for(int e=0;e<8;e++){
for(int f=0;f<8;f++){
for(int g=0;g<8;g++){
checker[a][b][c][d][e][f][g] = true;
}
}
}
}
}
}
}
queue<Puzzle> q;
Puzzle Start;
cin >> Start.p[0][0];
if(cin.eof()){
break;
}
cin >> Start.p[0][1] >> Start.p[0][2] >> Start.p[0][3] >> Start.p[1][0] >> Start.p[1][1] >> Start.p[1][2] >> Start.p[1][3];
q.push(Start);
while(!q.empty()){
Puzzle tmp;
tmp = q.front();
q.pop();
if(tmp.p[0][0] == 0 && tmp.p[0][1] == 1 && tmp.p[0][2] == 2 && tmp.p[0][3] == 3 && tmp.p[1][0] == 4 && tmp.p[1][1] == 5 && tmp.p[1][2] == 6){
cout << tmp.ordernum << endl;
while(!q.empty()){
tmp = q.front();
q.pop();
}
break;
}
short x,y;
for(short i=0;i < 2; i++){
for(short j=0;j < 4; j++){
if(tmp.p[i][j] == 0){
x = j;
y = i;
j=4;
i=3
}
}
}
tmp.ordernum++;
short Beforeorder = tmp.lastorder;
Puzzle puzzle = tmp;
short t;
if(x != 3 && Beforeorder != 3){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x+1];
puzzle.p[y][x+1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 1;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
}
puzzle = tmp;
}
if(x != 0 && Beforeorder != 1){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x-1];
puzzle.p[y][x-1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 3;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
}
puzzle = tmp;
}
if(Beforeorder != 5){
t = puzzle.p[0][x];
puzzle.p[0][x] = puzzle.p[1][x];
puzzle.p[1][x] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 5;
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
q.push(puzzle);
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:119:16: error: expected ';' before '}' token
119 | i=3
| ^
| ;
120 | }
| ~
|
s530750139 | p00121 | C++ | #include<iostream>
#include<queue>
#include<vector>
#include<list>
using namespace std;
bool checker[8][8][8][8][8][8][8];
list<short[7]> checklist;
class Puzzle{
public:
short p[2][4];
short lastorder;//1 ??? 3?????? 5 ??????
short ordernum;
Puzzle(){
/*p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}*/
this->lastorder = 8;
this->ordernum = 0;
}
/*Puzzle(const Puzzle& puzzle){
p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
p[i][j] = puzzle.p[i][j];
}
}
this->lastorder = puzzle.lastorder;
this->ordernum = puzzle.ordernum;
}*/
~Puzzle(){
/*for(int i=0; i<2; i++){
delete[] p[i];
}
delete[] p;*/
}
/*inline bool check(){
return(checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]]);
}
inline void throughpuzzle(){
checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]] = false;
}*/
};
int main(){
for(int a=0;a<8;a++){
for(int b=0;b<8;b++){
for(int c=0;c<8;c++){
for(int d=0;d<8;d++){
for(int e=0;e<8;e++){
for(int f=0;f<8;f++){
for(int g=0;g<8;g++){
checker[a][b][c][d][e][f][g] = true;
}
}
}
}
}
}
}
while(1){
queue<Puzzle> q;
Puzzle Start;
cin >> Start.p[0][0];
if(cin.eof()){
break;
}
cin >> Start.p[0][1] >> Start.p[0][2] >> Start.p[0][3] >> Start.p[1][0] >> Start.p[1][1] >> Start.p[1][2] >> Start.p[1][3];
q.push(Start);
while(!q.empty()){
Puzzle tmp;
tmp = q.front();
q.pop();
if(tmp.p[0][0] == 0 && tmp.p[0][1] == 1 && tmp.p[0][2] == 2 && tmp.p[0][3] == 3 && tmp.p[1][0] == 4 && tmp.p[1][1] == 5 && tmp.p[1][2] == 6){
cout << tmp.ordernum << endl;
while(!q.empty()){
q.pop();
}
break;
}
short x,y;
for(short i=0;i < 2; i++){
for(short j=0;j < 4; j++){
if(tmp.p[i][j] == 0){
x = j;
y = i;
}
}
}
tmp.ordernum++;
short Beforeorder = tmp.lastorder;
short checktmp[7];
Puzzle puzzle = tmp;
short t;
if(x != 3 && Beforeorder != 3){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x+1];
puzzle.p[y][x+1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 1;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
for(int i=0;i<7;i++){
checktmp[i] = puzzle.p[i/4][i%4];
}
checklist.push_back(checktmp);
}
puzzle = tmp;
}
if(x != 0 && Beforeorder != 1){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x-1];
puzzle.p[y][x-1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 3;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
for(int i=0;i<7;i++){
checktmp[i] = puzzle.p[i/4][i%4];
}
checklist.push_back(checktmp);
}
puzzle = tmp;
}
if(Beforeorder != 5){
t = puzzle.p[0][x];
puzzle.p[0][x] = puzzle.p[1][x];
puzzle.p[1][x] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 5;
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
for(int i=0;i<7;i++){
checktmp[i] = puzzle.p[i/4][i%4];
}
checklist.push_back(checktmp);
q.push(puzzle);
}
}
list<short[7]>::iterator itr;
for(itr = checklist.begin();itr!=checklist.end();itr++){
checker[(*itr)[0]] [(*itr)[1]] [(*itr)[2]] [(*itr)[3]] [(*itr)[4]] [(*itr)[5]] [(*itr)[6]] = true;
}
}
}
return 0;
} | In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
from /usr/include/c++/14/bits/allocator.h:46,
from /usr/include/c++/14/string:43,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::destroy(_Up*) [with _Up = short int [7]; _Tp = std::_List_node<short int [7]>]':
/usr/include/c++/14/bits/alloc_traits.h:597:15: required from 'static void std::allocator_traits<std::allocator<_CharT> >::destroy(allocator_type&, _Up*) [with _Up = short int [7]; _Tp = std::_List_node<short int [7]>; allocator_type = std::allocator<std::_List_node<short int [7]> >]'
597 | __a.destroy(__p);
| ~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/list.tcc:77:31: required from 'void std::__cxx11::_List_base<_Tp, _Alloc>::_M_clear() [with _Tp = short int [7]; _Alloc = std::allocator<short int [7]>]'
77 | _Node_alloc_traits::destroy(_M_get_Node_allocator(), __val);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_list.h:576:9: required from 'std::__cxx11::_List_base<_Tp, _Alloc>::~_List_base() [with _Tp = short int [7]; _Alloc = std::allocator<short int [7]>]'
576 | { _M_clear(); }
| ^~~~~~~~
/usr/include/c++/14/bits/stl_list.h:750:7: required from here
750 | list() = default;
| ^~~~
/usr/include/c++/14/bits/new_allocator.h:198:17: error: request for member '~short int [7]' in '* __p', which is of non-class type 'short int [7]'
198 | { __p->~_Up(); }
| ~~~~~~^~~
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = short int [7]; _Args = {const short int (&)[7]}; _Tp = std::_List_node<short int [7]>]':
/usr/include/c++/14/bits/alloc_traits.h:575:17: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = short int [7]; _Args = {const short int (&)[7]}; _Tp = std::_List_node<short int [7]>; allocator_type = std::allocator<std::_List_node<short int [7]> >]'
575 | __a.construct(__p, std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_list.h:714:33: required from 'std::__cxx11::list<_Tp, _Alloc>::_Node* std::__cxx11::list<_Tp, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const short int (&)[7]}; _Tp = short int [7]; _Alloc = std::allocator<short int [7]>; _Node = std::__cxx11::list<short int [7]>::_Node]'
714 | _Node_alloc_traits::construct(__alloc, __p->_M_valptr(),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
715 | std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_list.h:2013:32: required from 'void std::__cxx11::list<_Tp, _Alloc>::_M_insert(iterator, _Args&& ...) [with _Args = {const short int (&)[7]}; _Tp = short int [7]; _Alloc = std::allocator<short int [7]>; iterator = std::__cxx11::list<short int [7]>::iterator]'
2013 | _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_list.h:1315:24: required from 'void std::__cxx11::list<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = short int [7]; _Alloc = std::allocator<short int [7]>; value_type = short int [7]]'
1315 | { this->_M_insert(end(), __x); }
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~
a.cc:143:30: required from here
143 | checklist.push_back(checktmp);
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: parenthesized initializer in array new
191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s014093103 | p00121 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
bool checker[8][8][8][8][8][8][8];
vector<short[8]> checkvec;
class Puzzle{
public:
short p[2][4];
short lastorder;//1 ??? 3?????? 5 ??????
short ordernum;
Puzzle(){
/*p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}*/
this->lastorder = 8;
this->ordernum = 0;
}
/*Puzzle(const Puzzle& puzzle){
p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
p[i][j] = puzzle.p[i][j];
}
}
this->lastorder = puzzle.lastorder;
this->ordernum = puzzle.ordernum;
}*/
~Puzzle(){
/*for(int i=0; i<2; i++){
delete[] p[i];
}
delete[] p;*/
}
/*inline bool check(){
return(checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]]);
}
inline void throughpuzzle(){
checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]] = false;
}*/
};
int main(){
while(1){
queue<Puzzle> q;
Puzzle Start;
cin >> Start.p[0][0];
if(cin.eof()){
break;
}
cin >> Start.p[0][1] >> Start.p[0][2] >> Start.p[0][3] >> Start.p[1][0] >> Start.p[1][1] >> Start.p[1][2] >> Start.p[1][3];
if(Start.p[0][0] == 0 && Start.p[0][1] == 1 && Start.p[0][2] == 2 && Start.p[0][3] == 3 && Start.p[1][0] == 4 && Start.p[1][1] == 5 && Start.p[1][2] == 6){
cout << 0 << endl;
}
for(int a=0;a<8;a++){
for(int b=0;b<8;b++){
for(int c=0;c<8;c++){
for(int d=0;d<8;d++){
for(int e=0;e<8;e++){
for(int f=0;f<8;f++){
for(int g=0;g<8;g++){
checker[a][b][c][d][e][f][g] = true;
}
}
}
}
}
}
}
q.push(Start);
while(!q.empty()){
Puzzle tmp;
tmp = q.front();
q.pop();
if(tmp.p[0][0] == 0 && tmp.p[0][1] == 1 && tmp.p[0][2] == 2 && tmp.p[0][3] == 3 && tmp.p[1][0] == 4 && tmp.p[1][1] == 5 && tmp.p[1][2] == 6){
cout << tmp.ordernum << endl;
break;
}
short x,y;
for(short i=0;i < 2; i++){
for(short j=0;j < 4; j++){
if(tmp.p[i][j] == 0){
x = j;
y = i;
}
}
}
tmp.ordernum++;
short Beforeorder = tmp.lastorder;
Puzzle puzzle = tmp;
short t;
if(x != 3 && Beforeorder != 3){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x+1];
puzzle.p[y][x+1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 1;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
for(int i=0;i<8;i++){
checkvec[i] = puzzle.p[i/4][i%4];
}
}
puzzle = tmp;
}
if(x != 0 && Beforeorder != 1){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x-1];
puzzle.p[y][x-1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 3;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
for(int i=0;i<8;i++){
checkvec[i] = puzzle.p[i/4][i%4];
}
}
puzzle = tmp;
}
if(Beforeorder != 5){
t = puzzle.p[0][x];
puzzle.p[0][x] = puzzle.p[1][x];
puzzle.p[1][x] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 5;
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
q.push(puzzle);
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:140:25: error: incompatible types in assignment of 'short int' to '__gnu_cxx::__alloc_traits<std::allocator<short int [8]>, short int [8]>::value_type' {aka 'short int [8]'}
140 | checkvec[i] = puzzle.p[i/4][i%4];
a.cc:155:25: error: incompatible types in assignment of 'short int' to '__gnu_cxx::__alloc_traits<std::allocator<short int [8]>, short int [8]>::value_type' {aka 'short int [8]'}
155 | checkvec[i] = puzzle.p[i/4][i%4];
|
s393471330 | p00121 | C++ | #include<iostream>
#include<queue>
#include<vector>
using namespace std;
bool checker[8][8][8][8][8][8][8];
class Puzzle{
public:
short p[2][4];
short lastorder;//1 ??? 3?????? 5 ??????
short ordernum;
Puzzle(){
/*p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}*/
this->lastorder = 8;
this->ordernum = 0;
}
/*Puzzle(const Puzzle& puzzle){
p = new short*[2];
for(int i=0; i<2; i++){
p[i] = new short[4];
}
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
p[i][j] = puzzle.p[i][j];
}
}
this->lastorder = puzzle.lastorder;
this->ordernum = puzzle.ordernum;
}*/
~Puzzle(){
/*for(int i=0; i<2; i++){
delete[] p[i];
}
delete[] p;*/
}
/*inline bool check(){
return(checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]]);
}
inline void throughpuzzle(){
checker[p[0][0]][p[0][1]][p[0][2]][p[0][3]][p[1][0]][p[1][1]][p[1][2]] = false;
}*/
};
int main(){
while(1){
queue<Puzzle> q;
Puzzle Start;
cin >> Start.p[0][0];
if(cin.eof()){
break;
}
cin >> Start.p[0][1] >> Start.p[0][2] >> Start.p[0][3] >> Start.p[1][0] >> Start.p[1][1] >> Start.p[1][2] >> Start.p[1][3];
if(Start.p[0][0] == 0 && Start.p[0][1] == 1 && Start.p[0][2] == 2 && Start.p[0][3] == 3 && Start.p[1][0] == 4 && Start.p[1][1] == 5 && Start.p[1][2] == 6){
cout << 0 << endl;
continue;
}
for(int a=0;a<8;a++){
for(int b=0;b<8;b++){
for(int c=0;c<8;c++){
for(int d=0;d<8;d++){
for(int e=0;e<8;e++){
for(int f=0;f<8;f++){
for(int g=0;g<8;g++){
checker[a][b][c][d][e][f][g] = true;
}
}
}
}
}
}
}
q.push(Start);
while(!q.empty()){
Puzzle tmp;
tmp = q.front();
if(tmp.p[0][0] == 0 && tmp.p[0][1] == 1 && tmp.p[0][2] == 2 && tmp.p[0][3] == 3 && tmp.p[1][0] == 4 && tmp.p[1][1] == 5 && tmp.p[1][2] == 6){
cout << tmp.ordernum << endl;
break;
}
q.pop();
short x,y;
for(short i=0;i < 2; i++){
for(short j=0;j < 4; j++){
if(tmp.p[i][j] == 0){
x = j;
y = i;
}
}
}
tmp.ordernum++;
// short Beforeorder = tmp.lastorder;
Puzzle puzzle = tmp;
short t;
if(x != 3 && Beforeorder != 3){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x+1];
puzzle.p[y][x+1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 1;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
}
puzzle = tmp;
}
if(x != 0 && Beforeorder != 1){
t = puzzle.p[y][x];
puzzle.p[y][x] = puzzle.p[y][x-1];
puzzle.p[y][x-1] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 3;
q.push(puzzle);
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
}
puzzle = tmp;
}
if(Beforeorder != 5){
t = puzzle.p[0][x];
puzzle.p[0][x] = puzzle.p[1][x];
puzzle.p[1][x] = t;
if((checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]])){
puzzle.lastorder = 5;
checker[puzzle.p[0][0]][puzzle.p[0][1]][puzzle.p[0][2]][puzzle.p[0][3]][puzzle.p[1][0]][puzzle.p[1][1]][puzzle.p[1][2]] = false;
q.push(puzzle);
}
}
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:132:20: error: 'Beforeorder' was not declared in this scope
132 | if(x != 3 && Beforeorder != 3){
| ^~~~~~~~~~~
a.cc:145:20: error: 'Beforeorder' was not declared in this scope
145 | if(x != 0 && Beforeorder != 1){
| ^~~~~~~~~~~
a.cc:157:10: error: 'Beforeorder' was not declared in this scope
157 | if(Beforeorder != 5){
| ^~~~~~~~~~~
|
s688890179 | p00121 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x3f3f3f3f
#define inff -30000000
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=20+10;
typedef pair<string,int>P;
map<string,int>save;
string s[MAX];
int d[5]={-1,1,-4,4};
void bfs(){
queue<P>q;
q.push(P("01234567",0));
save["01234567"]=0;
while(!q.empty()){
P t=q.front();
q.pop();
int flag=t.second;
for(int i=0;i<4;i++){
if((flag==3&&d[i]==1||(flag==4&&d[i]==-1))||flag+d[i]<0||flag+d[i]>=8)
continue;
string str=t.first;
swap(str[flag],str[flag+d[i]]);
if(save.find(str)==save.end()){
save[str]=save[t.first]+1;
q.push(P(str,flag+d[i]));
}
}
}
}
int main(){
#ifdef SIYU
freopen("in.txt","r",stdin);
#endif // SIYU
bfs();
char ch[50],chh[50];
while(gets(ch)){
string siyu;
int j=0;
for(int i=0;i<strlen(ch);i++){
if(ch[i]!=' '){
chh[j++]=ch[i];
}
}
chh[8]='\0';
siyu=chh;
cout<<save[siyu]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:49:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
49 | while(gets(ch)){
| ^~~~
| getw
|
s261130301 | p00121 | C++ | #include <bits/stdc++.h>
using namespace std;
string swp(string s, const int& a, const int &b) {
swap(s[a],s[b]); return s;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string s = "01234567";
queue<string> q;
map<string, int> m;
q.push(s);
m[s] = 0;
while (!q.empty()) {
string t = q.front(); q.pop();
int idx = t.find('0');
string u;
if (idx-1 >= 0 && idx != 4) {
u = swp(t, idx, idx-1);
if (m.find(u) == m.end()) {
m[u] = m[t] + 1;
q.push(u);
}
}
if (idx + 1 < 8 && idx != 3) {
u = swp(t, idx, idx+1);
if (m.find[u] == m.end()) {
m[u] = m[t] + 1;
q.push(u);
}
}
if (idx - 4 >= 0) {
u = swp(t, idx, idx-4);
if (m.find(u) == m.end()) {
m[u] = m[t] + 1;
m.push(u);
}
}
if (idx + 4 < 0) {
u = swp(t, idx, idx+4);
if (m.find(u) == m.end()) {
m[u] = m[t] + 1;
q.push(u);
}
}
}
string line; stringstream ss;
while (getline(cin, line)) {
ss << line;
string t = "";
for (int i = 0; i < 8; ++i) {
char c; ss >> c; t += c;
}
cout << m[t] << endl;
}
} | a.cc: In function 'int main()':
a.cc:33:17: error: no match for 'operator[]' (operand types are '<unresolved overloaded function type>' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
33 | if (m.find[u] == m.end()) {
| ^
a.cc:42:11: error: 'class std::map<std::__cxx11::basic_string<char>, int>' has no member named 'push'
42 | m.push(u);
| ^~~~
|
s367676550 | p00121 | C++ | #include <bits/stdc++.h>
using namespace std;
using namespace std;
typedef pair<int,string> P;
int main(){
int d[4] = {-1,1,-4,4};
map<string,int> ans;
ans["01234567"] = 0;
queue<P> que;
que.push(P(0,"01234567"));
while(que.size()){
P p = que.front(); que.pop();
int k = ans[p.second];
for(int i = 0;i < 4;i++){
int n = p.first + d[i];
if(i == 0 && n == 3)continue;
if(i == 1 && n == 4)continue;
if(n >= 0 && n < 8){
string tmp;
tmp = p.second
tmp[p.first] = tmp[n];
tmp[n] = '0';
if(ans.find(tmp) == ans.end()){
ans[tmp] = k + 1;
que.push(P(n,tmp));
}
}
}
}
string s;
char t;
while(cin >> t){
s += t;
for(int i = 0;i < 7;i++){
cin >> t;
s += t;
}
cout << ans[s] << endl;
s.clear();
}
return 0;
} | a.cc: In function 'int main()':
a.cc:24:30: error: expected ';' before 'tmp'
24 | tmp = p.second
| ^
| ;
25 | tmp[p.first] = tmp[n];
| ~~~
|
s179574941 | p00121 | C++ | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <stack>
#include <set>
//反向bfs
using namespace std;
map<string ,int> t;
int num;
int mv[]={-4,4,1,-1};//上下右左
void bfs(string st)
{
queue<string> q;
t[st]=1;
q.push(st);
while(!q.empty())
{
s=q.front(),q.pop();
// int nu=st.find('0');
// for(int i=0;i<4;i++)
// {
// int tn=nu+mv[i];
// if(tn<0||tn>7||tn==3&&mv[i]==1||tn==4&&mv[i]==-1)
// continue;
// string tp=st;
// swap(tp[nu],tp[nu+mv[i]]);
// if(!t[tp])
// {
// q.push(tp);
// t[tp]=t[st]+1;
// }
//
//
// }
// }
//
// t[st]=1;q.push(st); //起始状?
// while(!q.empty())
// {
//st=q.front();q.pop();
int num=st.find('0');//找到空格位置
for(int i=0;i<4;++i)
{
int tn=num+mv[i];//可能??的数?
if(tn<0||tn>7||num==3&&mv[i]==1||num==4&&mv[i]==-1)
//空格在3的?候,4不能??,因?3 4 不相?,反之同理
{
continue;
}
string tp=st;
swap(tp[num],tp[num+mv[i]]);//移?物?
if(!t[tp])//未出??的状?
{
q.push(tp);
t[tp]=t[st]+1;
}
}
}
}
int main()
{
string st="01234567";
bfs(st);
while(scanf("%d",&num)!=EOF)
{
st[0]=num+'0';
for(int i=1;i<8;i++)
{
scanf("%d",&num);
st[i]=num+'0';
}
cout<<t[st]-1<<endl;
}
} | a.cc: In function 'void bfs(std::string)':
a.cc:25:8: error: 's' was not declared in this scope
25 | s=q.front(),q.pop();
| ^
|
s335251004 | p00121 | C++ |
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
using namespace std;
const int N = 8;
const int INF = INT_MAX;
bool hantei(int * box){
for(int i = 0; i < N; i++){
if( box[i] != i) return false;
}
return true;
}
int zeroIndex(int * box){
for(int i = 0; i < N; i++){
if( box[i] == 0) return i;
}
}
bool canMoveLeft(int * box){
int index = zeroIndex(box);
return (index != 0 && index != 4);
}
bool canMoveRight(int * box){
int index = zeroIndex(box);
return (index != 3 && index != 7);
}
bool canMoveUp(int *box){
int index = zeroIndex(box);
return (index >= 4);
}
bool canMoveDown(int *box){
int index = zeroIndex(box);
return (index <= 3);
}
int *copyBox(int *box){
int *newBox = new int[N];
for(int i = 0; i < N; i++){
newBox[i] = box[i];
}
return newBox;
}
int *swap(int *box,int x,int y){
int temp;
int *newBox = copyBox(box);
temp = box[x];
newBox[x] = newBox[y];
newBox[y] = temp;
return newBox;
}
int *moveLeft(int *box){
int zeroInd = zeroIndex(box);
return swap(box,zeroInd,zeroInd - 1);
}
int *moveRight(int *box){
int zeroInd = zeroIndex(box);
return swap(box,zeroInd,zeroInd + 1);
}
int *moveUp(int *box){
int zeroInd = zeroIndex(box);
return swap(box,zeroInd,zeroInd - 4);
}
int *moveDown(int *box){
int zeroInd = zeroIndex(box);
return swap(box,zeroInd,zeroInd + 4);
}
void printBox(int *box){
for(int i = 0; i < N; i++){
cout << box[i] <<" ";
}
cout << endl;
}
bool isEqualBox(int *box1, int *box2){
for(int i = 0; i < N; i++){
if(box1[i] != box2[i]){
return false;
}
}
return true;
}
bool didPass(vector<int *> oldBoxList,int *box){
auto itr = oldBoxList.begin();
while( itr != oldBoxList.end()){
if( isEqualBox( *itr,box) == true){
return true;
}
itr++;
}
return false;
}
int wfs(int *box){
if(hantei(box) == true){
return 0;
}
int count = 0;
int *currentBox;
queue<pair<int*,int>> nextBoxList;
vector<int *> oldBoxList;
pair<int*,int> p(box,count);
nextBoxList.push(p);
oldBoxList.push_back(box);
while( nextBoxList.empty() != true){
pair<int*,int> currentPair;
currentPair = nextBoxList.front();
currentBox = currentPair.first;
int currentNum = currentPair.second;
nextBoxList.pop();
//cout<< currentNum << " : ";
//printBox(currentBox);
//can move left ?
if( canMoveLeft(currentBox)){
int *leftBox = moveLeft(currentBox);
//if the leftBox is goal state, return count value
if(hantei( leftBox) == true){
return currentNum + 1;
}else if(didPass(oldBoxList,leftBox) != true){
//if leftBox have not appeared , add to the nexBoxList and oldBoxList
pair<int *,int> leftPair(leftBox,currentNum + 1);
nextBoxList.push(leftPair);
oldBoxList.push_back(leftBox);
}
}
//can move right?
if( canMoveRight(currentBox)){
int *rightBox = moveRight(currentBox);
//if the leftBox is goal state, return count value
if(hantei( rightBox) == true){
return currentNum + 1;
}else if(didPass(oldBoxList,rightBox) != true){
//if leftBox have not appeared, add to the nexBoxList and oldBoxList
pair<int*,int> rightPair(rightBox,currentNum + 1);
nextBoxList.push( rightPair);
oldBoxList.push_back(rightBox);
}
}
//can move up?
if( canMoveUp(currentBox)){
int *upperBox = moveUp(currentBox);
//if the uppertBox is goal state, return count value
if(hantei( upperBox) == true){
return currentNum + 1;
}else if(didPass(oldBoxList,upperBox) != true){
//if upperBox have not appeared, add to the nexBoxList and oldBoxList
pair<int*,int> upperPair(upperBox,currentNum + 1);
nextBoxList.push( upperPair);
oldBoxList.push_back(upperBox);
}
}
//can move down?
if( canMoveDown(currentBox)){
int *lowerBox = moveDown(currentBox);
//if the leftBox is goal state, return count value
if(hantei( lowerBox) == true){
return currentNum + 1;
}else if(didPass(oldBoxList,lowerBox) != true){
//if leftBox have not appeared, add to the nexBoxList and oldBoxList
pair<int *,int> lowerPair(lowerBox,currentNum + 1);
nextBoxList.push( lowerPair);
oldBoxList.push_back(lowerBox);
}
}
}
return -1;
}
int main()
{
int a[8];
int input;
int index = 0;
while(cin >> input){
a[index] = input;
index++;
if(index == 8){
cout << wfs(a) << endl;
index = 0;
}
}
return 0;
} | a.cc:10:17: error: 'INT_MAX' was not declared in this scope
10 | const int INF = INT_MAX;
| ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
6 | #include <queue>
+++ |+#include <climits>
7 | #include <vector>
a.cc: In function 'int zeroIndex(int*)':
a.cc:22:1: warning: control reaches end of non-void function [-Wreturn-type]
22 | }
| ^
|
s915740203 | p00121 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int find_locate(int node,int num) {
int ans=0;
while(ans < 8) {
int a, b, c;
int keta_a=1, keta_b=1;
for (int j=0; j<ans; j++) {
keta_a = keta_a*10;
keta_b = keta_b*10;
}
keta_a = keta_a*10;
a = node % keta_a;
b = node % keta_b;
c = a-b;
c = c/keta_b;
if (c==num) {
break;
}
ans++;
}
return ans;
}
int insert(int node, int keta, int num) {
int a,b,c,d;
int keta_a=1, keta_b=1;
int ans;
for (int i=0; i<keta; i++) {
keta_a = keta_a*10;
keta_b = keta_b*10;
}
keta_a = keta_a*10;
a = node % keta_a;
b = node % keta_b;
c = a-b;
d = num * keta_b;
ans = node - c;
ans = ans + d;
return ans;
}
int look(int node, int num) {
int a, b, c;
int keta_a=1, keta_b=1;
for (int j=0; j<num; j++) {
keta_a = keta_a*10;
keta_b = keta_b*10;
}
keta_a = keta_a*10;
a = node % keta_a;
b = node % keta_b;
c = a-b;
c = c/keta_b;
return c;
}
int proceed_adj(int node, int dirc) {
int loc_zero = find_locate(node, 0);
int swap;
if (dirc == 0) {
// go down
if (loc_zero <= 3) {
return 0;
}
swap = look(node, loc_zero-4);
node = insert(node, loc_zero-4, 0);
node = insert(node, loc_zero, swap);
return node;
}
if (dirc == 1) {
// go up
if (loc_zero >= 4) {
return 0;
}
swap = look(node, loc_zero+4);
node = insert(node, loc_zero+4, 0);
node = insert(node, loc_zero, swap);
return node;
}
if (dirc == 2) {
// go left
if (loc_zero == 3 || loc_zero == 7) {
return 0;
}
swap = look(node, loc_zero+1);
node = insert(node, loc_zero+1, 0);
node = insert(node, loc_zero, swap);
return node;
}
if (dirc == 3) {
// go right
if(loc_zero == 0 || loc_zero == 4) {
return 0;
}
swap = look(node, loc_zero-1);
node = insert(node, loc_zero-1, 0);
node = insert(node, loc_zero, swap);
return node;
}
}
/*
int main(void) {
int node1 = 12034567;
int node2 = 12345067;
printf("node1 is: %d\n", node1);
for (int i=0; i<4; i++) {
printf("i = %d, then adj node is %d\n", i, proceed_adj(node1, i));
}
printf("\n");
printf("node2 is: %d\n", node2);
for (int i=0; i<4; i++) {
printf("i = %d, then adj node is %d\n", i, proceed_adj(node2, i));
}
return 0;
}
*/
int main(void) {
int visited[76543210];
int distance[76543210];
queue<int> q;
int input;
int node, adj_node;
while(scanf("%d", &input) != EOF) {
for (int i=0; i<n; i++) {
visited[i] = 0;
distance[i] = n+1;
}
visited[input] = 1;
distance[input] = 0;
q.push(input);
while(true) {
node = q.front(); q.pop();
if (node == 1234567) {
break;
}
for (int i=0; i<4; i++) {
adj_node = proceed_adj(node, i);
if (adj_node == 0) { continue; }
if (visited[adj_node] == 1) { continue; }
visited[adj_node] = 1;
distance[adj_node] = distance[node]+1;
q.push(adj_node);
}
}
printf("%d\n", distance[node]);
}
} | a.cc: In function 'int main()':
a.cc:144:25: error: 'n' was not declared in this scope
144 | for (int i=0; i<n; i++) {
| ^
a.cc: In function 'int proceed_adj(int, int)':
a.cc:114:1: warning: control reaches end of non-void function [-Wreturn-type]
114 | }
| ^
|
s338028434 | p00121 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int find_locate(int node,int num) {
int ans=0;
while(ans < 8) {
int a, b, c;
int keta_a=1, keta_b=1;
for (int j=0; j<ans; j++) {
keta_a = keta_a*10;
keta_b = keta_b*10;
}
keta_a = keta_a*10;
a = node % keta_a;
b = node % keta_b;
c = a-b;
c = c/keta_b;
if (c==num) {
break;
}
ans++;
}
return ans;
}
int insert(int node, int keta, int num) {
int a,b,c,d;
int keta_a=1, keta_b=1;
int ans;
for (int i=0; i<keta; i++) {
keta_a = keta_a*10;
keta_b = keta_b*10;
}
keta_a = keta_a*10;
a = node % keta_a;
b = node % keta_b;
c = a-b;
d = num * keta_b;
ans = node - c;
ans = ans + d;
return ans;
}
int look(int node, int num) {
int a, b, c;
int keta_a=1, keta_b=1;
for (int j=0; j<num; j++) {
keta_a = keta_a*10;
keta_b = keta_b*10;
}
keta_a = keta_a*10;
a = node % keta_a;
b = node % keta_b;
c = a-b;
c = c/keta_b;
return c;
}
int proceed_adj(int node, int dirc) {
int loc_zero = find_locate(node, 0);
int swap;
if (dirc == 0) {
// go down
if (loc_zero <= 3) {
return 0;
}
swap = look(node, loc_zero-4);
node = insert(node, loc_zero-4, 0);
node = insert(node, loc_zero, swap);
return node;
}
if (dirc == 1) {
// go up
if (loc_zero >= 4) {
return 0;
}
swap = look(node, loc_zero+4);
node = insert(node, loc_zero+4, 0);
node = insert(node, loc_zero, swap);
return node;
}
if (dirc == 2) {
// go left
if (loc_zero == 3 || loc_zero == 7) {
return 0;
}
swap = look(node, loc_zero+1);
node = insert(node, loc_zero+1, 0);
node = insert(node, loc_zero, swap);
return node;
}
if (dirc == 3) {
// go right
if(loc_zero == 0 || loc_zero == 4) {
return 0;
}
swap = look(node, loc_zero-1);
node = insert(node, loc_zero-1, 0);
node = insert(node, loc_zero, swap);
return node;
}
}
/*
int main(void) {
int node1 = 12034567;
int node2 = 12345067;
printf("node1 is: %d\n", node1);
for (int i=0; i<4; i++) {
printf("i = %d, then adj node is %d\n", i, proceed_adj(node1, i));
}
printf("\n");
printf("node2 is: %d\n", node2);
for (int i=0; i<4; i++) {
printf("i = %d, then adj node is %d\n", i, proceed_adj(node2, i));
}
return 0;
}
*/
int main(void) {
n = 76543210;
int visited[76543210];
int distance[76543210];
queue<int> q;
int input;
int node, adj_node;
while(scanf("%d", &input) != EOF) {
for (int i=0; i<n; i++) {
visited[i] = 0;
distance[i] = n+1;
}
visited[input] = 1;
distance[input] = 0;
q.push(input);
while(true) {
node = q.front(); q.pop();
if (node == 1234567) {
break;
}
for (int i=0; i<4; i++) {
adj_node = proceed_adj(node, i);
if (adj_node == 0) { continue; }
if (visited[adj_node] == 1) { continue; }
visited[adj_node] = 1;
distance[adj_node] = distance[node]+1;
q.push(adj_node);
}
}
printf("%d\n", distance[node]);
}
} | a.cc: In function 'int main()':
a.cc:134:5: error: 'n' was not declared in this scope
134 | n = 76543210;
| ^
a.cc: In function 'int proceed_adj(int, int)':
a.cc:114:1: warning: control reaches end of non-void function [-Wreturn-type]
114 | }
| ^
|
s207354112 | p00121 | C++ | #include<stdio.h>
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<cstring>
#include<algorithm>
#define cdebug() freopen("C:\\Users\\netmaster.ASUS\\Desktop\\123.txt","r",stdin)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rev(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a,x) memset(a,x,sizeof a)
#define inf 0x3f3f3f3f
typedef long long LL;
using namespace std;
const int mod=1e9 +7;
const int maxn=2005;
const int maxm=4005;
int done[8][8][8][8][8][8][8];
struct node
{
int d[8],w,dir;
node()
{
}
node(int dd[],int di,int ww)
{
rep(i,0,8)
d[i]=dd[i];
dir=di;
w=ww;
}
};
inline int& gbool(int dd[])
{
return done[dd[0]][dd[1]][dd[2]][dd[3]][dd[4]][dd[5]][dd[6]];
}
int dx[][3]={1,4,-1,0,2,5,1,3,6,2,7,-1,0,5,-1,1,4,6,2,5,7,3,6,-1};
void bfs()
{
int dd[8];
queue<node>q;
clr(done,0);
rep(i,0,8)
dd[i]=i;
q.push(node(dd,0,0));
gbool(dd)=1;
while(!q.empty())
{
node x=q.front();q.pop();
rep(i,0,3)
if(dx[x.dir][i]!=-1)
{
node cur=x;
swap(cur.d[x.dir],cur.d[dx[x.dir][i]]);
cur.dir=dx[x.dir][i];
cur.w++;
if(!gbool(cur.d))
{
gbool(cur.d)=x.w+1;
q.push(cur);
}
}
}
}
int da[8];
int main()
{bfs();
while(~scanf("%d",&da[0]))
{
int sum=0;
rep(i,1,8)
scanf("%d",&da[i]),sum+=abs(i-da[i]);
if(!sum)
{
puts("0");
continue;
}
printf("%d\n",gbool(da));
}
return 0;
}
Compile Error Logs:
You are not authorized to see the message.
Status
Judge: 1/1 C++ CPU: 00.00 sec Memory: 9500 KB Length: 1682 B 2015-03-22 19:41 2015-03-22 19:41
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Accepted 00.00 sec 9500 KB
< prev | 1 / 1 | next > : Accepted 00.00 sec 9500 KB
Judge Input #1 ( in1.txt | 16 B) Judge Output #1 ( out1.txt | 16 B)
In preparation.
In preparation.
Comments
Under Construction.
Categories
Free Tags
| a.cc:95:6: error: stray '#' in program
95 | Case # Verdict CPU Time Memory In Out Case Name
| ^
a.cc:96:6: error: stray '#' in program
96 | Case #1: : Accepted 00.00 sec 9500 KB
| ^
a.cc:100:13: error: stray '#' in program
100 | Judge Input #1 ( in1.txt | 16 B) Judge Output #1 ( out1.txt | 16 B)
| ^
a.cc:100:62: error: stray '#' in program
100 | Judge Input #1 ( in1.txt | 16 B) Judge Output #1 ( out1.txt | 16 B)
| ^
a.cc:89:1: error: 'Compile' does not name a type
89 | Compile Error Logs:
| ^~~~~~~
|
s009355545 | p00121 | C++ | //
// 0121.cpp
//
//
// Created by Yoshida Satoshi on 2017/11/16.
//
//
#include <iostream>
#include <queue>
#include <stdlib.h>
#include <algorithm>
#include <map>
#define INF 100000
using namespace std;
int main(){
int num[8];
queue<vector<int>> que;
vector<int> state={1,0,1,2,3,4,5,6,7};//?????????????´????0??????????????????????????????
vector<int> tmp;
vector<int> next;
vector<int> input;
map<vector<int>, int> depth;
int start;
que.push(state);
depth[state]=0;
while(que.size()){
tmp=que.front(); que.pop();
next=tmp;
if(tmp[i]>4){
next[0]=tmp[i]-4;
swap(next[tmp[i]],next[tmp[i]-4]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[i]<5){
next[0]=tmp[i]+4;
swap(next[tmp[i]],next[tmp[i]+4]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[i]!=4&&tmp[i]!=8){
next[0]=tmp[i]+1;
swap(next[tmp[i]],next[tmp[i]+1]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[i]!=1&&tmp[i]!=5){
next[0]=tmp[i]-1;
swap(next[tmp[i]],next[tmp[i]-1]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
}
while(1){
if((cin>>num[0])==NULL) break;
for(int i=1;i<8;i++) cin>>num[i];
for(int i=0;i<8;i++){
if(num[i]==0) start=i;
}
input.push_back(start);
for(int i=0;i<8;i++) input.push_back(num[i]);
cout<<depth[input]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:36:16: error: 'i' was not declared in this scope
36 | if(tmp[i]>4){
| ^
a.cc:44:16: error: 'i' was not declared in this scope
44 | if(tmp[i]<5){
| ^
a.cc:52:16: error: 'i' was not declared in this scope
52 | if(tmp[i]!=4&&tmp[i]!=8){
| ^
a.cc:60:16: error: 'i' was not declared in this scope
60 | if(tmp[i]!=1&&tmp[i]!=5){
| ^
a.cc:71:25: error: no match for 'operator==' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'long int')
71 | if((cin>>num[0])==NULL) break;
| ^
a.cc:71:25: note: candidate: 'operator==(int, long int)' (built-in)
a.cc:71:25: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:9:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long int'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple |
s211049620 | p00121 | C++ | //
// 0121.cpp
//
//
// Created by Yoshida Satoshi on 2017/11/16.
//
//
#include <iostream>
#include <queue>
#include <stdlib.h>
#include <algorithm>
#include <map>
#define INF 100000
using namespace std;
int main(){
int num[8];
queue<vector<int>> que;
vector<int> state={1,0,1,2,3,4,5,6,7};//?????????????´????0??????????????????????????????
vector<int> tmp;
vector<int> next;
vector<int> input;
map<vector<int>, int> depth;
int start;
que.push(state);
depth[state]=0;
while(que.size()){
tmp=que.front(); que.pop();
next=tmp;
if(tmp[i]>4){
next[0]=tmp[i]-4;
swap(next[tmp[i]],next[tmp[i]-4]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[i]<5){
next[0]=tmp[i]+4;
swap(next[tmp[i]],next[tmp[i]+4]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[i]!=4&&tmp[i]!=8){
next[0]=tmp[i]+1;
swap(next[tmp[i]],next[tmp[i]+1]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[i]!=1&&tmp[i]!=5){
next[0]=tmp[i]-1;
swap(next[tmp[i]],next[tmp[i]-1]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
}
while(1){
if((cin>>num[0])==NULL) break;
for(int i=1;i<8;i++) cin>>num[i];
for(int i=0;i<8;i++){
if(num[i]==0) start=i;
}
input.push_back(start);
for(int i=0;i<8;i++) input.push_back(num[i]);
cout<<depth[input]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:36:16: error: 'i' was not declared in this scope
36 | if(tmp[i]>4){
| ^
a.cc:44:16: error: 'i' was not declared in this scope
44 | if(tmp[i]<5){
| ^
a.cc:52:16: error: 'i' was not declared in this scope
52 | if(tmp[i]!=4&&tmp[i]!=8){
| ^
a.cc:60:16: error: 'i' was not declared in this scope
60 | if(tmp[i]!=1&&tmp[i]!=5){
| ^
a.cc:71:25: error: no match for 'operator==' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'long int')
71 | if((cin>>num[0])==NULL) break;
| ^
a.cc:71:25: note: candidate: 'operator==(int, long int)' (built-in)
a.cc:71:25: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:9:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long int'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple |
s310189259 | p00121 | C++ | //
// 0121.cpp
//
//
// Created by Yoshida Satoshi on 2017/11/16.
//
//
#include <iostream>
#include <queue>
#include <stdlib.h>
#include <algorithm>
#include <map>
#define INF 100000
using namespace std;
int main(){
int num[8];
queue<vector<int> > que;
vector<int> state={1,0,1,2,3,4,5,6,7};//?????????????´????0??????????????????????????????
vector<int> tmp;
vector<int> next;
vector<int> input;
map<vector<int>, int> depth;
int start;
que.push(state);
depth[state]=0;
while(que.size()){
tmp=que.front(); que.pop();
next=tmp;
if(tmp[0]>4){
next[0]=tmp[0]-4;
swap(next[tmp[0]],next[tmp[0]-4]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[0]<5){
next[0]=tmp[0]+4;
swap(next[tmp[0]],next[tmp[0]+4]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[0]!=4&&tmp[0]!=8){
next[0]=tmp[0]+1;
swap(next[tmp[0]],next[tmp[0]+1]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[0]!=1&&tmp[0]!=5){
next[0]=tmp[0]-1;
swap(next[tmp[0]],next[tmp[0]-1]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
}
while(1){
if((cin>>num[0])==NULL) break;
for(int i=1;i<8;i++) cin>>num[i];
for(int i=0;i<8;i++){
if(num[i]==0) start=i;
}
input.push_back(start);
for(int i=0;i<8;i++) input.push_back(num[i]);
cout<<depth[input]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:71:25: error: no match for 'operator==' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'long int')
71 | if((cin>>num[0])==NULL) break;
| ^
a.cc:71:25: note: candidate: 'operator==(int, long int)' (built-in)
a.cc:71:25: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:9:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long int'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file incl |
s662527285 | p00121 | C++ | //
// 0121.cpp
//
//
// Created by Yoshida Satoshi on 2017/11/16.
//
//
#include <iostream>
#include <queue>
#include <stdlib.h>
#include <algorithm>
#include <map>
#define INF 100000
using namespace std;
int main(){
int num[8];
queue<vector<int> > que;
vector<int> state={1,0,1,2,3,4,5,6,7};//?????????????´????0??????????????????????????????
vector<int> tmp;
vector<int> next;
vector<int> input;
map<vector<int>, int> depth;
int start;
que.push(state);
depth[state]=0;
while(que.size()){
tmp=que.front(); que.pop();
next=tmp;
if(tmp[0]>4){
next[0]=tmp[0]-4;
swap(next[tmp[0]],next[tmp[0]-4]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[0]<5){
next[0]=tmp[0]+4;
swap(next[tmp[0]],next[tmp[0]+4]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[0]!=4&&tmp[0]!=8){
next[0]=tmp[0]+1;
swap(next[tmp[0]],next[tmp[0]+1]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
if(tmp[0]!=1&&tmp[0]!=5){
next[0]=tmp[0]-1;
swap(next[tmp[0]],next[tmp[0]-1]);
if(depth.count(next)==0){
depth[next]=depth[tmp]+1;
que.push(next);
}
}
}
while(1){
if((cin>>num[0])==NULL) break;
for(int i=1;i<8;i++) cin>>num[i];
for(int i=0;i<8;i++){
if(num[i]==0) start=i;
}
input.push_back(start);
for(int i=0;i<8;i++) input.push_back(num[i]);
cout<<depth[input]<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:71:25: error: no match for 'operator==' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'long int')
71 | if((cin>>num[0])==NULL) break;
| ^
a.cc:71:25: note: candidate: 'operator==(int, long int)' (built-in)
a.cc:71:25: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:9:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::fpos<_StateT>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::allocator<_CharT>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long int'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3819 | operator==(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2558 | operator==(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed:
a.cc:71:27: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
71 | if((cin>>num[0])==NULL) break;
| ^~~~
In file incl |
s785091869 | p00121 | C++ | #include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
char str[8];
char fin={0,1,2,3,4,5,6,7};
int dir[4]={-1,1,-4,4};
struct stat={
char temp[8];
int num;
stat(char* tt, int nn){
for(int i=0; i<8; i++) temp[i]==tt[i];
num =nn;
}
}
bool equal(char* p1, char* p2){
for(int i=0; i<8; i++){
if(p1[i]!=p2[i]) return false;
}
return true;
}
int bfs(char* s){
queue<stat> q;
q.push(stat(s, 0));
while(q.size()){
stat cur=q.front(); q.pop();
if(equal(cur.temp,fin)) return cur.step;
int zx;
for(int i=0; i<8; i++){ if(cur.temp[i]=='0') {zx=i; break;}}
for(int i=0; i<4; i++){
int nx = zx+dir[i];
if(nx>=0&& nx<8){
char t[8];
strcpy(t, cur.temp);
char a=t[zx]; t[zx]=t[nx]; t[nx]=a;
q.push(stat(t, cur.step+1));
}
}
}
}
int main(){
while(cin>>str){
cout<<bfs(str)<<endl;
}
}
| a.cc:7:6: error: scalar object 'fin' requires one element in initializer
7 | char fin={0,1,2,3,4,5,6,7};
| ^~~
a.cc:10:12: error: expected unqualified-id before '=' token
10 | struct stat={
| ^
a.cc: In function 'int bfs(char*)':
a.cc:27:21: error: invalid use of incomplete type 'struct stat'
27 | q.push(stat(s, 0));
| ^
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
a.cc:30:14: error: variable 'stat cur' has initializer but incomplete type
30 | stat cur=q.front(); q.pop();
| ^~~
a.cc:38:17: error: 'strcpy' was not declared in this scope
38 | strcpy(t, cur.temp);
| ^~~~~~
a.cc:4:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <queue>
+++ |+#include <cstring>
4 | using namespace std;
a.cc:40:42: error: invalid use of incomplete type 'struct stat'
40 | q.push(stat(t, cur.step+1));
| ^
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
In file included from /usr/include/c++/14/deque:66,
from /usr/include/c++/14/queue:62,
from a.cc:3:
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::deque<_Tp, _Alloc>::_M_destroy_data(iterator, iterator, const std::allocator<_CharT>&) [with _Tp = stat; _Alloc = std::allocator<stat>; iterator = std::_Deque_base<stat, std::allocator<stat> >::iterator]':
/usr/include/c++/14/bits/stl_deque.h:1028:24: required from 'std::deque<_Tp, _Alloc>::~deque() [with _Tp = stat; _Alloc = std::allocator<stat>]'
1028 | { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); }
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: required from here
96 | class queue
| ^~~~~
/usr/include/c++/14/bits/stl_deque.h:2094:14: error: invalid use of incomplete type 'std::deque<stat, std::allocator<stat> >::value_type' {aka 'struct stat'}
2094 | if (!__has_trivial_destructor(value_type))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:10:8: note: forward declaration of 'std::deque<stat, std::allocator<stat> >::value_type' {aka 'struct stat'}
10 | struct stat={
| ^~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::deque<_Tp, _Alloc>::pop_front() [with _Tp = stat; _Alloc = std::allocator<stat>]':
/usr/include/c++/14/bits/stl_queue.h:319:13: required from 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >]'
319 | c.pop_front();
| ~~~~~~~~~~~^~
a.cc:30:34: required from here
30 | stat cur=q.front(); q.pop();
| ~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:1578:47: error: invalid use of incomplete type 'struct stat'
1578 | != this->_M_impl._M_start._M_last - 1)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
/usr/include/c++/14/bits/stl_deque.h:1582:38: error: cannot increment a pointer to incomplete type 'stat'
1582 | ++this->_M_impl._M_start._M_cur;
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::_Deque_base<_Tp, _Alloc>::_M_initialize_map(std::size_t) [with _Tp = stat; _Alloc = std::allocator<stat>; std::size_t = long unsigned int]':
/usr/include/c++/14/bits/stl_deque.h:460:9: required from 'std::_Deque_base<_Tp, _Alloc>::_Deque_base() [with _Tp = stat; _Alloc = std::allocator<stat>]'
460 | { _M_initialize_map(0); }
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:855:7: required from 'std::queue<_Tp, _Sequence>::queue() [with _Seq = std::deque<stat, std::allocator<stat> >; _Requires = void; _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >]'
855 | deque() = default;
| ^~~~~
a.cc:26:17: required from here
26 | queue<stat> q;
| ^
/usr/include/c++/14/bits/stl_deque.h:641:69: error: invalid application of 'sizeof' to incomplete type 'stat'
641 | const size_t __num_nodes = (__num_elements / __deque_buf_size(sizeof(_Tp))
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:672:60: error: invalid application of 'sizeof' to incomplete type 'stat'
672 | % __deque_buf_size(sizeof(_Tp)));
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'std::_Deque_iterator<stat, stat&, stat*>::difference_type std::operator-(const _Deque_iterator<stat, stat&, stat*>::_Self&, const _Deque_iterator<stat, stat&, stat*>::_Self&)':
/usr/include/c++/14/bits/stl_deque.h:1269:40: required from 'std::deque<_Tp, _Alloc>::size_type std::deque<_Tp, _Alloc>::size() const [with _Tp = stat; _Alloc = std::allocator<stat>; size_type = long unsigned int]'
1269 | { return this->_M_impl._M_finish - this->_M_impl._M_start; }
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:223:22: required from 'std::queue<_Tp, _Sequence>::size_type std::queue<_Tp, _Sequence>::size() const [with _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >; size_type = long unsigned int]'
223 | { return c.size(); }
| ~~~~~~^~
a.cc:29:17: required from here
29 | while(q.size()){
| ~~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:374:25: error: invalid use of incomplete type 'struct stat'
374 | + (__x._M_cur - __x._M_first)
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
/usr/include/c++/14/bits/stl_deque.h:375:26: error: invalid use of incomplete type 'struct stat'
375 | + (__y._M_last - __y._M_cur);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::_Deque_base<_Tp, _Alloc>::_M_deallocate_node(_Ptr) [with _Tp = stat; _Alloc = std::allocator<stat>; _Ptr = stat*]':
/usr/include/c++/14/bits/stl_deque.h:700:2: required from 'void std::_Deque_base<_Tp, _Alloc>::_M_destroy_nodes(_Map_pointer, _Map_pointer) [with _Tp = stat; _Alloc = std::allocator<stat>; _Map_pointer = stat**]'
700 | _M_deallocate_node(*__n);
| ^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:622:4: required from 'std::_Deque_base<_Tp, _Alloc>::~_Deque_base() [with _Tp = stat; _Alloc = std::allocator<stat>]'
622 | _M_destroy_nodes(this->_M_impl._M_start._M_node,
| ^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:855:7: required from 'std::queue<_Tp, _Sequence>::queue() [with _Seq = std::deque<stat, std::allocator<stat> >; _Requires = void; _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >]'
855 | deque() = default;
| ^~~~~
a.cc:26:17: required from here
26 | queue<stat> q;
| ^
/usr/include/c++/14/bits/stl_deque.h:590:60: error: invalid application of 'sizeof' to incomplete type 'stat'
590 | _Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp)));
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'static std::size_t std::_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size() [with _Tp = stat; _Ref = stat&; _Ptr = stat*; std::size_t = long unsigned int]':
/usr/include/c++/14/bits/stl_deque.h:372:39: required from 'std::_Deque_iterator<stat, stat&, stat*>::difference_type std::operator-(const _Deque_iterator<stat, stat&, stat*>::_Self&, const _Deque_iterator<stat, stat&, stat*>::_Self&)'
372 | return difference_type(_S_buffer_size())
| ~~~~~~~~~~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:1269:40: required from 'std::deque<_Tp, _Alloc>::size_type std::deque<_Tp, _Alloc>::size() const [with _Tp = stat; _Alloc = std::allocator<stat>; size_type = long unsigned int]'
1269 | { return this->_M_impl._M_finish - this->_M_impl._M_start; }
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:223:22: required from 'std::queue<_Tp, _Sequence>::size_type std::queue<_Tp, _Sequence>::size() const [with _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >; size_type = long unsigned int]'
223 | { return c.size(); }
| ~~~~~~^~
a.cc:29:17: required from here
29 | while(q.size()){
| ~~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:132:33: error: invalid application of 'sizeof' to incomplete type 'stat'
132 | { return __deque_buf_size(sizeof(_Tp)); }
| ^~~~~~~~~~~
|
s883668402 | p00121 | C++ | #include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
char str[8];
char fin[8]={0,1,2,3,4,5,6,7};
int dir[4]={-1,1,-4,4};
struct stat={
char temp[8];
int num;
stat(char* tt, int nn){
for(int i=0; i<8; i++) temp[i]==tt[i];
num =nn;
}
}
bool equal(char* p1, char* p2){
for(int i=0; i<8; i++){
if(p1[i]!=p2[i]) return false;
}
return true;
}
int bfs(char* s){
queue<stat> q;
q.push(stat(s, 0));
while(q.size()){
stat cur=q.front(); q.pop();
if(equal(cur.temp,fin)) return cur.step;
int zx;
for(int i=0; i<8; i++){ if(cur.temp[i]=='0') {zx=i; break;}}
for(int i=0; i<4; i++){
int nx = zx+dir[i];
if(nx>=0&& nx<8){
char t[8];
strcpy(t, cur.temp);
char a=t[zx]; t[zx]=t[nx]; t[nx]=a;
q.push(stat(t, cur.step+1));
}
}
}
}
int main(){
while(cin>>str){
cout<<bfs(str)<<endl;
}
}
| a.cc:10:12: error: expected unqualified-id before '=' token
10 | struct stat={
| ^
a.cc: In function 'int bfs(char*)':
a.cc:27:21: error: invalid use of incomplete type 'struct stat'
27 | q.push(stat(s, 0));
| ^
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
a.cc:30:14: error: variable 'stat cur' has initializer but incomplete type
30 | stat cur=q.front(); q.pop();
| ^~~
a.cc:38:17: error: 'strcpy' was not declared in this scope
38 | strcpy(t, cur.temp);
| ^~~~~~
a.cc:4:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <queue>
+++ |+#include <cstring>
4 | using namespace std;
a.cc:40:42: error: invalid use of incomplete type 'struct stat'
40 | q.push(stat(t, cur.step+1));
| ^
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
In file included from /usr/include/c++/14/deque:66,
from /usr/include/c++/14/queue:62,
from a.cc:3:
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::deque<_Tp, _Alloc>::_M_destroy_data(iterator, iterator, const std::allocator<_CharT>&) [with _Tp = stat; _Alloc = std::allocator<stat>; iterator = std::_Deque_base<stat, std::allocator<stat> >::iterator]':
/usr/include/c++/14/bits/stl_deque.h:1028:24: required from 'std::deque<_Tp, _Alloc>::~deque() [with _Tp = stat; _Alloc = std::allocator<stat>]'
1028 | { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); }
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:96:11: required from here
96 | class queue
| ^~~~~
/usr/include/c++/14/bits/stl_deque.h:2094:14: error: invalid use of incomplete type 'std::deque<stat, std::allocator<stat> >::value_type' {aka 'struct stat'}
2094 | if (!__has_trivial_destructor(value_type))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:10:8: note: forward declaration of 'std::deque<stat, std::allocator<stat> >::value_type' {aka 'struct stat'}
10 | struct stat={
| ^~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::deque<_Tp, _Alloc>::pop_front() [with _Tp = stat; _Alloc = std::allocator<stat>]':
/usr/include/c++/14/bits/stl_queue.h:319:13: required from 'void std::queue<_Tp, _Sequence>::pop() [with _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >]'
319 | c.pop_front();
| ~~~~~~~~~~~^~
a.cc:30:34: required from here
30 | stat cur=q.front(); q.pop();
| ~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:1578:47: error: invalid use of incomplete type 'struct stat'
1578 | != this->_M_impl._M_start._M_last - 1)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
/usr/include/c++/14/bits/stl_deque.h:1582:38: error: cannot increment a pointer to incomplete type 'stat'
1582 | ++this->_M_impl._M_start._M_cur;
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::_Deque_base<_Tp, _Alloc>::_M_initialize_map(std::size_t) [with _Tp = stat; _Alloc = std::allocator<stat>; std::size_t = long unsigned int]':
/usr/include/c++/14/bits/stl_deque.h:460:9: required from 'std::_Deque_base<_Tp, _Alloc>::_Deque_base() [with _Tp = stat; _Alloc = std::allocator<stat>]'
460 | { _M_initialize_map(0); }
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:855:7: required from 'std::queue<_Tp, _Sequence>::queue() [with _Seq = std::deque<stat, std::allocator<stat> >; _Requires = void; _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >]'
855 | deque() = default;
| ^~~~~
a.cc:26:17: required from here
26 | queue<stat> q;
| ^
/usr/include/c++/14/bits/stl_deque.h:641:69: error: invalid application of 'sizeof' to incomplete type 'stat'
641 | const size_t __num_nodes = (__num_elements / __deque_buf_size(sizeof(_Tp))
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:672:60: error: invalid application of 'sizeof' to incomplete type 'stat'
672 | % __deque_buf_size(sizeof(_Tp)));
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'std::_Deque_iterator<stat, stat&, stat*>::difference_type std::operator-(const _Deque_iterator<stat, stat&, stat*>::_Self&, const _Deque_iterator<stat, stat&, stat*>::_Self&)':
/usr/include/c++/14/bits/stl_deque.h:1269:40: required from 'std::deque<_Tp, _Alloc>::size_type std::deque<_Tp, _Alloc>::size() const [with _Tp = stat; _Alloc = std::allocator<stat>; size_type = long unsigned int]'
1269 | { return this->_M_impl._M_finish - this->_M_impl._M_start; }
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:223:22: required from 'std::queue<_Tp, _Sequence>::size_type std::queue<_Tp, _Sequence>::size() const [with _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >; size_type = long unsigned int]'
223 | { return c.size(); }
| ~~~~~~^~
a.cc:29:17: required from here
29 | while(q.size()){
| ~~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:374:25: error: invalid use of incomplete type 'struct stat'
374 | + (__x._M_cur - __x._M_first)
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
/usr/include/c++/14/bits/stl_deque.h:375:26: error: invalid use of incomplete type 'struct stat'
375 | + (__y._M_last - __y._M_cur);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~
a.cc:10:8: note: forward declaration of 'struct stat'
10 | struct stat={
| ^~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'void std::_Deque_base<_Tp, _Alloc>::_M_deallocate_node(_Ptr) [with _Tp = stat; _Alloc = std::allocator<stat>; _Ptr = stat*]':
/usr/include/c++/14/bits/stl_deque.h:700:2: required from 'void std::_Deque_base<_Tp, _Alloc>::_M_destroy_nodes(_Map_pointer, _Map_pointer) [with _Tp = stat; _Alloc = std::allocator<stat>; _Map_pointer = stat**]'
700 | _M_deallocate_node(*__n);
| ^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:622:4: required from 'std::_Deque_base<_Tp, _Alloc>::~_Deque_base() [with _Tp = stat; _Alloc = std::allocator<stat>]'
622 | _M_destroy_nodes(this->_M_impl._M_start._M_node,
| ^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:855:7: required from 'std::queue<_Tp, _Sequence>::queue() [with _Seq = std::deque<stat, std::allocator<stat> >; _Requires = void; _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >]'
855 | deque() = default;
| ^~~~~
a.cc:26:17: required from here
26 | queue<stat> q;
| ^
/usr/include/c++/14/bits/stl_deque.h:590:60: error: invalid application of 'sizeof' to incomplete type 'stat'
590 | _Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp)));
| ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h: In instantiation of 'static std::size_t std::_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size() [with _Tp = stat; _Ref = stat&; _Ptr = stat*; std::size_t = long unsigned int]':
/usr/include/c++/14/bits/stl_deque.h:372:39: required from 'std::_Deque_iterator<stat, stat&, stat*>::difference_type std::operator-(const _Deque_iterator<stat, stat&, stat*>::_Self&, const _Deque_iterator<stat, stat&, stat*>::_Self&)'
372 | return difference_type(_S_buffer_size())
| ~~~~~~~~~~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:1269:40: required from 'std::deque<_Tp, _Alloc>::size_type std::deque<_Tp, _Alloc>::size() const [with _Tp = stat; _Alloc = std::allocator<stat>; size_type = long unsigned int]'
1269 | { return this->_M_impl._M_finish - this->_M_impl._M_start; }
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:223:22: required from 'std::queue<_Tp, _Sequence>::size_type std::queue<_Tp, _Sequence>::size() const [with _Tp = stat; _Sequence = std::deque<stat, std::allocator<stat> >; size_type = long unsigned int]'
223 | { return c.size(); }
| ~~~~~~^~
a.cc:29:17: required from here
29 | while(q.size()){
| ~~~~~~^~
/usr/include/c++/14/bits/stl_deque.h:132:33: error: invalid application of 'sizeof' to incomplete type 'stat'
132 | { return __deque_buf_size(sizeof(_Tp)); }
| ^~~~~~~~~~~
|
s308153632 | p00121 | C++ | #include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
char str[8];
char fin[8]={0,1,2,3,4,5,6,7};
int dir[4]={-1,1,-4,4};
struct stat{
char temp[8];
int num;
stat(char* tt, int nn){
for(int i=0; i<8; i++) temp[i]==tt[i];
num =nn;
}
}
bool equal(char* p1, char* p2){
for(int i=0; i<8; i++){
if(p1[i]!=p2[i]) return false;
}
return true;
}
int bfs(char* s){
queue<stat> q;
q.push(stat(s, 0));
while(q.size()){
stat cur=q.front(); q.pop();
if(equal(cur.temp,fin)) return cur.step;
int zx;
for(int i=0; i<8; i++){ if(cur.temp[i]=='0') {zx=i; break;}}
for(int i=0; i<4; i++){
int nx = zx+dir[i];
if(nx>=0&& nx<8){
char t[8];
strcpy(t, cur.temp);
char a=t[zx]; t[zx]=t[nx]; t[nx]=a;
q.push(stat(t, cur.step+1));
}
}
}
}
int main(){
while(cin>>str){
cout<<bfs(str)<<endl;
}
}
| a.cc:17:2: error: expected ';' after struct definition
17 | }
| ^
| ;
a.cc: In function 'int bfs(char*)':
a.cc:31:44: error: 'struct stat' has no member named 'step'
31 | if(equal(cur.temp,fin)) return cur.step;
| ^~~~
a.cc:38:17: error: 'strcpy' was not declared in this scope
38 | strcpy(t, cur.temp);
| ^~~~~~
a.cc:4:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <queue>
+++ |+#include <cstring>
4 | using namespace std;
a.cc:40:36: error: 'struct stat' has no member named 'step'
40 | q.push(stat(t, cur.step+1));
| ^~~~
|
s714571112 | p00121 | C++ | #include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
char str[8];
char fin[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
int dir[4] = { -1, 1, -4, 4 };
struct point{
char temp[8];
int num;
point(char* tt, int nn){
strcpy(temp, tt);
num = nn;
}
};
bool equal(char* p1, char* p2){
for (int i = 0; i<8; i++){
if (p1[i] != p2[i]) return false;
}
return true;
}
int bfs(char* s){
queue<point> q;
q.push(point(s, 0));
while (q.size()){
point cur = q.front(); q.pop();
if (equal(cur.temp, fin)) return cur.num;
int zx;
for (int i = 0; i<8; i++){ if (cur.temp[i] == '0') { zx = i; break; } }
for (int i = 0; i<4; i++){
int nx = zx + dir[i];
if (nx >= 0 && nx<8){
char t[8];
strcpy(t, cur.temp);
char a = t[zx]; t[zx] = t[nx]; t[nx] = a;
q.push(point(t, cur.num + 1));
}
}
}
}
int main(){
while (cin >> str){
cout << bfs(str) << endl;
}
}
| a.cc: In constructor 'point::point(char*, int)':
a.cc:14:17: error: 'strcpy' was not declared in this scope
14 | strcpy(temp, tt);
| ^~~~~~
a.cc:4:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <queue>
+++ |+#include <cstring>
4 | using namespace std;
a.cc: In function 'int bfs(char*)':
a.cc:39:33: error: 'strcpy' was not declared in this scope
39 | strcpy(t, cur.temp);
| ^~~~~~
a.cc:39:33: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
a.cc:45:1: warning: control reaches end of non-void function [-Wreturn-type]
45 | }
| ^
|
s249628822 | p00121 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
map<string, int> dp;
int dx[4]={-1, 1, 4, -4};
void bfs(){
string now="01234567";
dp[now]=0;
queue<string> q;
q.push(now);
while(q.size()){
now=q.front(); q.pop();
int z;
for(int i=0; i<8; i++)
if(now[i]=='0') z=i;
for(int i=0; i<4; i++){
int n=z+dx[i];
if(n>=0&& n<8 &&(!(z==3&&i==1))&&(!(z==4&&i==0))){
string next=now;
swap(next[n], next[z]);
if(dp.find(next)==dp.end()){
dp[next]=dp[now]+1;
q.push(next);
}
}
}
}
}
int main(){
bfs();
string line;
while(getline(cin, line)){
line.erase(remove(line.begin(), line.end(), " "), line.end());
cout<<dp[line]<<endl;
}
}
| In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_equals_val<_Value>::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; _Value = const char [2]]':
/usr/include/c++/14/bits/stl_algobase.h:2180:13: required from '_ForwardIterator std::__remove_if(_ForwardIterator, _ForwardIterator, _Predicate) [with _ForwardIterator = __gnu_cxx::__normal_iterator<char*, __cxx11::basic_string<char> >; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const char [2]>]'
2180 | if (!__pred(__first))
| ~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:798:30: required from '_FIter std::remove(_FIter, _FIter, const _Tp&) [with _FIter = __gnu_cxx::__normal_iterator<char*, __cxx11::basic_string<char> >; _Tp = char [2]]'
798 | return std::__remove_if(__first, __last,
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
799 | __gnu_cxx::__ops::__iter_equals_val(__value));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:39:26: required from here
39 | line.erase(remove(line.begin(), line.end(), " "), line.end());
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:270:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
270 | { return *__it == _M_value; }
| ~~~~~~^~~~~~~~~~~
|
s538393946 | p00121 | C++ | #include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main(){_
map<string,int> vis;
map<string,int> step;
queue<string> qu;
vis["01234567"] = 1;
step["01234567"] = 0;
qu.push("01234567");
while(!qu.empty()){
string now = qu.front();
qu.pop();
int poi;
for(int i = 0; i < 8; i++)
if(now[i] == '0'){
poi = i;
break;
}
if(poi >= 0 && poi <= 3){ //down
string next = now;
int pl = next[poi];
next[poi] = next[poi + 4];
next[poi + 4] = pl;
if(!vis[next]){
qu.push(next);
step[next] = step[now] + 1;
vis[next] = 1;
}
}
if(poi >= 4 && poi <= 7){ //up
string next = now;
int pl = next[poi];
next[poi] = next[poi - 4];
next[poi - 4] = pl;
if(!vis[next]){
qu.push(next);
step[next] = step[now] + 1;
vis[next] = 1;
}
}
if(poi % 4 != 0){ //left
string next = now;
int pl = next[poi];
next[poi] = next[poi - 1];
next[poi - 1] = pl;
if(!vis[next]){
qu.push(next);
step[next] = step[now] + 1;
vis[next] = 1;
}
}
if(poi % 4 != 3){ //right
string next = now;
int pl = next[poi];
next[poi] = next[poi + 1];
next[poi + 1] = pl;
if(!vis[next]){
qu.push(next);
step[next] = step[now] + 1;
vis[next] = 1;
}
}
}
//
char ch[20];
while(gets(ch)){
for(int i = 0; i <15; i++)
ch[i] = ch[i*2];
ch[8] = '\0';
string str = ch;
printf("%d\n",step[str]);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:67:11: error: 'gets' was not declared in this scope; did you mean 'getw'?
67 | while(gets(ch)){
| ^~~~
| getw
|
s995650488 | p00121 | C++ | #include <iostream>
#include <unordered_map>
#include <queue>
int a[2][4] , stx , sty , nx;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
std::unordered_map <int , int> st;
struct node{
int x;
int step;
};
void fx(int y){
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
a[i][j] = y % 8;
y = (int)(y / 8);
if(a[i][j] == 0){
stx = j , sty = i;
}
}
}
}
bool f(int k){
if(stx + dirc[k][0] < 0 || stx + dirc[k][0] >= 4 || sty + dirc[k][1] < 0 || sty + dirc[k][1] >= 2){
return false;
}
nx = 0;
int tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
if(i == sty && j == stx){
nx += tmp * a[sty + dirc[k][1]][stx + dirc[k][0]];
}else if(i == sty + dirc[k][1] && j == stx + dirc[k][0]){
nx += 0;
}else{
nx += tmp * a[i][j];
}
tmp *= 8;
}
}
return true;
}
int main(){
st.insert(std::make_pair<int , int>(16434824 , 0));
node nod;
nod.x = 16434824 , nod.step = 0;
std::queue <node> que;
que.push(nod);
while(!que.empty()){
nod = que.front();
que.pop();
fx(nod.x);
for(int i = 0;i < 4;i++){
if(f(i)){
if(st.find(nx) == st.end()){
st.insert(std::make_pair<int , int>(nx , nod.step + 1));
node nod1;
nod1.x = nx , nod1.step = nod.step + 1;
que.push(nod1);
}
}
}
}
while(std::cin >>a[0][0]>>a[0][1]>>a[0][2]>>a[0][3]>>a[1][0]>>a[1][1]>>a[1][2]>>a[1][3]){
int mark = 0 , tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
mark += tmp * a[i][j];
tmp *= 8;
}
}
std::cout << st[mark] << "\n";
}
}
| a.cc: In function 'int main()':
a.cc:55:57: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
55 | st.insert(std::make_pair<int , int>(nx , nod.step + 1));
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s664968250 | p00121 | C++ | #include <iostream>
#include <unordered_map>
#include <queue>
#include <utility>
int a[2][4] , stx , sty , nx;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
std::unordered_map <int , int> st;
struct node{
int x;
int step;
};
void fx(int y){
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
a[i][j] = y % 8;
y = (int)(y / 8);
if(a[i][j] == 0){
stx = j , sty = i;
}
}
}
}
bool f(int k){
if(stx + dirc[k][0] < 0 || stx + dirc[k][0] >= 4 || sty + dirc[k][1] < 0 || sty + dirc[k][1] >= 2){
return false;
}
nx = 0;
int tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
if(i == sty && j == stx){
nx += tmp * a[sty + dirc[k][1]][stx + dirc[k][0]];
}else if(i == sty + dirc[k][1] && j == stx + dirc[k][0]){
nx += 0;
}else{
nx += tmp * a[i][j];
}
tmp *= 8;
}
}
return true;
}
int main(){
st.insert(std::make_pair<int , int>(16434824 , 0));
node nod;
nod.x = 16434824 , nod.step = 0;
std::queue <node> que;
que.push(nod);
while(!que.empty()){
nod = que.front();
que.pop();
fx(nod.x);
for(int i = 0;i < 4;i++){
if(f(i)){
if(st.find(nx) == st.end()){
st.insert(std::make_pair<int , int>(nx , nod.step + 1));
node nod1;
nod1.x = nx , nod1.step = nod.step + 1;
que.push(nod1);
}
}
}
}
while(std::cin >>a[0][0]>>a[0][1]>>a[0][2]>>a[0][3]>>a[1][0]>>a[1][1]>>a[1][2]>>a[1][3]){
int mark = 0 , tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
mark += tmp * a[i][j];
tmp *= 8;
}
}
std::cout << st[mark] << "\n";
}
}
| a.cc: In function 'int main()':
a.cc:56:57: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
56 | st.insert(std::make_pair<int , int>(nx , nod.step + 1));
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s604701178 | p00121 | C++ | #include <iostream>
#include <unordered_map>
#include <queue>
#include <utility>
#include <functional>
int a[2][4] , stx , sty , nx;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
std::unordered_map <int , int> st;
struct node{
int x;
int step;
};
void fx(int y){
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
a[i][j] = y % 8;
y = (int)(y / 8);
if(a[i][j] == 0){
stx = j , sty = i;
}
}
}
}
bool f(int k){
if(stx + dirc[k][0] < 0 || stx + dirc[k][0] >= 4 || sty + dirc[k][1] < 0 || sty + dirc[k][1] >= 2){
return false;
}
nx = 0;
int tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
if(i == sty && j == stx){
nx += tmp * a[sty + dirc[k][1]][stx + dirc[k][0]];
}else if(i == sty + dirc[k][1] && j == stx + dirc[k][0]){
nx += 0;
}else{
nx += tmp * a[i][j];
}
tmp *= 8;
}
}
return true;
}
int main(){
st.insert(std::make_pair<int , int>(16434824 , 0));
node nod;
nod.x = 16434824 , nod.step = 0;
std::queue <node> que;
que.push(nod);
while(!que.empty()){
nod = que.front();
que.pop();
fx(nod.x);
for(int i = 0;i < 4;i++){
if(f(i)){
if(st.find(nx) == st.end()){
st.insert(std::make_pair<int , int>(nx , nod.step + 1));
node nod1;
nod1.x = nx , nod1.step = nod.step + 1;
que.push(nod1);
}
}
}
}
while(std::cin >>a[0][0]>>a[0][1]>>a[0][2]>>a[0][3]>>a[1][0]>>a[1][1]>>a[1][2]>>a[1][3]){
int mark = 0 , tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
mark += tmp * a[i][j];
tmp *= 8;
}
}
std::cout << st[mark] << "\n";
}
}
| a.cc: In function 'int main()':
a.cc:58:57: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
58 | st.insert(std::make_pair<int , int>(nx , nod.step + 1));
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s985564634 | p00121 | C++ | #include <iostream>
#include <unordered_map>
#include <queue>
#include <utility>
#include <functional>
int a[2][4] , stx , sty , nx;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
std::unordered_map <int , int> st;
struct node{
int x;
int step;
};
void fx(int y){
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
a[i][j] = y % 8;
y = (int)(y / 8);
if(a[i][j] == 0){
stx = j , sty = i;
}
}
}
}
bool f(int k){
if(stx + dirc[k][0] < 0 || stx + dirc[k][0] >= 4 || sty + dirc[k][1] < 0 || sty + dirc[k][1] >= 2){
return false;
}
nx = 0;
int tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
if(i == sty && j == stx){
nx += tmp * a[sty + dirc[k][1]][stx + dirc[k][0]];
}else if(i == sty + dirc[k][1] && j == stx + dirc[k][0]){
nx += 0;
}else{
nx += tmp * a[i][j];
}
tmp *= 8;
}
}
return true;
}
int main(){
st.insert(std::make_pair<int , int>(16434824 , 0));
node nod;
nod.x = 16434824 , nod.step = 0;
std::queue <node> que;
que.push(nod);
while(!que.empty()){
nod = que.front();
que.pop();
fx(nod.x);
for(int i = 0;i < 4;i++){
if(f(i)){
if(st.find(nx) == st.end()){
st.insert(std::make_pair<int , int>(nx , nod.step + 1));
node nod1;
nod1.x = nx , nod1.step = nod.step + 1;
que.push(nod1);
}
}
}
}
while(std::cin >>a[0][0]>>a[0][1]>>a[0][2]>>a[0][3]>>a[1][0]>>a[1][1]>>a[1][2]>>a[1][3]){
int mark = 0 , tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
mark += tmp * a[i][j];
tmp *= 8;
}
}
std::cout << st[mark] << "\n";
}
}
| a.cc: In function 'int main()':
a.cc:58:57: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
58 | st.insert(std::make_pair<int , int>(nx , nod.step + 1));
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s288958306 | p00121 | C++ | #include <iostream>
#include <unordered_map>
#include <queue>
#include <utility>
#include <functional>
int a[2][4] , stx , sty , nx;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
std::unordered_map <int , int> st;
struct node{
int x;
int step;
};
void fx(int y){
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
a[i][j] = y % 8;
y = (int)(y / 8);
if(a[i][j] == 0){
stx = j , sty = i;
}
}
}
}
bool f(int k){
if(stx + dirc[k][0] < 0 || stx + dirc[k][0] >= 4 || sty + dirc[k][1] < 0 || sty + dirc[k][1] >= 2){
return false;
}
nx = 0;
int tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
if(i == sty && j == stx){
nx += tmp * a[sty + dirc[k][1]][stx + dirc[k][0]];
}else if(i == sty + dirc[k][1] && j == stx + dirc[k][0]){
nx += 0;
}else{
nx += tmp * a[i][j];
}
tmp *= 8;
}
}
return true;
}
int main(){
st.insert(std::make_pair<int , int>(16434824 , 0));
node nod;
nod.x = 16434824 , nod.step = 0;
std::queue <node> que;
que.push(nod);
while(!que.empty()){
nod = que.front();
que.pop();
fx(nod.x);
for(int i = 0;i < 4;i++){
if(f(i)){
if(st.find(nx) == st.end()){
st.insert(std::make_pair<int , int>(nx , nod.step + 1));
node nod1;
nod1.x = nx , nod1.step = nod.step + 1;
que.push(nod1);
}
}
}
}
while(std::cin >>a[0][0]>>a[0][1]>>a[0][2]>>a[0][3]>>a[1][0]>>a[1][1]>>a[1][2]>>a[1][3]){
int mark = 0 , tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
mark += tmp * a[i][j];
tmp *= 8;
}
}
std::cout << st[mark] << "\n";
}
}
| a.cc: In function 'int main()':
a.cc:58:57: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
58 | st.insert(std::make_pair<int , int>(nx , nod.step + 1));
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s530165105 | p00121 | C++ | #include <iostream>
#include <unordered_map>
#include <queue>
#include <utility>
#include <functional>
int a[2][4] , stx , sty , nx;
int dirc[4][2] = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
std::unordered_map <int , int> st;
struct node{
int x;
int step;
};
void fx(int y){
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
a[i][j] = y % 8;
y = (int)(y / 8);
if(a[i][j] == 0){
stx = j , sty = i;
}
}
}
}
bool f(int k){
if(stx + dirc[k][0] < 0 || stx + dirc[k][0] >= 4 || sty + dirc[k][1] < 0 || sty + dirc[k][1] >= 2){
return false;
}
nx = 0;
int tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
if(i == sty && j == stx){
nx += tmp * a[sty + dirc[k][1]][stx + dirc[k][0]];
}else if(i == sty + dirc[k][1] && j == stx + dirc[k][0]){
nx += 0;
}else{
nx += tmp * a[i][j];
}
tmp *= 8;
}
}
return true;
}
int main(){
st.insert(std::make_pair<int , int>(16434824 , 0));
node nod;
nod.x = 16434824 , nod.step = 0;
std::queue <node> que;
que.push(nod);
while(!que.empty()){
nod = que.front();
que.pop();
fx(nod.x);
for(int i = 0;i < 4;i++){
if(f(i)){
if(st.find(nx) == st.end()){
st.insert(std::make_pair<int , int>(nx , nod.step + 1));
node nod1;
nod1.x = nx , nod1.step = nod.step + 1;
que.push(nod1);
}
}
}
}
while(std::cin >>a[0][0]>>a[0][1]>>a[0][2]>>a[0][3]>>a[1][0]>>a[1][1]>>a[1][2]>>a[1][3]){
int mark = 0 , tmp = 1;
for(int i = 0;i < 2;i++){
for(int j = 0;j < 4;j++){
mark += tmp * a[i][j];
tmp *= 8;
}
}
std::cout << st.at(mark) << "\n";
}
}
| a.cc: In function 'int main()':
a.cc:58:57: error: cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
58 | st.insert(std::make_pair<int , int>(nx , nod.step + 1));
| ^~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = int; _T2 = int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = int; typename decay<_Tp>::type = int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = int; typename decay<_Tp2>::type = int]'
1132 | make_pair(_T1&& __x, _T2&& __y)
| ~~~~~~^~~
|
s364783208 | p00121 | C++ | #include <iostream>
#include <map>
#include <queue>
#include <string>
using namespace std;
map<string, int> res;
int d[4] = {1, -1, 4, -4};
void bfs() {
queue<string> que;
que.push("01234567");
res["01234567"] = 0;
while (!que.empty()) {
string s = que.front();
que.pop();
int pos = 0;
while (s[pos] != '0') pos++;
for (int i = 0; i < 4; i++) {
int npos = pos + d[i];
if (0 <= npos && npos < 8 && !(npos == 3 && i == 0) &&
!(npos == 4 && i == 1)) {
string ns = s;
swap(ns[pos], ns[npos]);
if (res.find(ns) == res.end()) {
res[ns] = res[s] + 1;
que.push(ns);
}
}
}
}
}
int main() {
bfs();
string line;
while (getline(cin, line)) {
line.erase(remove(line.begin(), line.end(), ' '),
line.end()); // remove white spaces
cout << res[line] << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:37:33: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'const char*'
37 | line.erase(remove(line.begin(), line.end(), ' '),
| ~~~~~~~~~~^~
| |
| std::__cxx11::basic_string<char>::iterator
In file included from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdio.h:158:32: note: initializing argument 1 of 'int remove(const char*)'
158 | extern int remove (const char *__filename) __THROW;
| ~~~~~~~~~~~~^~~~~~~~~~
|
s511953644 | p00121 | C++ | #include<stdio.h>
#include<queue>
#include<bitset>
using namespace std;
const int N = 8;
const int SHIFT_BITS = 3;
unsigned Swap3Bits(unsigned x, int b1, int b2)
{
unsigned a,b,s;
b1 *= SHIFT_BITS;
b2 *= SHIFT_BITS;
a = (x& (07<<b1));
b = (x& (07<<b2));
s = (a>>b1<<b2) | (b>>b2<<b1);
return (x&~a&~b)|s;
}
int Ans(int initField)
{
int ans, i;
unsigned field;
set<unsigned> his;
static bitset<16777216> bitHis;
queue<unsigned> q;
unsigned int NEXT_COUNT = 0xffffffff;
ans = 0;
bitHis.reset();
q.push(initField);
q.push(NEXT_COUNT);
for(;;)
{
field = q.front();
q.pop();
if(field == NEXT_COUNT)
{
++ans;
q.push(NEXT_COUNT);
continue;
}
if(bitHis[field])
continue;
if(field == 001234567)
break;
bitHis[field] = true;
int zi = 0;
for(i = 0; i < N; ++i)
{
if( (field & (07<<i*SHIFT_BITS)) == 00)
{
zi = i;
break;
}
}
q.push( Swap3Bits(field, zi, (zi<4?zi+4:zi-4)) );
if((zi&0x3) != 0x3)
q.push( Swap3Bits(field, zi, zi+1) );
if((zi&0x3) != 0x0)
q.push( Swap3Bits(field, zi,zi-1) );
}
return ans;
}
int main(void)
{
int a[N], i;
for(;;)
{
unsigned field = 0;
for(i = 0; i < N; ++i)
{
if(scanf("%d",&a[i])!=1) return 0;
field |= (a[i] << ( (N-i-1)*SHIFT_BITS) );
}
printf("%d\n",Ans(field));
}
return 1;
} | a.cc: In function 'int Ans(int)':
a.cc:24:9: error: 'set' was not declared in this scope
24 | set<unsigned> his;
| ^~~
a.cc:4:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
3 | #include<bitset>
+++ |+#include <set>
4 | using namespace std;
a.cc:24:13: error: expected primary-expression before 'unsigned'
24 | set<unsigned> his;
| ^~~~~~~~
|
s079145281 | p00121 | C++ | #include <iostream>
#include <queue>
#include <string>
#include <set>
#include <map>
using namespace std;
map<string, int> stoi;
map<int, string> itos;
int solve(string str){
bool dp[30][40320];
dp[0][stoi[str]] = true;
for(int i=0;i<30;i++){
for(int j=0;j<40320;j++){
if(!dp[i][j]) continue;
if(j==0) return i;
string str = itos[j];
for(int k=0;k<8;k++){
string tmp;
if(str[k] != '0') continue;
if(k!=0 && k!=4){
tmp = str;
swap(tmp[k], tmp[k-1]);
dp[i+1][stoi[tmp]] = true;
}
if(k!=7 && k!=3){
v.str = u.str;
swap(tmp[k], tmp[k+1]);
dp[i+1][stoi[tmp]] = true;
}
v.str = u.str;
if(k<4){
swap(tmp[k], tmp[k+4]);
dp[i+1][stoi[tmp]] = true;
}else{
swap(tmp[k], tmp[k-4]);
dp[i+1][stoi[tmp]] = true;
}
}
}
}
return 0;
}
/*class State{
public:
string str;
int cnt;
};
int bfs(string str){
State u, v;
u.str = str;
u.cnt = 0;
queue<State> Q;
Q.push(u);
set<string> vis;
vis.insert(u.str);
while(!Q.empty()){
u = Q.front(); Q.pop();
if(u.str == "01234567") return u.cnt;
v.cnt = u.cnt + 1;
for(int i=0;i<8;i++){
if(u.str[i] != '0') continue;
if(i!=0 && i!=4){
v.str = u.str;
swap(v.str[i], v.str[i-1]);
if(vis.find(v.str)==vis.end()){
vis.insert(v.str);
Q.push(v);
}
}
if(i!=7 && i!=3){
v.str = u.str;
swap(v.str[i], v.str[i+1]);
if(vis.find(v.str)==vis.end()){
vis.insert(v.str);
Q.push(v);
}
}
v.str = u.str;
if(i<4){
swap(v.str[i], v.str[i+4]);
if(vis.find(v.str)==vis.end()){
vis.insert(v.str);
Q.push(v);
}
}else{
swap(v.str[i], v.str[i-4]);
if(vis.find(v.str)==vis.end()){
vis.insert(v.str);
Q.push(v);
}
}
}
}
return 0;
}*/
main(){
string str = "01234567";
int cnt = 0;
do{
itos[0] = str;
stoi[str] = cnt++;
}while(next_permutation(str.begin(), str.end()));
while(cin >> str){
char c;
for(int i=0;i<7;i++){
cin >> c;
str += c;
}
//cout << bfs(str) << endl;
cout << solve(str) << endl;
}
return 0;
} | a.cc: In function 'int solve(std::string)':
a.cc:14:9: error: reference to 'stoi' is ambiguous
14 | dp[0][stoi[str]] = true;
| ^~~~
In file included from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
4432 | stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
a.cc:9:18: note: 'std::map<std::__cxx11::basic_string<char>, int> stoi'
9 | map<string, int> stoi;
| ^~~~
a.cc:26:19: error: reference to 'stoi' is ambiguous
26 | dp[i+1][stoi[tmp]] = true;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
4432 | stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
a.cc:9:18: note: 'std::map<std::__cxx11::basic_string<char>, int> stoi'
9 | map<string, int> stoi;
| ^~~~
a.cc:29:11: error: 'v' was not declared in this scope
29 | v.str = u.str;
| ^
a.cc:29:19: error: 'u' was not declared in this scope
29 | v.str = u.str;
| ^
a.cc:31:19: error: reference to 'stoi' is ambiguous
31 | dp[i+1][stoi[tmp]] = true;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
4432 | stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
a.cc:9:18: note: 'std::map<std::__cxx11::basic_string<char>, int> stoi'
9 | map<string, int> stoi;
| ^~~~
a.cc:33:9: error: 'v' was not declared in this scope
33 | v.str = u.str;
| ^
a.cc:33:17: error: 'u' was not declared in this scope
33 | v.str = u.str;
| ^
a.cc:36:19: error: reference to 'stoi' is ambiguous
36 | dp[i+1][stoi[tmp]] = true;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
4432 | stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
a.cc:9:18: note: 'std::map<std::__cxx11::basic_string<char>, int> stoi'
9 | map<string, int> stoi;
| ^~~~
a.cc:39:19: error: reference to 'stoi' is ambiguous
39 | dp[i+1][stoi[tmp]] = true;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
4432 | stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
a.cc:9:18: note: 'std::map<std::__cxx11::basic_string<char>, int> stoi'
9 | map<string, int> stoi;
| ^~~~
a.cc: At global scope:
a.cc:104:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
104 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:109:5: error: reference to 'stoi' is ambiguous
109 | stoi[str] = cnt++;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4432:3: note: candidates are: 'int std::__cxx11::stoi(const std::wstring&, std::size_t*, int)'
4432 | stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
/usr/include/c++/14/bits/basic_string.h:4164:3: note: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
4164 | stoi(const string& __str, size_t* __idx = 0, int __base = 10)
| ^~~~
a.cc:9:18: note: 'std::map<std::__cxx11::basic_string<char>, int> stoi'
9 | map<string, int> stoi;
| ^~~~
a.cc:110:10: error: 'next_permutation' was not declared in this scope
110 | }while(next_permutation(str.begin(), str.end()));
| ^~~~~~~~~~~~~~~~
|
s928209440 | p00121 | C++ | #include <iostream>
#include <string>
#include <queue>
#include <map>
#define FOR(a,start,end) for(I64 a=(start);a<(end);a++)
using namespace std;
int main(){
int vec[4] = {-1, 1, 4, -4};
queue<string> que;
que.push("01234567");
map<string, int> d;
d["01234567"] = 0;
while(!que.empty()){
string str = que.front();
que.pop();
int zero = str.find('0');
FOR(i, 0, 4){
int next_z;
next_z = zero + vec[i];
if(next_z >= 0 && next_z <= 7){
string str2 = str;
swap(str2[zero], str2[next_z]);
if(d.find(str2) == d.end()){
que.push(str2);
d[str2] = d[str] + 1;
}
}
}
}
string num;
while(getline(cin, num)){
string::iterator end_it = remove(num.begin(), num.end(), ' ');
num.erase(end_it, num.end());
cout << d[num] << endl;
}
} | a.cc: In function 'int main()':
a.cc:5:30: error: 'I64' was not declared in this scope
5 | #define FOR(a,start,end) for(I64 a=(start);a<(end);a++)
| ^~~
a.cc:17:17: note: in expansion of macro 'FOR'
17 | FOR(i, 0, 4){
| ^~~
a.cc:17:21: error: 'i' was not declared in this scope
17 | FOR(i, 0, 4){
| ^
a.cc:5:44: note: in definition of macro 'FOR'
5 | #define FOR(a,start,end) for(I64 a=(start);a<(end);a++)
| ^
a.cc:32:59: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'const char*'
32 | string::iterator end_it = remove(num.begin(), num.end(), ' ');
| ~~~~~~~~~^~
| |
| std::__cxx11::basic_string<char>::iterator
In file included from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdio.h:158:32: note: initializing argument 1 of 'int remove(const char*)'
158 | extern int remove (const char *__filename) __THROW;
| ~~~~~~~~~~~~^~~~~~~~~~
|
s510285824 | p00121 | C++ | #include <iostream>
#include <cmath>
#include <string>
#include <queue>
#include <set>
#include <map>
#define I64 long long int
#define FOR(a,start,end) for(I64 a=(start);a<(end);a++)
using namespace std;
int main(){
int vec[4] = {-1, 1, 4, -4};
queue<string> que;
que.push("01234567");
map<string, int> d;
d["01234567"] = 0;
while(!que.empty()){
string str = que.front();
que.pop();
int zero = str.find('0');
FOR(i, 0, 4){
int next_z;
next_z = zero + vec[i];
if(next_z >= 0 && next_z <= 7){
string str2 = str;
swap(str2[zero], str2[next_z]);
if(d.find(str2) == d.end()){
que.push(str2);
d[str2] = d[str] + 1;
}
}
}
}
string num;
while(getline(cin, num)){
string::iterator end_it = remove(num.begin(), num.end(), ' ');
num.erase(end_it, num.end());
cout << d[num] << endl;
}
} | a.cc: In function 'int main()':
a.cc:36:59: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'const char*'
36 | string::iterator end_it = remove(num.begin(), num.end(), ' ');
| ~~~~~~~~~^~
| |
| std::__cxx11::basic_string<char>::iterator
In file included from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdio.h:158:32: note: initializing argument 1 of 'int remove(const char*)'
158 | extern int remove (const char *__filename) __THROW;
| ~~~~~~~~~~~~^~~~~~~~~~
|
s249805811 | p00121 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#define INF 10000000
#define I64 long long int
#define FOR(a,start,end) for(I64 a=(start);a<(end);a++)
using namespace std;
typedef pair<string, int> P;
int main(){
//4ûüpzñ
int vec[] = {1, -1, 4, -4};
queue<string> que;
que.push("01234567");
//TõÏÝe[u
map<string, int> d;
//"01234567"©çtü«ÉDæTõµÈªçTõÏÝe[uðßé
while(!que.empty()){
string str = que.front();
que.pop();
int zero = str.find("0");
string str2;
FOR(i, 0, 4){
int next_z;
next_z = zero + vec[i];
if(next_z >= 0 && next_z <= 7 && !((zero == 3 && next_4) || (zero == 4 && next_z == 3))){
str2 = str;
swap(str2[zero], str2[next_z]);
if(d.find(str2) == d.end()){
que.push(str2);
d[str2] = d[str] + 1;
}
}
}
}
//üÍ©ç' 'ð¢ÄTõÏÝe[u©ç¦ðoÍ
string num;
while(getline(cin, num)){
string::iterator end_it = remove(num.begin(), num.end(), ' ');
num.erase(end_it, num.end());
cout << d[num] << endl;
}
} | a.cc: In function 'int main()':
a.cc:32:74: error: 'next_4' was not declared in this scope; did you mean 'next_z'?
32 | if(next_z >= 0 && next_z <= 7 && !((zero == 3 && next_4) || (zero == 4 && next_z == 3))){
| ^~~~~~
| next_z
|
s512644421 | p00121 | C++ | #include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
class pz{
public:
int a,b,c,d,e,f,g,h;
bool operator < (const pz& a) const{
if(a.a != this->a) return a.a > this->a;
else if(a.b != this->b) return a.b > this->b;
else if(a.c != this->c) return a.c > this->c;
else if(a.d != this->d) return a.d > this->d;
else if(a.e != this->e) return a.e > this->e;
else if(a.f != this->f) return a.f > this->f;
else if(a.g != this->g) return a.g > this->g;
else return false;
}
bool operator == (const pz& a) const{
return a.a == this->a && a.b == this.b && a.c == this->c && a.d == this->d
&& a.e == this->e && a.f == this->f && a.g == this->g && a.h == this->h;
}
};
#define P pair<pz,int>
void swap(int* a,int* b)
{
int t;
t = *a;
*a = *b;
*b = t;
}
int main()
{
pz a;
while(cin >> a.a >> a.b >> a.c >> a.d >> a.e >> a.f >> a.g >> a.h){
queue< P > q;
set< pz > st;
q.push( P(a,0) );
while(!q.empty()){
P v = q.front(); q.pop();
pz p = v.first;
if(p.a == 0 && p.b == 1 && p.c == 2 && p.d == 3 &&
p.e == 4 && p.f == 5 && p.g == 6 && p.h == 7){
cout << v.second << endl;
break;
}
if(p.a == 0){
pz s = p;
swap(&s.a,&s.b);
if(st.find(s) == st.end()){
q.push( P(s,v.second+1) );
st.insert(s);
}
pz t = p;
swap(&t.a,&t.e);
if(st.find(t) == st.end()){
q.push( P(t,v.second+1) );
st.insert(s);
}
}else if(p.b == 0){
pz s = p;
swap(&s.b,&s.a);
if(st.find(s) == st.end()){
q.push( P(s,v.second+1) );
st.insert(s);
}
pz t = p;
swap(&t.b,&t.c);
if(st.find(t) == st.end()){
q.push( P(t,v.second+1) );
st.insert(t);
}
pz u = p;
swap(&u.b,&u.f);
if(st.find(u) == st.end()){
q.push( P(u,v.second+1) );
st.insert(u);
}
}else if(p.c == 0){
pz s = p;
swap(&s.c,&s.b);
if(st.find(s) == st.end()){
q.push( P(s,v.second+1) );
st.insert(s);
}
pz t = p;
swap(&t.c,&t.d);
if(st.find(t) == st.end()){
q.push( P(t,v.second+1) );
st.insert(t);
}
pz u = p;
swap(&u.c,&u.g);
if(st.find(u) == st.end()){
q.push( P(u,v.second+1) );
st.insert(u);
}
}else if(p.d == 0){
pz s = p;
swap(&s.d,&s.c);
if(st.find(s) == st.end()){
q.push( P(s,v.second+1) );
st.insert(s);
}
pz t = p;
swap(&t.d,&t.h);
if(st.find(t) == st.end()){
q.push( P(t,v.second+1) );
st.insert(t);
}
}else if(p.e == 0){
pz s = p;
swap(&s.e,&s.f);
if(st.find(s) == st.end()){
q.push( P(s,v.second+1) );
st.insert(s);
}
pz t = p;
swap(&t.e,&t.a);
if(st.find(t) == st.end()){
q.push( P(t,v.second+1) );
st.insert(t);
}
}else if(p.f == 0){
pz s = p;
swap(&s.f,&s.e);
if(st.find(s) == st.end()){
q.push( P(s,v.second+1) );
st.insert(s);
}
pz t = p;
swap(&t.f,&t.g);
if(st.find(t) == st.end()){
q.push( P(t,v.second+1) );
st.insert(t);
}
pz u = p;
swap(&u.f,&u.b);
if(st.find(u) == st.end()){
q.push( P(u,v.second+1) );
st.insert(u);
}
}else if(p.g == 0){
pz s = p;
swap(&s.g,&s.f);
if(st.find(s) == st.end()){
q.push( P(s,v.second+1) );
st.insert(s);
}
pz t = p;
swap(&t.g,&t.h);
if(st.find(t) == st.end()){
q.push( P(t,v.second+1) );
st.insert(t);
}
pz u = p;
swap(&u.g,&u.c);
if(st.find(u) == st.end()){
q.push( P(u,v.second+1) );
st.insert(u);
}
}else if(p.h == 0){
pz s = p;
swap(&s.h,&s.g);
if(st.find(s) == st.end()){
q.push( P(s,v.second+1) );
st.insert(s);
}
pz t = p;
swap(&t.h,&t.d);
if(st.find(t) == st.end()){
q.push( P(t,v.second+1) );
st.insert(t);
}
}
}
}
return 0;
} | a.cc: In member function 'bool pz::operator==(const pz&) const':
a.cc:20:42: error: request for member 'b' in '(const pz*)this', which is of pointer type 'const pz*' (maybe you meant to use '->' ?)
20 | return a.a == this->a && a.b == this.b && a.c == this->c && a.d == this->d
| ^
|
s145653852 | p00121 | C++ |
#include <iostream>
#include <queue>
using namespace std;
#define SIZE 8
int coefficients[SIZE] = {10000000, 1000000, 100000, 10000, 1000, 100, 10, 1};
int movablePairs[SIZE][4] = {
{1,4,-1,-1}, {0,2,5,-1}, {1,3,6,-1}, {2,7,-1,-1},
{0,5,-1,-1}, {1,4,6,-1}, {2,5,7,-1}, {3,6,-1,-1}
};
int answerStateCode = 1234567;
class Puzzle
{
public:
int state[SIZE];
int depth;
int movablePiecePoint;
int stateCode;
Puzzle(int state0[SIZE], int depth0)
{
memcpy(state, state0, sizeof(int)*SIZE);
depth = depth0;
stateCode = 0;
for (int i=0; i<SIZE; i++) {
if(state0[i] == 0){
movablePiecePoint = i;
}
stateCode += coefficients[i]*state0[i];
}
}
};
void move(int state[], int nextState[], int point1, int point2)
{
memcpy(nextState, state, sizeof(int)*SIZE);
int tmp = nextState[point1];
nextState[point1] = nextState[point2];
nextState[point2] = tmp;
return;
}
bool isVisit[76543211];
int solve(int input[])
{
queue<Puzzle> qu;
for (int i=0; i<76543211; i++) {
isVisit[i] = false;
}
Puzzle init = Puzzle(input, 0);
qu.push(init);
while (!qu.empty()) {
Puzzle now = qu.front();
qu.pop();
if (answerStateCode == now.stateCode) {
return now.depth;
}
if (!isVisit[now.stateCode]) {
for (int i=0; movablePairs[now.movablePiecePoint][i]>=0 and i<3; i++){
int nextMove = movablePairs[now.movablePiecePoint][i];
int nextState[SIZE];
move(now.state, nextState, now.movablePiecePoint, nextMove);
Puzzle nextP = Puzzle(nextState, now.depth+1);
qu.push(nextP);
}
isVisit[now.stateCode] = true;
}
}
return -1;
}
int get()
{
int input[SIZE];
for(int i=0; i<SIZE; i++){
cin >> input[i];
}
return solve(input);
}
int main(int argc, const char * argv[])
{
while (true) {
cout << get() << endl;
}
return 0;
} | a.cc: In constructor 'Puzzle::Puzzle(int*, int)':
a.cc:26:9: error: 'memcpy' was not declared in this scope
26 | memcpy(state, state0, sizeof(int)*SIZE);
| ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <queue>
+++ |+#include <cstring>
4 | using namespace std;
a.cc: In function 'void move(int*, int*, int, int)':
a.cc:40:5: error: 'memcpy' was not declared in this scope
40 | memcpy(nextState, state, sizeof(int)*SIZE);
| ^~~~~~
a.cc:40:5: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s644018754 | p00121 | C++ | import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Scanner;
/**
* AIZU 0121
* 幅優先探索
*/
public class Main {
private final static int SIZE = 8;
private final BitSet isVisit;// 既に生成した状態かどうかを管理するフラグセット
// int[0の座標番号][交換候補の座標]
private final static int[][] MOVABLE_PAIRS = {
{1,4}, {0,2,5}, {1,3,6}, {2,7},
{0,5}, {1,4,6}, {2,5,7}, {3,6}
};
// stateを整数に変換する際の係数
private final static int[] coefficients = {5040, 720, 120, 24, 6, 2, 1, 0};
private Main() {
Scanner in = new Scanner(System.in);
this.isVisit = new BitSet();
while(in.hasNext()) {
int[] puzzle = new int[SIZE];
for(int i=0; i<SIZE; i++) {
puzzle[i] = in.nextByte();
}
long start = System.currentTimeMillis();
System.out.println(solve(puzzle));
System.out.println(System.currentTimeMillis() - start);
isVisit.clear();
}
in.close();
}
final class Puzzle {
// 座標番号
// 0 1 2 3
// 4 5 6 7
final int[] state; // パズルの状態
final int depth; // 深さ(操作回数)
final int movablePiecePoint; // パズル内にある動かせるピースの座標
final int point;// 移動可能なピースの直前にあった座標
final boolean isRoot; // 根ノードかどうか
int stateCode;
/**
* 根ノード用コンストラクタ
* @param state
*/
public Puzzle(int[] state) {
this.isRoot = true;
this.depth = 0;
this.state = state;
this.point = -1;
calcStateCode();
for(int i=0; i<SIZE; i++) {
// 0(動かせるピース)の座標を探索
if(state[i]==0) {
this.movablePiecePoint = i;
return;
}
}
this.movablePiecePoint = -1;
}
/**
* 子ノード生成用コンストラクタ
* @param parent 親ノード
* @param point1
* @param point2
*/
public Puzzle (Puzzle parent, int nextMove){
this.isRoot = false;
this.depth = parent.depth+1;
this.point = parent.movablePiecePoint;
this.movablePiecePoint = nextMove;
// stateのswap
this.state = Arrays.copyOf(parent.state, SIZE);
int tmp = this.state[this.point];
this.state[this.point] = this.state[nextMove];
this.state[nextMove] = tmp;
calcStateCode();
}
/**
* stateCodeの計算メソッド
*/
private final void calcStateCode() {
for(int i=SIZE-2; i>=0; i--) {
// 状態コードの計算
int c = 0;
for(int j=SIZE-1; j-i>0; j--) {
if(this.state[i] > this.state[j]) {
c++;
}
}
this.stateCode += (coefficients[i]*c);
}
}
}
/**
* パズルを解く
* @param puzzle 初期状態
* @return 操作回数
*/
private final int solve(int[] puzzle) {
ArrayDeque<Puzzle> queue = new ArrayDeque<Puzzle>();
queue.add(new Puzzle(puzzle));
while(!queue.isEmpty()) {
Puzzle now = queue.poll();
if(now.stateCode==0) { // 01234567のstateCodeは0
return now.depth;
}
if(!isVisit.get(now.stateCode)) { // 枝刈りが可能かチェック
for(int nextMove : MOVABLE_PAIRS[now.movablePiecePoint]) {
if (now.isRoot || (!now.isRoot && now.point!=nextMove)) {
queue.add(new Puzzle(now, nextMove));
}
}
}
isVisit.set(now.stateCode, true);
}
return -1;
}
public static void main(String[] args) {
new Main();
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.ArrayDeque;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.util.Arrays;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.BitSet;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.Scanner;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: expected unqualified-id before 'public'
10 | public class Main {
| ^~~~~~
|
s008141022 | p00121 | C++ | #include<stdio.h>
#include<utility>
#include<string.h>
#include<queue>
using namespace std;
int d[1<<27]={0};
int main()
{
typedef struct p{int n;char s[9];}p;
queue<p> Q;
int m[4]={1,4,-4,-1};
char s[9]={48,49,50,51,52,53,54,55,0},c[18];
memset(d,1,sizeof(d));
d[1234567]=0;
p T;
T.n=-1;
strcpy(T.s,s);
Q.push(T);
while(!Q.empty())
{
T=Q.front();
Q.pop();
int i,j,k;
char w[9];
strcpy(w,T.s);
if(T.n<30)
{
for(i=0;i<8;i++)
if(T.s[i]=='0')
break;
if(i==3)
j=1,k=4;
else if(i==4)
j=0,k=3;
else
j=0,k=4;
for(;j<k;j++)
if(i+m[j]>=0&&i+m[j]<8)
{
char t=T.s[i+m[j]];
T.s[i+m[j]]=T.s[i];
T.s[i]=t;
if(d[atoi(T.s)]>d[atoi(w)]+1)
{
d[atoi(T.s)]=T.n=d[atoi(w)]+1;
Q.push(T);
}
strcpy(T.s,w);
}
}
}
while((c[0]=getchar())!=-1)
{
for(int i=1;i<16;i++)
c[i]=getchar();
for(int i=0,j=0;i<8;i++,j+=2)
s[i]=c[j];
printf("%d\n",d[atoi(s)]);
}
} | a.cc: In function 'int main()':
a.cc:44:46: error: 'atoi' was not declared in this scope
44 | if(d[atoi(T.s)]>d[atoi(w)]+1)
| ^~~~
a.cc:59:33: error: 'atoi' was not declared in this scope
59 | printf("%d\n",d[atoi(s)]);
| ^~~~
|
s450171604 | p00121 | C++ | #include <iostream>
#include <queue>
#include <string>
#include <map>
#include <stdio.h>
using namespace std;
int dd[] = {1, -1, 4, -4};
int dfs(string cards){
//その時のカードの状態をqueueに突っ込む
map<string, int> done;
queue<string> que;
if(cards == "01234567")
return 0;
que.push(cards);
while(!que.empty()){
string q = que.front(); que.pop();
int x0 = q.find("0");
for(int i=0; i<4; i++){
string t = q;
int nx = x0+dd[i];
if(nx<0 || 7<nx || (x0==3&&i==0) || (x0==4&&i==1))
continue;
t[x0] = t[nx];
t[nx] = '0';
if(done.count(t))
continue;
done[t] = done[q] + 1;
if(t == "01234567")
return done[t];
que.push(t);
}
}
return 0;
}
int main(){
string t;
while(getline(cin,t)){
t.erase(remove(t.begin(),t.end(),' '),t.end());
cout << dfs(t) << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:44:39: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'const char*'
44 | t.erase(remove(t.begin(),t.end(),' '),t.end());
| ~~~~~~~^~
| |
| std::__cxx11::basic_string<char>::iterator
In file included from /usr/include/c++/14/cstdio:42,
from /usr/include/c++/14/ext/string_conversions.h:45,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdio.h:158:32: note: initializing argument 1 of 'int remove(const char*)'
158 | extern int remove (const char *__filename) __THROW;
| ~~~~~~~~~~~~^~~~~~~~~~
|
s624948940 | p00121 | C++ | #include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
using namespace std;
char visited[0xffffff];
inline int is_visited(unsigned s){ return visited[s&0xffffff]; }
inline void set_visited(unsigned s){ visited[s&0xffffff]=1; }
inline unsigned exchange(unsigned s, unsigned p1, unsigned p2, unsigned n){
unsigned x = ((s>>p1)^(s>>p2))&((1U<<n)-1);
unsigned ns = s^((x<<p1)|(x<<p2));
return ns;
}
int main(){
cin.sync_with_stdin(false);
unsigned int a[8];
unsigned f_state = 0;
for(int i=0;i<8;++i) f_state |= (i<<(3*i));
while(cin >> a[0]){
for(int i=1;i<8;++i) cin >> a[i];
unsigned istate=0;
for(int i=0;i<8;++i)istate |= (a[i]<<(3*i));
for(int i=0;i<8;++i){
if(a[i]==0){
istate |= (i<<24);
}
}
queue<unsigned> q;
q.push(istate);
memset(visited,0,sizeof(visited));
set_visited(istate);
int flag = 0;
for(int n=0;;++n){
queue<unsigned> nq;
while(!q.empty()){
unsigned p = q.front(); q.pop();
unsigned state = (p&0xffffff);
unsigned pos = (p>>24);
if(state == f_state){ flag=1; cout << n << endl; break; }
int bit_pos = 3*pos;
unsigned next_state;
if(pos!=0 && pos!=4){
next_state = exchange(state,bit_pos,bit_pos-3,3);
next_state |= ((pos-1)<<24);
if(!is_visited(next_state)){
set_visited(next_state);
nq.push(next_state);
}
}
if(pos!=3 && pos!=7){
next_state = exchange(state,bit_pos,bit_pos+3,3);
next_state |= ((pos+1)<<24);
if(!is_visited(next_state)){
set_visited(next_state);
nq.push(next_state);
}
}
if(pos<=3){
next_state = exchange(state,bit_pos,bit_pos+12,3);
next_state |= ((pos+4)<<24);
if(!is_visited(next_state)){
set_visited(next_state);
nq.push(next_state);
}
}
if(pos>=4){
next_state = exchange(state,bit_pos,bit_pos-12,3);
next_state |= ((pos-4)<<24);
if(!is_visited(next_state)){
set_visited(next_state);
nq.push(next_state);
}
}
}
if(flag)break;
q = nq;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:27:9: error: 'std::istream' {aka 'class std::basic_istream<char>'} has no member named 'sync_with_stdin'; did you mean 'sync_with_stdio'?
27 | cin.sync_with_stdin(false);
| ^~~~~~~~~~~~~~~
| sync_with_stdio
|
s629887025 | p00121 | C++ | #include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <cstring>
using namespace std;
typedef pair<string, int> P;
int iti;
string n;
void solve(){
queue<P> que;
map<string, int> m;
map<string, int>::iterator ite;
que.push(P(n, 0));
m.insert(make_pair(n, 0));
while(true){
P p = que.front(); que.pop();
if(p.first == "01234567"){
cout << p.second << endl;
break;
}
for(int i = 0; i < 8; i++){
if(p.first[i] == '0') iti = i;
}
if(iti != 3 && iti != 7){
swap(p.first[iti], p.first[iti+1]);
ite = m.find(p.first);
if(ite == m.end()){
que.push(P(p.first, p.second+1));
m.insert(make_pair(p.first, p.second+1));
}
swap(p.first[iti], p.first[iti+1]);
}
if(iti != 0 && iti != 4){
swap(p.first[iti], p.first[iti-1]);
ite = m.find(p.first);
if(ite == m.end()){
que.push(P(p.first, p.second+1));
m.insert(make_pair(p.first, p.second+1));
}
swap(p.first[iti], p.first[iti-1]);
}
if(iti <= 3){
swap(p.first[iti+4], p.first[iti]);
ite = m.find(p.first);
if(ite == m.end()){
que.push(P(p.first, p.second+1));
m.insert(make_pair(p.first, p.second+1));
}
swap(p.first[iti+4], p.first[iti]);
}
else{
swap(p.first[iti-4], p.first[iti]);
ite = m.find(p.first);
if(ite == m.end()){
que.push(P(p.first, p.second+1));
m.insert(make_pair(p.first, p.second+1));
}
swap(p.first[iti-4], p.first[iti]);
}
}
}
int main(){
char trash;
while(cin >> trash){
n.push_back(trash);
for(int i = 1; i < 8; i++){
cin >> trash;
n.push_back(trash);
}
solve();
n.clear();
}
} | a.cc: In function 'void solve()':
a.cc:14:9: error: 'queue' was not declared in this scope
14 | queue<P> que;
| ^~~~~
a.cc:7:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
6 | #include <cstring>
+++ |+#include <queue>
7 | using namespace std;
a.cc:14:16: error: expected primary-expression before '>' token
14 | queue<P> que;
| ^
a.cc:14:18: error: 'que' was not declared in this scope
14 | queue<P> que;
| ^~~
a.cc:15:9: error: 'map' was not declared in this scope
15 | map<string, int> m;
| ^~~
a.cc:7:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
6 | #include <cstring>
+++ |+#include <map>
7 | using namespace std;
a.cc:15:19: error: expected primary-expression before ',' token
15 | map<string, int> m;
| ^
a.cc:15:21: error: expected primary-expression before 'int'
15 | map<string, int> m;
| ^~~
a.cc:16:19: error: expected primary-expression before ',' token
16 | map<string, int>::iterator ite;
| ^
a.cc:16:21: error: expected primary-expression before 'int'
16 | map<string, int>::iterator ite;
| ^~~
a.cc:18:9: error: 'm' was not declared in this scope; did you mean 'tm'?
18 | m.insert(make_pair(n, 0));
| ^
| tm
a.cc:22:25: error: 'cout' was not declared in this scope
22 | cout << p.second << endl;
| ^~~~
a.cc:7:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
6 | #include <cstring>
+++ |+#include <iostream>
7 | using namespace std;
a.cc:30:25: error: 'ite' was not declared in this scope; did you mean 'iti'?
30 | ite = m.find(p.first);
| ^~~
| iti
a.cc:39:25: error: 'ite' was not declared in this scope; did you mean 'iti'?
39 | ite = m.find(p.first);
| ^~~
| iti
a.cc:48:25: error: 'ite' was not declared in this scope; did you mean 'iti'?
48 | ite = m.find(p.first);
| ^~~
| iti
a.cc:57:25: error: 'ite' was not declared in this scope; did you mean 'iti'?
57 | ite = m.find(p.first);
| ^~~
| iti
a.cc: In function 'int main()':
a.cc:69:15: error: 'cin' was not declared in this scope
69 | while(cin >> trash){
| ^~~
a.cc:69:15: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s104675126 | p00121 | C++ | #include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <cstring>
using namespace std;
typedef pair<string, int> P;
int iti;
string n;
void solve(){
queue<P> que;
map<string, int> m;
map<string, int>::iterator ite;
que.push(P(n, 0));
m.insert(make_pair(n, 0));
while(true){
P p = que.front(); que.pop();
if(p.first == "01234567"){
cout << p.second << endl;
break;
}
for(int i = 0; i < 8; i++){
if(p.first[i] == '0') iti = i;
}
if(iti != 3 && iti != 7){
swap(p.first[iti], p.first[iti+1]);
ite = m.find(p.first);
if(ite == m.end()){
que.push(P(p.first, p.second+1));
m.insert(make_pair(p.first, p.second+1));
}
swap(p.first[iti], p.first[iti+1]);
}
if(iti != 0 && iti != 4){
swap(p.first[iti], p.first[iti-1]);
ite = m.find(p.first);
if(ite == m.end()){
que.push(P(p.first, p.second+1));
m.insert(make_pair(p.first, p.second+1));
}
swap(p.first[iti], p.first[iti-1]);
}
if(iti <= 3){
swap(p.first[iti+4], p.first[iti]);
ite = m.find(p.first);
if(ite == m.end()){
que.push(P(p.first, p.second+1));
m.insert(make_pair(p.first, p.second+1));
}
swap(p.first[iti+4], p.first[iti]);
}
else{
swap(p.first[iti-4], p.first[iti]);
ite = m.find(p.first);
if(ite == m.end()){
que.push(P(p.first, p.second+1));
m.insert(make_pair(p.first, p.second+1));
}
swap(p.first[iti-4], p.first[iti]);
}
}
}
int main(){
char trash;
while(cin >> trash){
n.push_back(trash);
for(int i = 1; i < 8; i++){
cin >> trash;
n.push_back(trash);
}
solve();
n.clear();
}
} | a.cc: In function 'void solve()':
a.cc:14:9: error: 'queue' was not declared in this scope
14 | queue<P> que;
| ^~~~~
a.cc:7:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
6 | #include <cstring>
+++ |+#include <queue>
7 | using namespace std;
a.cc:14:16: error: expected primary-expression before '>' token
14 | queue<P> que;
| ^
a.cc:14:18: error: 'que' was not declared in this scope
14 | queue<P> que;
| ^~~
a.cc:15:9: error: 'map' was not declared in this scope
15 | map<string, int> m;
| ^~~
a.cc:7:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
6 | #include <cstring>
+++ |+#include <map>
7 | using namespace std;
a.cc:15:19: error: expected primary-expression before ',' token
15 | map<string, int> m;
| ^
a.cc:15:21: error: expected primary-expression before 'int'
15 | map<string, int> m;
| ^~~
a.cc:16:19: error: expected primary-expression before ',' token
16 | map<string, int>::iterator ite;
| ^
a.cc:16:21: error: expected primary-expression before 'int'
16 | map<string, int>::iterator ite;
| ^~~
a.cc:18:9: error: 'm' was not declared in this scope; did you mean 'tm'?
18 | m.insert(make_pair(n, 0));
| ^
| tm
a.cc:22:25: error: 'cout' was not declared in this scope
22 | cout << p.second << endl;
| ^~~~
a.cc:7:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
6 | #include <cstring>
+++ |+#include <iostream>
7 | using namespace std;
a.cc:30:25: error: 'ite' was not declared in this scope; did you mean 'iti'?
30 | ite = m.find(p.first);
| ^~~
| iti
a.cc:39:25: error: 'ite' was not declared in this scope; did you mean 'iti'?
39 | ite = m.find(p.first);
| ^~~
| iti
a.cc:48:25: error: 'ite' was not declared in this scope; did you mean 'iti'?
48 | ite = m.find(p.first);
| ^~~
| iti
a.cc:57:25: error: 'ite' was not declared in this scope; did you mean 'iti'?
57 | ite = m.find(p.first);
| ^~~
| iti
a.cc: In function 'int main()':
a.cc:69:15: error: 'cin' was not declared in this scope
69 | while(cin >> trash){
| ^~~
a.cc:69:15: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s611903215 | p00121 | C++ | #include <iostream>
#include <queue>
#include <vector>
#include <set>
using namespace std;
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
typedef vector<int> vi;
struct state {
int v[8];
int step, x, y;
};
const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, 1, 0, -1 };
inline bool in(int x, int y){
return 0 <= x && x < 4 && 0 <= y && y < 2;
}
int hashh(const int v[8]){
int res = 0;
rep(i, 8){
res <<= 3;
res |= v[i];
}
return res;
}
void disp(state s){
rep(i, 2){
rep(j, 4){
cout << s.v[i * 2 + j];
}
cout << endl;
}
cout << endl;
}
bool dp[1 << 24] = {};
int main(){
int fin = 0;
rep(i, 8){
fin <<= 3; fin |= i;
}
while (1){
memset(dp, 0, sizeof(dp));
state s;
s.step = 0;
rep(i, 8){
if (!(cin >> s.v[i])) return 0;
if (s.v[i] == 0){
s.x = i % 4;
s.y = i / 4;
}
}
queue<state> q;
q.push(s);
int ans = -1;
while (q.size()){
state s = q.front();
q.pop();
int h = hashh(s.v);
if (dp[h]) continue;
dp[h] = true;
// disp(s);
if (h == fin){
ans = s.step;
break;
}
rep(i, 4){
int xx = s.x + dx[i];
int yy = s.y + dy[i];
if (in(xx, yy)){
state next = s;
next.x = xx;
next.y = yy;
int n_space = xx + 4 * yy;
swap(next.v[n_space], next.v[s.x + s.y * 4]);
next.step++;
q.push(next);
}
}
}
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:53:9: error: 'memset' was not declared in this scope
53 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <set>
+++ |+#include <cstring>
5 |
|
s868106633 | p00121 | C++ | #include <cstdio>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define MAX_HIT ((0<<0)|(1<<3)|(2<<6)|(3<<9)|(4<<12)|(5<<15)|(6<<18)|(7<<21))
bool hit[MAX_HIT+1];
int swap_pos(int value, int i, int j)
{
int vi, vj;
i*=3; j*=3;
vi = (value>>i) & 7;
vj = (value>>j) & 7;
value = (value & ~(7<<i)) | (vj<<i);
value = (value & ~(7<<j)) | (vi<<j);
return value;
}
int main()
{
//freopen("in.txt", "r", stdin);
int target, src;
int i, j;
target=0;
for (i=0; i<=7; i++) {
target = (target<<3)|i;
}
//printf("MAX_HIT=0x%x\n", MAX_HIT);
while (scanf("%d", &src)==1) {
for (i=1; i<=7; i++) {
int tmp;
scanf("%d", &tmp);
src = (src<<3) | tmp;
}
//printf("target=%d, src=%d\n", target, src);
memset(hit, 0, sizeof(hit));
hit[src] = true;
queue<int> q1, q2, *q, *nq, *qtmp;
q = &q1; nq = &q2;
q1.push(src);
int step = 0;
while (!hit[target]) {
while (!nq->empty()) nq->pop();
step++;
while (!q->empty()) {
int value = q->front(); q->pop();
int next_value;
for (i=0; i<7; i++) {
next_value = swap_pos(value, i, i+1);
if (hit[next_value]==false) {
hit[next_value] = true;
nq->push(next_value);
}
}
if (hit[target]) break;
}
qtmp = q; q = nq; nq = qtmp;
}
printf("%d\n", step);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:50:17: error: 'memset' was not declared in this scope
50 | memset(hit, 0, sizeof(hit));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <map>
+++ |+#include <cstring>
5 |
|
s977191918 | p00121 | C++ | #include <iostream>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
typedef pair<string, int> P;
const int INF = 100000000;
//霎灘?
string a;
//遘サ蜉ィ譁ケ蜷?int dir[4] = {-1, 1, -4, 4};
map<string, int> dp; //菫晏ュ倅サ市tring蜿伜芦"01234567"逧?nt
//隶。邂嶺サ?01234567"霓ャ謐「蛻ー蜈カ莉門コ丞?謇?怙逧?怙蟆乗ュ・謨ー
void bfs(){
//蛻晏ァ句喧
queue<P> que;
que.push(P("01234567", 0));
dp["01234567"] = 0;
//螳ス蠎ヲ莨伜?謳懃エ「
while(!que.empty()){
P p = que.front();
que.pop();
string s = p.first;
int cur = p.second;
for(int i = 0; i < 4; i ++){
//譫??荳倶ク?ャ。莠、謐「
int next = cur + dir[i];
string str = s;
swap(str[cur], str[next]);
map<string, int>::iterator it = dp.find(str);
//蛻、譁ュ譏ッ蜷ヲ蜿ッ遘サ蜉ィ莉・蜿頑弍蜷ヲ隶ソ髣ョ霑? if(0 <= next && next < 8
&& !(cur == 3 && next == 4) && !(cur == 4 && next == 3)
&& it == dp.end()){
que.push(P(str, next));
dp[str] = dp[s] + 1;
}
}
}
}
void solve(){
//蛻?勁遨コ譬シ
a.erase(remove(a.begin(), a.end(), ' '), a.end());
cout<<dp[a]<<endl;
}
int main(int argc, char const *argv[]){
//蜈磯?蜷第桷騾?園譛画ュ蜀オ?悟錘逶エ謗・隸サ蜿冶セ灘?逕ィ萓狗噪扈捺棡
bfs();
while(getline(cin, a)){
solve();
}
return 0;
} | a.cc: In function 'void bfs()':
a.cc:34:30: error: 'dir' was not declared in this scope; did you mean 'div'?
34 | int next = cur + dir[i];
| ^~~
| div
a.cc:39:20: error: expected identifier before '!' token
39 | && !(cur == 3 && next == 4) && !(cur == 4 && next == 3)
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.