#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define aLL(g) (g).begin(),(g).end() #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define F(i,j,k) fill(i[0],i[0]+j*j,k) #define P(p) cout<<(p)< vi; typedef vector vl; typedef vector vd; typedef pair pii; typedef pair pll; typedef long long ll; int dx[] = {0,1,0,-1}; int dy[] = {-1,0,1,0}; int main(){ int nums[16]; int puzzle[4][4]; int answer[4][4] = {{1,2,3,4}, {5,6,7,8}, {9,10,11,12}, {13,14,15,0}}; for(int i = 0;i < 4;i++){ for(int j = 0;j < 4;j++){ cin >> puzzle[i][j]; nums[i+j] = puzzle[i][j]; } } int count = 0; for(int i = 0;i < 4;i++){ for(int j = 0;j < 4;j++){ int t = puzzle[i][j]; if(t == 0){ count += 3-i; continue; } if(i < j && nums[i] > nums[j])count++; int x,y; for(int k = 0;k < 4;k++){ for(int l = 0;l < 4;l++){ if(answer[k][l] == t){ x = l; y = k; } } } if((abs(i-y) <= 1 && abs(j-x) == 0) || (abs(i-y) == 0 && abs(j-x) <= 1)){} else{ P("No"); return 0; } } } if(count % 2 == 0)P("Yes"); return 0; }