QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#770971#1965. TriovwxyzTL 83ms11428kbPython3743b2024-11-22 06:34:282024-11-22 06:34:30

Judging History

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

  • [2024-11-22 06:34:30]
  • 评测
  • 测评结果:TL
  • 用时:83ms
  • 内存:11428kb
  • [2024-11-22 06:34:28]
  • 提交

answer

from collections import defaultdict
import itertools

N=int(input())
S=[input() for i in range(N)]
ans=0
dct=defaultdict(int)
for b in range(N):
    for c in range(b+1,N):
        T=[]
        cnt=0
        for i in range(4):
            T.append([])
            if S[b][i]==S[c][i]:
                T[-1].append(S[b][i])
            else:
                T[-1].append("*")
                T[-1].append(S[b][i])
                T[-1].append(S[c][i])
                cnt+=1
        for tpl in itertools.product(*[T[i] for i in range(4)]):
            ans+=dct["".join(tpl)]*(-1)**(cnt-tpl.count("*"))
    for tpl in itertools.product(*["*"+S[b][i] for i in range(4)]):
        dct["".join(tpl)]+=1
print(ans)            

详细

Test #1:

score: 100
Accepted
time: 12ms
memory: 10640kb

input:

4
1234
2345
3456
4567

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 13ms
memory: 10708kb

input:

9
1299
2399
3499
4599
5699
6799
7899
8999
9199

output:

84

result:

ok single line: '84'

Test #3:

score: 0
Accepted
time: 8ms
memory: 10776kb

input:

9
1239
2349
3459
4569
5679
6789
7899
8919
9129

output:

84

result:

ok single line: '84'

Test #4:

score: 0
Accepted
time: 15ms
memory: 10620kb

input:

9
1999
2999
3999
4999
5999
6999
7999
8999
9999

output:

84

result:

ok single line: '84'

Test #5:

score: 0
Accepted
time: 0ms
memory: 10876kb

input:

9
1234
2345
3456
4567
5678
6789
7891
8912
9123


output:

84

result:

ok single line: '84'

Test #6:

score: 0
Accepted
time: 14ms
memory: 10796kb

input:

18
1211
2311
3411
4511
5611
6711
7811
8911
9111
1222
2322
3422
4522
5622
6722
7822
8922
9122

output:

168

result:

ok single line: '168'

Test #7:

score: 0
Accepted
time: 12ms
memory: 10652kb

input:

17
1211
2311
3411
4511
5611
6711
7811
8911
9111
1231
2341
3451
4561
5671
6781
7891
9121

output:

336

result:

ok single line: '336'

Test #8:

score: 0
Accepted
time: 83ms
memory: 11428kb

input:

81
1211
2311
3411
4511
5611
6711
7811
8911
9111
1222
2322
3422
4522
5622
6722
7822
8922
9122
1233
2333
3433
4533
5633
6733
7833
8933
9133
1244
2344
3444
4544
5644
6744
7844
8944
9144
1255
2355
3455
4555
5655
6755
7855
8955
9155
1266
2366
3466
4566
5666
6766
7866
8966
9166
1277
2377
3477
4577
5677
67...

output:

43848

result:

ok single line: '43848'

Test #9:

score: 0
Accepted
time: 12ms
memory: 10596kb

input:

17
3433
3443
3444
3434
3333
3334
3343
3344
4333
4343
4334
4344
4433
4434
4444
4443
5678

output:

8

result:

ok single line: '8'

Test #10:

score: 0
Accepted
time: 7ms
memory: 10656kb

input:

21
1111
1113
1131
1133
1222
1312
1321
1323
1332
2122
2322
3112
3121
3123
3132
3222
3311
3313
3331
3333
4567

output:

28

result:

ok single line: '28'

Test #11:

score: -100
Time Limit Exceeded

input:

500
5225
6396
8284
5729
9576
3159
1831
9314
5674
4164
5166
5513
1765
8333
9921
7856
3789
6129
3882
1462
1322
5932
6859
1794
6426
8336
3265
2938
4487
7143
3653
4218
7814
3521
3349
5331
3486
7264
5385
8724
7421
5736
9875
9432
1588
5758
4319
9649
4224
6841
9639
1774
1551
9761
1944
3979
7682
5599
4289
7...

output:


result: