結果
| 問題 | No.3622 Perfect Matching of Crab |
| コンテスト | |
| ユーザー |
テナガザル
|
| 提出日時 | 2026-08-14 22:04:12 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 327 ms / 2,000 ms |
| + 133µs | |
| コード長 | 797 bytes |
| 記録 | |
| コンパイル時間 | 1,004 ms |
| コンパイル使用メモリ | 181,708 KB |
| 実行使用メモリ | 14,592 KB |
| 最終ジャッジ日時 | 2026-08-14 22:04:19 |
| 合計ジャッジ時間 | 6,714 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
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];
map<int, int> sx, sy;
for (int i = 0; i < 2 * n; ++i)
{
if (c[i] == 'x')
{
++sy[y[i]];
}
else if (c[i] == 'y')
{
++sx[x[i]];
}
}
int mx = 0, cx = 0;
for (auto [xx, c] : sx)
{
mx += c % 2;
cx += c;
}
int my = 0, cy = 0;
for (auto [yy, c] : sy)
{
my += c % 2;
cy += c;
}
if (cx < cy)
{
swap(cx, cy);
swap(mx, my);
}
int ans = (mx <= cy && cy <= cx);
cout << (ans ? "Yes" : "No") << endl;
}
int main()
{
int t;
cin >> t;
while (t--) solve();
}
テナガザル