firedrakesin's blog

By firedrakesin, history, 5 years ago, In English

This is the code I wrote for this problem mentioned above

def mat(a,b,two): l=[] prevind=-1;i=-1;ctwo=0 for t in b: i+=1;ii=-1;dcoder="" if t=="2": ctwo+=1 m=["0" for t in range(a)] l.append(m) n=0 for tt in b: ii+=1 if i==ii: l[i][ii]="X" elif t=="1" and tt=="2": l[i][ii]="+" elif t=="1" and tt=="1": l[i][ii]="=" elif two==ctwo and t=="2" and tt=="2" and n==0: l[i][ii]="+" n+=1 elif t=="2" and tt=="2" and n==0 and ii>prevind: n+=1 prevind=ii l[i][ii]="+" else: l[i][ii]="-" dcoder+=l[i][ii] print(dcoder) for _ in range(int(input())): a=int(input()) b=input() ll=list(map(str,b)) two=ll.count("2") if two<3 and two!=0: print("NO") continue print("YES")
mat(a,b,two)

It is correct I tried on different IDE, but not showing right on codeforces. Why like that and if any error , please help me by letting me know what is it.

  • Vote: I like it
  • -25
  • Vote: I do not like it

| Write comment?
»
5 years ago, hide # |
← Rev. 7  
Vote: I like it 0 Vote: I do not like it

The check log of test #2 for your submitted code 128674490 is

wrong answer t[3][1] equals -, but t[1][3] equals - (test case 28)

Fortunately, test case 28 is visible. It is

4
2222

And the output of your code is also visible. It is

YES
X+--
-X+-
--X+
+--X

The output matrix should be anti-symmetric with respect to the win/loss outcome of player i vs player j game, i.e. if t[i][j] = '-', then t[j][i] = '+'. Otherwise, it is symmetric when the outcome of this game is tie, i.e. t[i][j] = t[j][i] = '='. However, your output matrix for test case 28 has

t[3][1] = t[1][3] = '-'
t[4][2] = t[2][4] = '-'