結果

問題 No.3622 Perfect Matching of Crab
コンテスト
ユーザー hiro1729
提出日時 2026-08-14 22:53:35
言語 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
結果
AC  
実行時間 162 ms / 2,000 ms
+ 5µs
コード長 904 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,179 ms
コンパイル使用メモリ 337,844 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2026-08-14 22:54:15
合計ジャッジ時間 6,039 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int T; cin >> T;
    while (T--) {
        int N; cin >> N;
        map<int, int> mx, my;
        int xc = 0, yc = 0;
        for (int i = 0; i < 2 * N; i++) {
            int X, Y; char c;
            cin >> X >> Y >> c;
            if (c == 'x') {
                xc++;
                mx[Y]++;
            } else {
                yc++;
                my[X]++;
            }
        }
        if (xc == yc) {
            cout << "Yes\n";
        } else if (xc > yc) {
            int s = 0;
            for (auto [_, c]: mx) s += c / 2;
            cout << (s >= (xc - yc) / 2 ? "Yes\n" : "No\n");
        } else {
            int s = 0;
            for (auto [_, c]: my) s += c / 2;
            cout << (s >= (yc - xc) / 2 ? "Yes\n" : "No\n");
        }
    }
}
0