結果

問題 No.3622 Perfect Matching of Crab
コンテスト
ユーザー yaaya
提出日時 2026-08-14 21:27:55
言語 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  
実行時間 203 ms / 2,000 ms
+ 757µs
コード長 1,783 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,019 ms
コンパイル使用メモリ 341,360 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2026-08-14 21:28:11
合計ジャッジ時間 5,518 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define ll long long
#define ull unsigned ll
#define ld long double
#define bl __int128_t
#define fi first
#define se second
#define vel vector<ll>
#define vvel vector<vel>
#define pll pair<ll,ll>
#define vepll vector<pll>
#define vvepll vector<vepll>
#define ves vector<string>
#define vem vector<mint>
#define vvem vector<vem>
#define pmm pair<mint,mint>
#define cleout(i) cout<<fixed<<setprecision(i)
template<class T>using PQ=priority_queue<T,vector<T>,greater<T>>;
//               上  右 下 左
vector<int> di={-1, 0, 1, 0};
vector<int> dj={ 0, 1, 0,-1};

vector<int> dx={ 0, 1, 0,-1};
vector<int> dy={ 1, 0,-1, 0};


vector<int> ddx={ 1, 1, 1, 0, -1, -1, -1, 0 };
vector<int> ddy={ 1, 0, -1, -1, -1, 0, 1, 1 };

ll inf=1000000000000000000;//1e18
// LLONG_MAX

mt19937_64 rng((ull)chrono::steady_clock::now().time_since_epoch().count());

//[x^M]1/(1-x)^N=comb(N-1+M,M)

void _solve(){
    ll N;
    cin>>N;
    map<ll,ll> X,Y;
    rep(i,0,2*N){
        ll x,y;
        cin>>x>>y;
        char c;
        cin>>c;
        if(c=='x'){
            X[y]++;
        }else Y[x]++;
    }
    ll x=0;
    ll y=0;
    ll xx=0;
    ll yy=0;
    for(auto it=X.begin();it!=X.end();it++){
        x+=it->se/2*2;
        xx+=it->se%2;
    }
    for(auto it=Y.begin();it!=Y.end();it++){
        y+=it->se/2*2;
        yy+=it->se%2;
    }
    ll M=max(xx,yy);
    x+=xx;
    y+=yy;
    x-=M;
    y-=M;
    if(0<=y&&0<=x){
        cout<<"Yes\n";
    }else cout<<"No\n";
}


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

    
    ll _;
    bool multitest=1;
    if(multitest)cin>>_;
    else _=1;
    rep(__,0,_){
        _solve();
    }
}
0