QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789587#9802. Light Up the GridhskRE 14ms10700kbPython31.1kb2024-11-27 21:00:052024-11-27 21:00:09

Judging History

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

  • [2024-11-29 22:57:15]
  • 管理员手动重测本题所有提交记录
  • 测评结果:RE
  • 用时:15ms
  • 内存:10636kb
  • [2024-11-27 21:00:09]
  • 评测
  • 测评结果:0
  • 用时:14ms
  • 内存:10700kb
  • [2024-11-27 21:00:05]
  • 提交

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]]])):
            c4[sk[0]]-=1
            c4[sk[1]]-=1
            ans+=sk[2]
            t+=1
        i+=1
    print(ans)

詳細信息

Test #1:

score: 100
Accepted
time: 14ms
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: 14ms
memory: 10700kb

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: 11ms
memory: 10580kb

input:

1 1000000 1000000 1000000 1000000
1
11
11

output:

2000000

result:

ok 1 number(s): "2000000"

Test #4:

score: -100
Dangerous Syscalls

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:


result: