結果
問題 | No.1328 alligachi-problem |
ユーザー |
![]() |
提出日時 | 2021-01-08 20:52:05 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,909 bytes |
コンパイル時間 | 99 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 260,736 KB |
最終ジャッジ日時 | 2024-11-16 08:46:30 |
合計ジャッジ時間 | 44,733 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
11,136 KB |
testcase_01 | AC | 27 ms
10,880 KB |
testcase_02 | AC | 29 ms
11,008 KB |
testcase_03 | AC | 28 ms
10,880 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 38 ms
13,312 KB |
testcase_07 | WA | - |
testcase_08 | AC | 32 ms
11,904 KB |
testcase_09 | TLE | - |
testcase_10 | AC | 1,999 ms
259,584 KB |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | AC | 1,996 ms
259,584 KB |
testcase_16 | TLE | - |
testcase_17 | WA | - |
testcase_18 | TLE | - |
testcase_19 | WA | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | TLE | - |
ソースコード
def main(n,cxy): # xで分類 bary=[[set(),set()] for _ in range(n+1)] rary=[[set(),set()] for _ in range(n+1)] dc={'B':0,'R':1} B=0 R=1 for i,(c,x,y) in enumerate(cxy): if x=='B': bary[int(y)][dc[c]].add(i+1) else: rary[int(y)][dc[c]].add(i+1) # bart[i][B]:青がi個の状態で列に加えないといけない青ボール。 # bart[i][R]:青がi個の状態で列に加えないといけない赤ボール。 # rart[i][B]:赤がi個の状態で列に加えないといけない青ボール。 # rart[i][R]:赤がi個の状態で列に加えないといけない赤ボール。 numb=0 numr=0 ret=[] while len(ret)<n: if bary[numb][R] and rary[numr][B]:return [-1] elif bary[numb][R] and rary[numr][R]: ret.append(rary[numr][R].pop()) numr+=1 elif rary[numr][B] and bary[numb][B]: ret.append(bary[numb][B].pop()) numb+=1 elif bary[numb][B] and rary[numr][B]: ret.append(bary[numb][B].pop()) numb+=1 elif bary[numb][R] and rary[numr][R]: ret.append(rary[numr][R].pop()) numr+=1 elif bary[numb][B]: ret.append(bary[numb][B].pop()) numb+=1 elif bary[numb][R]: ret.append(bary[numb][R].pop()) numr+=1 elif rary[numr][B]: ret.append(rary[numr][B].pop()) numb+=1 elif rary[numr][R]: ret.append(rary[numr][R].pop()) numr+=1 else: return [-1] return ret def chk(n,cxy,ret): numb=0 numr=0 for i in ret: i-=1 c,x,y=cxy[i] y=int(y) if x=='R': if numr!=y:return False elif x=='B': if numb!=y:return False if c=='R': numr+=1 else: numb+=1 return True if __name__ == "__main__": n=int(input()) cxy=[list(input().split()) for _ in range(n)] ret=main(n,cxy) if ret[0]==-1: print('No') else: print('Yes') print(*ret) #print(chk(n,cxy,ret))