QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#428958#8780. Training, Round 2ucup-team3646#WA 9ms9464kbPython32.5kb2024-06-01 23:21:462024-06-01 23:21:46

Judging History

你现在查看的是最新测评结果

  • [2024-06-01 23:21:46]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:9464kb
  • [2024-06-01 23:21:46]
  • 提交

answer

op=[]

debug=0
def swap(frm,col_f,to,col_t):
  # cycle frm の色 col_f と,cycle to の色 col_t を swap
  
  idx1=S[frm].index(col_f)
  # これを 0 にもってくる 
  if idx1!=0:
    op.append([frm,(-idx1)%10])
    for _ in range((-idx1)%10):
      S[frm]=S[frm][9:]+S[frm][:9]
  
    if debug:
      for i in S:
        print(''.join(i))
      print()
  
  idx2=S[to].index(col_t)
  # これを 3 にもってくる
  if idx2!=3:
    op.append([to,(3-idx2)%10])
    for _ in range((3-idx2)%10):
      S[to]=S[to][9:]+S[to][:9]
    if debug:
      for i in S:
        print(''.join(i))
      print()
  # 真ん中を回す
  if (frm-to)%3!=0:
    op.append([-1,(frm-to)%3])
    for _ in range((frm-to)%3):
      S[0][:3],S[1][:3],S[2][:3]=S[1][:3],S[2][:3],S[0][:3]
    if debug:
      for i in S:
        print(''.join(i))
      print()
  
  # to を回す
  op.append([to,9])
  for _ in range(9):
    S[to]=S[to][9:]+S[to][:9]
  if debug:
    for i in S:
      print(''.join(i))
    print()
  # 真ん中を回す
  if (to-frm)%3!=0:
    op.append([-1,(to-frm)%3])
    for _ in range((to-frm)%3):
      S[0][:3],S[1][:3],S[2][:3]=S[1][:3],S[2][:3],S[0][:3]
    if debug:
      for i in S:
        print(''.join(i))
      print()
  
  

S=[list(input()) for i in range(3)]
memo=[i.copy() for i in S]

C='ogr'
for frm in range(3):
  for frm_col in C:
    if frm_col==C[frm]:
      continue
    for to in range(3):
      if frm==to:
        continue
      for to_col in C:
        if to_col==C[to]:
          continue
        
        while frm_col in S[frm] and to_col in S[to]:
          swap(frm,frm_col,to,to_col)

print(len(op))
op2=[]
for p,c in op:
  if p==-1:
    print('c'+str(c))
    op2.append('c'+str(c))
  elif p==0:
    print('o'+str(c))
    op2.append('o'+str(c))
  elif p==1:
    print('g'+str(c))
    op2.append('g'+str(c))
  else:
    print('f'+str(c))
    op2.append('r'+str(c))

def judge():
  S=[i.copy() for i in memo]
  for t in op2:
    assert t[1]!='0'
    c=int(t[1])
    if t[0]=='c':
      assert t[1]=='1' or t[1]=='2'
      S[0][:3],S[1][:3],S[2][:3]=S[1][:3],S[2][:3],S[0][:3]
    elif t[0]=='o':
      for i in range(c):
        S[0]=S[to][9:]+S[0][:9]
    elif t[0]=='g':
      for i in range(c):
        S[1]=S[1][9:]+S[1][:9]
    elif t[0]=='r':
      for i in range(c):
        S[2]=S[2][9:]+S[2][:9]
    else:
      assert 0
  
  for i in S:
    print(''.join(i))

judge()

詳細信息

Test #1:

score: 0
Wrong Answer
time: 9ms
memory: 9464kb

input:

3 0 0
0 1 0 1
1 1 0 1
1 1 1 1

output:

0
3 0 0
0 1 0 1
1 1 0 1

result:

wrong answer 1st lines differ - expected: '3', found: '0'