結果

問題 No.483 マッチ並べ
ユーザー ikdikd
提出日時 2017-02-10 23:57:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 985 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 78,000 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-28 12:29:29
合計ジャッジ時間 2,625 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>

using namespace std;
typedef pair<int, int> pii;
map<pii, vector<pii>> g;
int N;
map<pii, int> used;
int x[101], y[101];

bool rec(int p, int q, int i, int j){

   used[pii(i, j)]=1;
   bool ret=true;
   for(pii z: g[pii(i, j)]){
      //cout<<p<<" "<<q<<" "<< i<<" "<<j<<" "<<z.first<<" "<<z.second<< endl;
      if(z.first==p&&z.second==q) continue;
      if(used[pii(z.first, z.second)]) return false;
      ret&=rec(i, j, z.first, z.second);
   }

   return ret;
}

int main(){

   cin>> N;
   for(int i=0; i<N; i++){
      int a, b, c, d;
      cin>> a>> b>> c>> d;
      //a--; b--; c--; d--;
      g[pii(a, b)].push_back(pii(c, d));
      g[pii(c, d)].push_back(pii(a, b));
      x[i]=a; y[i]=b;
   }

   bool ok=true;
   for(int i=0; i<N; i++){
      if(used[pii(x[i], y[i])]==1) continue;
      ok&=rec(-1, -1, x[i], y[i]);
   }

   if(ok){
      cout<< "YES"<< endl;
   }else{
      cout<< "NO"<< endl;
   }

   return 0;
}
0