QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#837839#9574. StripsYinyuDreamWA 16ms10688kbPython31.8kb2024-12-30 14:55:552024-12-30 14:56:06

Judging History

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

  • [2024-12-30 14:56:06]
  • 评测
  • 测评结果:WA
  • 用时:16ms
  • 内存:10688kb
  • [2024-12-30 14:55:55]
  • 提交

answer

def main():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    index = 0
    T = int(data[index])
    index += 1
    results = []
    
    for _ in range(T):
        n = int(data[index])
        m = int(data[index + 1])
        k = int(data[index + 2])
        w = int(data[index + 3])
        index += 4
        
        a = list(map(int, data[index:index + n]))
        index += n
        b = list(map(int, data[index:index + m]))
        index += m
        
        a.sort()
        b.sort()
        
        b = [0] + b + [w + 1]
        
        paper_strips = []
        red_ptr = 0
        num_red = n
        
        for i in range(len(b) - 1):
            left = b[i] + 1
            right = b[i + 1] - 1
            if left > right:
                continue
            while red_ptr < num_red and a[red_ptr] < left:
                red_ptr += 1
            while red_ptr < num_red and a[red_ptr] <= right:
                pos = a[red_ptr]
                start = pos - k + 1
                if start < left:
                    start = left
                if start + k - 1 > right:
                    results.append(-1)
                    break
                paper_strips.append(start)
                cover_end = start + k
                while red_ptr < num_red and a[red_ptr] < cover_end:
                    red_ptr += 1
            else:
                continue
            break
        else:
            if red_ptr == num_red:
                c = len(paper_strips)
                results.append(c)
                results.append(' '.join(map(str, sorted(paper_strips))))
                continue
        results.append(-1)
    
    print('\n'.join(map(str, results)))

if __name__ == "__main__":
    main()

详细

Test #1:

score: 0
Wrong Answer
time: 16ms
memory: 10688kb

input:

4
5 2 3 16
7 11 2 9 14
13 5
3 2 4 11
6 10 2
1 11
2 1 2 6
1 5
3
2 1 2 6
1 5
2

output:

5
1 6 7 9 14
3
2 3 7
2
1 4
-1
-1

result:

wrong answer There are more than one stripe covering cell 7 (test case 1)