#define _CRT_SECURE_NO_WARNINGS //#define _GLIBCXX_DEBUG #include using namespace std; typedef long long ll; //#define int ll //#define endl "\n" typedef vector vi; typedef vector vvi; typedef pair pii; #define all(c) (c).begin(), (c).end() #define loop(i,a,b) for(ll i=a; i ostream & operator<<(ostream & os, vector const &); template typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple const &){} template typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple const & t){ os << (n==0?"":" ") << get(t); _ot(os, t); } template ostream & operator<<(ostream & os, tuple const & t){ _ot<0>(os, t); return os; } template ostream & operator<<(ostream & os, pair const & p){ return os << "(" << p.first << ", " << p.second << ") "; } template ostream & operator<<(ostream & os, vector const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; } template inline bool chmax(T & x, T const & y){ return x inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; } #ifdef DEBUG #define dump(...) (cerr<<#__VA_ARGS__<<" = "<> g[i][j]; if(g[i][j]==0) sj = j, si = i; } int di[] = {0,1,0,-1}; int dj[] = {1,0,-1,0}; while(1){ bool ok = false; rep(d,4){ int ni = si+di[d]; int nj = sj+dj[d]; if(ni < 0 || nj < 0 || ni >= 4 || nj >= 4) continue; int a = g[ni][nj]; if(a == si*4+sj+1){ swap(g[si][sj],g[ni][nj]); si = ni, sj = nj; ok = true; break; } } // rep(i,4){ // rep(j,4){ // cout << g[i][j] << " "; // } // cout << endl; // } if(ok) continue; else break; } bool ok = true; rep(i,4)rep(j,4){ ok &= g[i][j] == i*4 + j+1 || (i==3 && j==3); } puts(ok ? "Yes" : "No"); } }