#include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef ONLINE_JUDGE //POJ # include # include # include # define mkt make_tuple # define empb emplace_back #endif #ifdef _LOCAL # include "for_local.h" #endif using namespace std; typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; #define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I)) #define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I)) #define mkp make_pair #define all(_X) (_X).begin(), (_X).end() inline int scani() { int n; scanf("%d", &n); return n; } static int const dx[] = { 1, 0, -1, 0 }, dy[] = { 0, 1, 0, -1 }; int board[4][4] {}; int iz, jz; bool correct(int i, int j, int k) { return k == (i * 4 + j + 1); } void move() { for (;;) { bool continues = false; rep(d, 4) { int u = iz + dx[d]; int v = jz + dy[d]; if ( 0 <= u && u < 4 && 0 <= v && v < 4 && correct(iz, jz, board[u][v]) ) { swap(board[iz][jz], board[u][v]); iz = u; jz = v; continues = true; break; } } if ( !continues) break; } } bool check() { move(); rep(i, 4) rep(j, 4) { if ( i == iz && j == jz ) continue; if ( !correct(i, j, board[i][j]) ) return false; } return true; } signed main() { rep(i, 4) rep(j, 4) { int k; cin >> k; board[i][j] = k; if ( k == 0 ) { iz = i; jz = j; } } cout << (check() ? "Yes" : "No") << endl; return 0; }