結果
問題 | No.2307 [Cherry 5 th Tune *] Cool 46 |
ユーザー | first_vil |
提出日時 | 2023-05-20 09:47:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 686 ms / 2,000 ms |
コード長 | 1,844 bytes |
コンパイル時間 | 1,239 ms |
コンパイル使用メモリ | 86,140 KB |
実行使用メモリ | 176,532 KB |
最終ジャッジ日時 | 2023-08-23 07:35:07 |
合計ジャッジ時間 | 42,771 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
70,996 KB |
testcase_01 | AC | 72 ms
70,800 KB |
testcase_02 | AC | 567 ms
81,344 KB |
testcase_03 | AC | 373 ms
85,948 KB |
testcase_04 | AC | 321 ms
84,092 KB |
testcase_05 | AC | 298 ms
83,608 KB |
testcase_06 | AC | 303 ms
85,932 KB |
testcase_07 | AC | 260 ms
81,664 KB |
testcase_08 | AC | 329 ms
103,972 KB |
testcase_09 | AC | 320 ms
98,848 KB |
testcase_10 | AC | 320 ms
107,152 KB |
testcase_11 | AC | 391 ms
111,272 KB |
testcase_12 | AC | 328 ms
115,412 KB |
testcase_13 | AC | 458 ms
110,652 KB |
testcase_14 | AC | 359 ms
119,748 KB |
testcase_15 | AC | 278 ms
102,100 KB |
testcase_16 | AC | 393 ms
104,836 KB |
testcase_17 | AC | 385 ms
101,204 KB |
testcase_18 | AC | 438 ms
156,764 KB |
testcase_19 | AC | 446 ms
151,544 KB |
testcase_20 | AC | 488 ms
176,188 KB |
testcase_21 | AC | 465 ms
172,292 KB |
testcase_22 | AC | 449 ms
155,376 KB |
testcase_23 | AC | 476 ms
176,040 KB |
testcase_24 | AC | 450 ms
146,596 KB |
testcase_25 | AC | 464 ms
154,400 KB |
testcase_26 | AC | 448 ms
174,872 KB |
testcase_27 | AC | 470 ms
155,052 KB |
testcase_28 | AC | 476 ms
171,260 KB |
testcase_29 | AC | 475 ms
169,812 KB |
testcase_30 | AC | 449 ms
147,752 KB |
testcase_31 | AC | 464 ms
175,636 KB |
testcase_32 | AC | 453 ms
176,532 KB |
testcase_33 | AC | 478 ms
169,296 KB |
testcase_34 | AC | 468 ms
166,360 KB |
testcase_35 | AC | 451 ms
151,152 KB |
testcase_36 | AC | 467 ms
165,292 KB |
testcase_37 | AC | 469 ms
162,112 KB |
testcase_38 | AC | 534 ms
79,056 KB |
testcase_39 | AC | 686 ms
80,404 KB |
testcase_40 | AC | 228 ms
78,360 KB |
testcase_41 | AC | 380 ms
79,540 KB |
testcase_42 | AC | 405 ms
144,812 KB |
testcase_43 | AC | 408 ms
145,524 KB |
testcase_44 | AC | 203 ms
102,612 KB |
testcase_45 | AC | 198 ms
102,676 KB |
ソースコード
from bisect import bisect_left mi=lambda: map(int,input().split()) mi1=lambda: map(lambda x: int(x)-1,input().split()) li=lambda: list(mi()) li1=lambda: list(mi1()) ii=lambda: int(input()) def buildCompressedElementsList(a,comp=[]): return sorted(set(a+comp)) def compress(a,comp): for i in range(len(a)): a[i]=bisect_left(comp,a[i]) def countListElements(a,n): # assert all(0 <= x < n for x in a) res=[0]*n for x in a: res[x]+=1 return res printRed=lambda x: print("Red", x+1) printBlue=lambda x: print("Blue", x+1) def printPair(x,redFirst=True): if redFirst: printRed(x) printBlue(x) else: printBlue(x) printRed(x) def solve(): n,m=mi() a=li1() b=li1() if n==0: print("Yes") for x in b: printBlue(x) return if m==0: print("Yes") for x in a: printRed(x) return setB=set(b) checkAnyPair=lambda: any(x in setB for x in a) if not checkAnyPair(): print("No") return comp=buildCompressedElementsList(a) comp=buildCompressedElementsList(b,comp) compress(a,comp) compress(b,comp) s=len(comp) cntA=countListElements(a,s) cntB=countListElements(b,s) red=[] blue=[] pair=[] for i in range(s): mn=min(cntA[i],cntB[i]) pair+=[i for _ in range(mn)] if cntA[i]>cntB[i]: red+=[i for _ in range(cntA[i]-cntB[i])] else: blue+=[i for _ in range(cntB[i]-cntA[i])] print("Yes") # step 1: eat red cards which doesn't has partner for x in red: printRed(comp[x]) # step 2.1: eat a pair of cards (it's guaranteed that there is at least one pair of cards, and this changes previous color to blue) printPair(comp[pair[0]], True) # step 2.2: eat blue cards which doesn't has partner for x in blue: printBlue(comp[x]) # step 2.3: eat the other pairs of cards for i in range(1,len(pair)): printPair(comp[pair[i]],(i&1)==0) for _ in range(ii()): solve()