結果

問題 No.483 マッチ並べ
ユーザー char134217728char134217728
提出日時 2017-08-17 06:39:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,623 bytes
コンパイル時間 1,678 ms
コンパイル使用メモリ 178,412 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 15:18:17
合計ジャッジ時間 3,419 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 3 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 3 ms
5,376 KB
testcase_48 AC 9 ms
5,376 KB
testcase_49 AC 5 ms
5,376 KB
testcase_50 AC 4 ms
5,376 KB
testcase_51 AC 3 ms
5,376 KB
testcase_52 AC 3 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:18:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   18 | main(){
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ti;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

vector<ti> sat[200][2][2];
int m[2][200];
vector<pii> li[12544];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  FOR(i, 0, n){
    int a, b;
    FOR(j, 0, 2){
      cin >> a >> b;
      a = a * 112 + b;
      m[j][i] = a;
      li[a].pb(pii(i, j));
    }
    FOR(j, 0, 2){
      FOR(k, 0, 2){
        sat[i][j][k].pb(ti(pii(i, 1-j), 1-k));
      }
    }
  }
  FOR(i, 0, 12544){
    FOR(j, 0, li[i].size()){
      int f, s;
      f = li[i][j].first;
      s = li[i][j].second;
      FOR(k, 0, li[i].size()){
        if(j==k)continue;
        int _f, _s;
        _f = li[i][k].first;
        _s = li[i][k].second;
        sat[f][s][1].pb(ti(pii(_f, _s), 0));
      }
    }
  }
  set<ti> y;
  queue<ti> q;
  ti bad, tmp;
  vector<ti> tmpv;
  FOR(i, 0, n)FOR(j, 0, 2)FOR(k, 0, 2){
    y.clear();
    q.push(ti(pii(i, j), k));
    bad = ti(pii(i, j), k-1);
    while(!q.empty()){
      tmp = q.front();
      q.pop();
      y.insert(tmp);
      if(tmp == bad){
        cout << "NO" << endl;
        return 0;
      }
      tmpv = sat[tmp.first.first][tmp.first.second][tmp.second];
      for(vector<ti>::iterator itr = tmpv.begin(); itr != tmpv.end(); itr++){
        if(y.find(*itr) == y.end()){
          q.push(*itr);
        }
      }
    }
  }
  cout << "YES" << endl;
}
0