結果
| 問題 | No.870 無敵囲い | 
| コンテスト | |
| ユーザー |  kekenx | 
| 提出日時 | 2020-03-06 10:08:24 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 300 ms | 
| コード長 | 1,128 bytes | 
| コンパイル時間 | 1,370 ms | 
| コンパイル使用メモリ | 169,920 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-29 06:37:50 | 
| 合計ジャッジ時間 | 2,024 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 18 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, P> P2;
int main() {
  int n;
  cin >> n;
  vector<P2> xy(n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    P one = P(x, y);
    cin >> x >> y;
    P two = P(x, y);
    xy[i] = P2(one, two);
  }
  int cx = 2, cy = 8;
  for (int i = 0; i < n; ++i) {
    P2 cur = xy[i];
    if (cur.first.first == cx && cur.first.second == cy) {
      cx = cur.second.first;
      cy = cur.second.second;
    }
  }
  if (cx != 5 || cy != 8) {
    puts("NO");
    return 0;
  }
  cx = 3; cy = 9;
  for (int i = 0; i < n; ++i) {
    P2 cur = xy[i];
    if (cur.first.first == cx && cur.first.second == cy) {
      cx = cur.second.first;
      cy = cur.second.second;
    }
  }
  if (cx != 4 || cy != 8) {
    puts("NO");
    return 0;
  }
  cx = 7; cy = 9;
  for (int i = 0; i < n; ++i) {
    P2 cur = xy[i];
    if (cur.first.first == cx && cur.first.second == cy) {
      cx = cur.second.first;
      cy = cur.second.second;
    }
  }
  if (cx != 6 || cy != 8) {
    puts("NO");
    return 0;
  }    
  puts("YES");
  return 0;
}
            
            
            
        