#include #include #include #include #include #include using namespace std; int main() { vector a(16); for (int& i : a) cin >> i; queue, vector>> b; b.emplace(unordered_set(), a); while (!b.empty()) { int c = find(b.front().second.begin(), b.front().second.end(), 0) - b.front().second.begin(), i; for (i = 0; i < 15; ++i) { if (1 + i != b.front().second[i]) break; } if (15 == i) break; if (3 != c % 4) { if (!b.front().first.count(b.front().second[1 + c])) { pair, vector> d(b.front()); swap(d.second[1 + c], d.second[c]); d.first.insert(d.second[c]); b.push(d); } } if (3 != c / 4) { if (!b.front().first.count(b.front().second[4 + c])) { pair, vector> d(b.front()); swap(d.second[4 + c], d.second[c]); d.first.insert(d.second[c]); b.push(d); } } if (c % 4) { if (!b.front().first.count(b.front().second[c - 1])) { pair, vector> d(b.front()); swap(d.second[c - 1], d.second[c]); d.first.insert(d.second[c]); b.push(d); } } if (c / 4) { if (!b.front().first.count(b.front().second[c - 4])) { pair, vector> d(b.front()); swap(d.second[c - 4], d.second[c]); d.first.insert(d.second[c]); b.push(d); } } b.pop(); } if (b.empty()) cout << "No"; else cout << "Yes"; }