QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667484#2412. Canvas Linetassei903#WA 10ms10784kbPython3908b2024-10-22 23:28:262024-10-22 23:28:36

Judging History

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

  • [2024-10-22 23:28:36]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:10784kb
  • [2024-10-22 23:28:26]
  • 提交

answer


n = int(input())
l, r = zip(*[map(int, input().split()) for i in range(n)])
p = int(input())
x = list(map(int, input().split()))
l = list(l)
r = list(r)
from bisect import bisect_left as bl
X = set(x)
last = 2

rest = []
for i in range(n):
    cnt = bl(x, r[i] + 1) - bl(x, l[i])
    if cnt > 2:
        print("impossible")
        exit()
    rest.append(2 - cnt)

i = 0
ans = []
while i < n:
    if rest[i] == 0:
        i += 1
        continue
    j = i
    while j + 1 < n and r[j] == l[j+1] and rest[j+1] and (not r[j] in X):
        j += 1
    
    for k in range(i, j):
        if rest[k] and rest[k+1]:
            ans.append(r[k])
            rest[k] -= 1
            rest[k+1] -= 1
    i = j + 1

for i in range(n):
    j = l[i] + 1
    while rest[i]:
        if not j in X:
            ans.append(j)
            rest[i] -= 1

print(len(ans))
print(*ans)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 10ms
memory: 10684kb

input:

5
0 100
100 200
200 300
300 400
400 500
2
100 200

output:

4
300 400 1 401

result:

ok 

Test #2:

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

input:

20
0 100
100 200
200 300
300 400
400 500
500 600
600 700
700 800
800 900
900 1000
1000 1100
1100 1200
1200 1300
1300 1400
1400 1500
1500 1600
1600 1700
1700 1800
1800 1900
1900 2000
3
300 900 2000

output:

18
100 200 400 500 600 700 800 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 1

result:

ok 

Test #3:

score: -100
Wrong Answer
time: 7ms
memory: 10784kb

input:

300
0 10
10 20
20 30
30 40
40 50
50 60
60 70
70 80
80 90
90 100
100 110
110 120
120 130
130 140
140 150
150 160
160 170
170 180
180 190
190 200
200 210
210 220
220 230
230 240
240 250
250 260
260 270
270 280
280 290
290 300
300 310
310 320
320 330
330 340
340 350
350 360
360 370
370 380
380 390
390 ...

output:

299
10 50 60 70 80 100 110 130 160 170 180 190 200 220 230 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 450 460 470 480 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820 830 840 8...

result:

wrong answer Team has multiple pegs at x=21