結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー かに
提出日時 2015-07-04 22:07:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,721 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 88,256 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 22:54:29
合計ジャッジ時間 1,210 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:70:43: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   70 |       if((abs(i-y) <= 1 && abs(j-x) == 0) || (abs(i-y) == 0 && abs(j-x) <= 1)){}
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:70:69: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   70 |       if((abs(i-y) <= 1 && abs(j-x) == 0) || (abs(i-y) == 0 && abs(j-x) <= 1)){}
      |                                                                    ~^~

ソースコード

diff #

#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#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)<<endl;
#define EXISt(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define MaX 100000000
#define pb push_back
using namespace std; 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

int main(){
  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];
    }
  }
  for(int i = 0;i < 4;i++){
    for(int j = 0;j < 4;j++){
      int t = puzzle[i][j];
      if(t == 0)continue;
      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;
            break;
          }
        }
      }
      if((abs(i-y) <= 1 && abs(j-x) == 0) || (abs(i-y) == 0 && abs(j-x) <= 1)){}
      else{
        P("No");
        return 0;
      }
    }
  }
  P("Yes");
  return 0;
}
0