結果

問題 No.3622 Perfect Matching of Crab
コンテスト
ユーザー vjudge1
提出日時 2026-08-21 20:04:53
言語 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  
実行時間 -
コード長 1,057 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,156 ms
コンパイル使用メモリ 332,900 KB
実行使用メモリ 9,412 KB
最終ジャッジ日時 2026-08-21 20:05:03
合計ジャッジ時間 9,364 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 7 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>//???????
using namespace std;
int t;
int n;
struct node{
	int x,y;
	char c;
}a[200010];
int cntx,cnty;
int main(){
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=2*n;i++){
			cin>>a[i].x>>a[i].y>>a[i].c;
			if(a[i].c=='x') cntx++;
			else cnty++;
		}
		if(!(cntx-cnty)){
			cout<<"Yes\n";
			continue;
		}
		for(int i=1;i<=2*n;i++){
			for(int j=1;j<=2*n;j++){
				if(i==j) continue;
				if(a[i].c==a[j].c && a[i].x!=INT_MAX && a[j].x!=INT_MAX){
					if(a[i].c=='x'){
						if(a[i].y==a[j].y){
							a[i].x=INT_MAX;
							a[j].x=INT_MAX;
						}
					}
					if(a[i].c=='y'){
						if(a[i].x==a[j].x){
							a[i].x=INT_MAX;
							a[j].x=INT_MAX;
						}
					}
				}
			}
		}
		for(int i=1;i<=2*n;i++){
			for(int j=1;j<=2*n;j++){
				if(i==j) continue;
				if(a[i].c=='x' && a[j].c=='y' && a[i].x!=INT_MAX && a[j].x!=INT_MAX){
					a[i].x=INT_MAX;
					a[j].x=INT_MAX;
				}
			}
		}
		bool f=1;
		for(int i=1;i<=2*n;i++){
			if(a[i].x!=INT_MAX && f){
				cout<<"No\n";
				f=0;
			}
		}
		if(f) cout<<"Yes\n";
	}
	return 0;
}
0