結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー かにかに
提出日時 2015-07-04 22:25:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,876 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 88,476 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-22 06:11:35
合計ジャッジ時間 1,691 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:76:43: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       if((abs(i-y) <= 1 && abs(j-x) == 0) || (abs(i-y) == 0 && abs(j-x) <= 1)){}
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:76:69: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       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 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;
}
0