結果

問題 No.483 マッチ並べ
ユーザー Yut176Yut176
提出日時 2017-02-11 00:10:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,237 bytes
コンパイル時間 963 ms
コンパイル使用メモリ 92,688 KB
実行使用メモリ 11,436 KB
最終ジャッジ日時 2023-08-28 12:30:44
合計ジャッジ時間 5,791 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,760 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 4 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 6 ms
4,384 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 23 ms
4,376 KB
testcase_20 WA -
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 AC 8 ms
4,380 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 10 ms
4,380 KB
testcase_28 AC 365 ms
5,084 KB
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;

int a = 0;

int dfs(int sy, int sx, int gy, int gx, vector< vector<int> > m, vector< vector<bool> > f, int p){
  int dx[4] = {0, 1, 0, -1};
  int dy[4] = {-1, 0, 1, 0};
  if( sy == gy && sx == gx && p >= 3){
    a++;
    return a;
  }

  for(int i=0; i<4; i++){

    if( !f[ sy+dy[i] ][ sx + dx[i] ] && m[ sy+dy[i] ][ sx + dx[i] ] != 0 ){
      f[ sy+dy[i] ][ sx+dx[i] ] = true;
      dfs(sy+dy[i], sx+dx[i], gy, gx, m, f, p+1);
    }

  }
  return 0;
}


int main(){

  int n;
  cin >> n;
  vector< vector<int> > m(120, vector<int>(120, 0));
  for(int i=0; i<n; i++){
    int r0, c0, r1, c1;
    cin >> r0 >> c0 >> r1 >> c1;

    m[r0][c0]++;
    m[r1][c1]++;
    // if( m[r0][c0] >= 3 || m[] )
  }
  vector< vector<bool> > f(120, vector<bool>(120, false));
  for(int i=1; i<115; i++){
    for(int j=1; j<115; j++){

      if( m[i][j] != 0 ){
        dfs(i, j, i, j, m, f, 0);
      }
      if( a >= 2 ){
        cout << "NO" << endl;
        return 0;
      }
      a = 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}
0