結果

問題 No.1328 alligachi-problem
ユーザー persimmon_t01persimmon_t01
提出日時 2021-01-08 21:21:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 2,253 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 13,184 KB
実行使用メモリ 261,504 KB
最終ジャッジ日時 2024-04-28 01:44:40
合計ジャッジ時間 47,514 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
11,136 KB
testcase_01 AC 31 ms
11,008 KB
testcase_02 AC 30 ms
11,008 KB
testcase_03 AC 30 ms
11,008 KB
testcase_04 AC 44 ms
13,440 KB
testcase_05 AC 44 ms
13,568 KB
testcase_06 AC 42 ms
13,696 KB
testcase_07 AC 47 ms
13,952 KB
testcase_08 AC 36 ms
11,904 KB
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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:
    ary=[len(bary[numb][B])>0,len(rary[numr][B])>0,len(bary[numb][R])>0,len(rary[numr][R])>0]
    num=0
    for i in range(4):
      if ary[i]:num+=1<<i
    if ary[1] and ary[2]:
      return [-1]
    elif num==0:
      return [-1]
    elif num==1:
      ret.append(bary[numb][B].pop())
      numb+=1
    elif num==2:
      ret.append(rary[numr][B].pop())
      numb+=1
    elif num==4:
      ret.append(bary[numb][R].pop())
      numr+=1
    elif num==8:
      ret.append(rary[numr][R].pop())
      numr+=1
    elif num==3:
      ret.append(bary[numb][B].pop())
      numb+=1
    elif num==5:
      ret.append(bary[numb][R].pop())
      numr+=1
    elif num==6:pass
    elif num==7:pass
    elif num==9:
      ret.append(bary[numb][B].pop())
      numb+=1
      ret.append(rary[numr][R].pop())
      numr+=1
    elif num==10:
      ret.append(rary[numr][B].pop())
      numb+=1
    elif num==11:
      ret.append(bary[numb][B].pop())
      numb+=1
    elif num==12:
      ret.append(rary[numr][R].pop())
      numr+=1
    elif num==13:
      ret.append(rary[numr][R].pop())
      numr+=1
    elif num==14:pass
    elif num==15:pass
  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)
0