QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#734235#9714. A Colorful Gridriad_alarefiWA 15ms10512kbPython31.9kb2024-11-11 07:28:202024-11-11 07:28:23

Judging History

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

  • [2024-11-11 07:28:23]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:10512kb
  • [2024-11-11 07:28:20]
  • 提交

answer

def solve():
    import sys
    input = sys.stdin.read
    data = input().split()
    
    index = 0
    T = int(data[index])
    index += 1
    results = []
    
    for t in range(T):
        n = int(data[index])
        m = int(data[index + 1])
        k = int(data[index + 2])
        index += 3
        
        conditions = []
        for _ in range(k):
            x1 = int(data[index])
            y1 = int(data[index + 1])
            x2 = int(data[index + 2])
            y2 = int(data[index + 3])
            c = int(data[index + 4])
            conditions.append((x1, y1, x2, y2, c))
            index += 5
        
        grid = [['L' for _ in range(m)] for _ in range(n)]
        possible = True
        
        for (x1, y1, x2, y2, c) in conditions:
            if (x2, y2) == (x1, y1 + 1):
                if c == 0:
                    if grid[x1-1][y1-1] == 'L':
                        grid[x1-1][y1-1] = 'R'
                    elif grid[x1-1][y1-1] == 'R':
                        possible = False
                else:
                    if grid[x1-1][y1-1] == 'L':
                        grid[x1-1][y1-1] = 'R'
                    grid[x2-1][y2-1] = 'L'
            elif (x2, y2) == (x1 + 1, y1):
                if c == 0:
                    if grid[x1-1][y1-1] == 'L':
                        grid[x1-1][y1-1] = 'D'
                    elif grid[x1-1][y1-1] == 'D':
                        possible = False
                else:
                    if grid[x1-1][y1-1] == 'L':
                        grid[x1-1][y1-1] = 'D'
                    grid[x2-1][y2-1] = 'U'
        
        if possible:
            results.append(f"Case #{t + 1}: Yes")
            for row in grid:
                results.append(''.join(row))
        else:
            results.append(f"Case #{t + 1}: No")
    
    print('\n'.join(results))

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 15ms
memory: 10512kb

input:

4
2 2 1
1 1 1 2 1
2 2 1
1 1 2 1 1
2 2 1
1 1 2 2 1
2 2 2
1 1 1 2 0
1 1 2 1 0

output:


result:

wrong output format Unexpected end of file - token expected