QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#789610#9802. Light Up the GridhskWA 342ms10720kbPython31.1kb2024-11-27 21:08:142024-11-27 21:08:15

Judging History

你现在查看的是测评时间为 2024-11-27 21:08:15 的历史记录

  • [2024-11-29 22:57:25]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:344ms
  • 内存:10644kb
  • [2024-11-27 21:08:15]
  • 评测
  • 测评结果:0
  • 用时:342ms
  • 内存:10720kb
  • [2024-11-27 21:08:14]
  • 提交

answer

n,a1,a2,a3,a4=map(int,input().split())
c={
    0:2*min(a1,a2,a3,a4),
    1:a1,
    2:a1,
    3:min(a1*2,a2),
    4:a1,
    5:min(a1*2,a3),
    6:min(a1*2,a2+a3),
    7:a1+min(a2,a3,a4,2*a1),
    8:a1,
    9:min(a1*2,a2+a3),
    10:min(a1*2,a3),
    11:a1+min(a2,a3,a4,2*a1),
    12:min(a1*2,a2),
    13:a1+min(a2,a3,a4,2*a1),
    14:a1+min(a2,a3,a4,2*a1),
    15:min(a4,2*min(a2,a3,2*a1))
}
for _ in range(n):
    c1=int(input())
    c2=[0]#存点
    c3=[]
    c4=[2]*(c1+1)
    for i in range(c1):
        a=int(input(),2)
        a+=int(input(),2)*4
        a^=15
        c2.append(a)
        if i!=c1-1:
            input()
    for i in range(c1+1):
        for j in range(i+1,c1+1):
            c3.append((i,j,c[c2[i]^c2[j]]))
    c3.sort(key= lambda x:x[-1])
    t=0
    i=0
    ans=0
    while t<c1:
        sk=c3[i]
        if c4[sk[0]] and c4[sk[1]] and (t!=c1-1 or (t==c1-1  and (2 in [c4[sk[0]] , c4[sk[1]]] or c4.count(1)==4))):
            c4[sk[0]]-=1
            c4[sk[1]]-=1
            ans+=sk[2]
            t+=1
        i+=1
    print(ans)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 9ms
memory: 10580kb

input:

2 1000 100 10 1
4
10
00

01
00

00
10

00
01
1
11
11

output:

1121
2

result:

ok 2 number(s): "1121 2"

Test #2:

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

input:

2 1 1 1 1
4
10
00

01
00

00
10

00
01
1
11
11

output:

5
2

result:

ok 2 number(s): "5 2"

Test #3:

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

input:

1 1000000 1000000 1000000 1000000
1
11
11

output:

2000000

result:

ok 1 number(s): "2000000"

Test #4:

score: -100
Wrong Answer
time: 342ms
memory: 10720kb

input:

10000 8 2 7 8
8
00
01

00
11

00
10

11
11

10
10

01
10

01
00

10
11
8
11
01

11
00

01
10

11
11

00
01

01
01

01
00

11
10
9
00
00

01
01

10
11

00
01

11
10

11
00

11
11

00
11

01
10
9
11
11

10
00

11
00

11
01

00
10

01
11

00
01

01
01

10
01
11
00
01

01
01

10
10

00
11

11
11

11
10
...

output:

31
26
35
30
29
27
34
30
29
34
35
34
31
28
28
26
20
36
29
29
27
35
36
29
26
35
33
28
26
29
24
30
28
28
34
31
32
27
28
25
18
26
31
32
28
25
34
26
30
35
33
20
28
34
30
34
28
37
30
31
37
32
38
24
28
35
33
35
28
30
25
27
18
28
28
28
33
28
38
28
32
26
29
31
28
30
37
28
31
28
32
34
33
32
33
25
28
30
30
26
...

result:

wrong answer 1st numbers differ - expected: '34', found: '31'