結果

問題 No.3622 Perfect Matching of Crab
コンテスト
ユーザー titia
提出日時 2026-08-15 01:16:46
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 467 ms / 2,000 ms
+ 15µs
コード長 1,144 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 291 ms
コンパイル使用メモリ 21,412 KB
実行使用メモリ 23,196 KB
最終ジャッジ日時 2026-08-15 01:16:55
合計ジャッジ時間 8,413 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

T=int(input())

for tests in range(T):
    N=int(input())

    X=[]
    Y=[]

    for i in range(2*N):
        x,y,c=input().split()
        x=int(x)
        y=int(y)

        if c=="x":
            X.append(y)
        else:
            Y.append(x)

    X.sort()
    Y.sort()

    if len(X)==len(Y):
        print("Yes")
    else:
        if len(X)<len(Y):
            k=len(Y)-len(X)

            ind=0
            score=0
            while ind<len(Y):
                if ind+1<len(Y) and Y[ind]==Y[ind+1]:
                    ind+=2
                    score+=2
                    continue
                ind+=1

            if score>=k:
                print("Yes")
            else:
                print("No")
        else:
            k=len(X)-len(Y)

            ind=0
            score=0
            while ind<len(X):
                if ind+1<len(X) and X[ind]==X[ind+1]:
                    ind+=2
                    score+=2
                    continue
                ind+=1

            if score>=k:
                print("Yes")
            else:
                print("No")

            
0