結果

問題 No.3622 Perfect Matching of Crab
コンテスト
ユーザー テナガザル
提出日時 2026-08-14 21:41:03
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 583 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 926 ms
コンパイル使用メモリ 179,196 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2026-08-14 21:41:10
合計ジャッジ時間 6,115 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

void solve()
{
  int n;
  cin >> n;
  vector<int> x(2 * n), y(2 * n);
  vector<char> c(2 * n);
  for (int i = 0; i < 2 * n; ++i) cin >> x[i] >> y[i] >> c[i];
  set<int> sx, sy;
  for (int i = 0; i < 2 * n; ++i)
  {
    if (c[i] == 'x')
    {
      sy.insert(y[i]);
    }
    else if (c[i] == 'y')
    {
      sx.insert(x[i]);
    }
  }
  int ans = (sx.size() <= n && sy.size() <= n);
  cout << (ans ? "Yes" : "No") << endl;
}

int main()
{
  int t;
  cin >> t;
  while (t--) solve(); 
}
0