QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623125#5731. CheckerboardWill_Potato#AC ✓17ms10744kbPython31.3kb2024-10-09 10:16:422024-10-09 10:16:47

Judging History

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

  • [2024-10-09 10:16:47]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:10744kb
  • [2024-10-09 10:16:42]
  • 提交

answer

import sys
from collections import defaultdict, Counter
from itertools import permutations
from functools import cache
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp(): # For taking integer inputs.
    return(int(input()))

def inlst(): # For taking List inputs.
    return(list(map(int,input().split())))

# For taking string inputs. Actually it returns a List of Characters, instead of a string, 
def instr():
    s = input()
    return(list(s[:len(s) - 1]))

# For taking space seperated integer variable inputs.
def insep(): 
    return(map(int,input().split()))

############ ---- Problem ---- ############

R, C, A, B = inlst()
a = [inp() for _ in range(A)]
b = [inp() for _ in range(B)]

grid = []

cur_row = 0
col_count = 0
row_count = 0

for row in range(R):
    l = []
    for i, rec in enumerate(b):
        # print(cur_row)
        c = "W" if cur_row % 2 else "B"
        if i % 2 != 0:
            c = "B" if cur_row % 2 else "W"
        l.extend([c]*rec)
    grid.append(l)
    row_count += 1
    # print(row_count, a[c_row])
    if row_count == a[cur_row]:
        cur_row += 1
        row_count = 0
        # print("New row")
        

for row in grid:
    print("".join(row))

詳細信息

Test #1:

score: 100
Accepted
time: 14ms
memory: 10640kb

input:

6 5 3 2
1
2
3
3
2

output:

BBBWW
WWWBB
WWWBB
BBBWW
BBBWW
BBBWW

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 11ms
memory: 10588kb

input:

4 4 2 2
1
3
3
1

output:

BBBW
WWWB
WWWB
WWWB

result:

ok 4 lines

Test #3:

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

input:

20 20 4 14
5
2
9
4
1
2
1
1
1
1
1
1
1
1
1
1
4
3

output:

BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
WBBWBWBWBWBWBWWWWBBB
WBBWBWBWBWBWBWWWWBBB
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWBWBWBWBWBBBBWWW
BWWBWB...

result:

ok 20 lines

Test #4:

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

input:

50 2 43 2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
3
1
2
1
1
1
1
3
1
1
1
1
1
1
1

output:

BW
WB
BW
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
WB
BW
BW
WB
BW
WB
BW
WB
BW
BW
BW
WB
BW
BW
WB
BW
WB
BW
WB
WB
WB
BW
WB
BW
WB
BW

result:

ok 50 lines

Test #5:

score: 0
Accepted
time: 10ms
memory: 10744kb

input:

1 50 1 5
1
1
10
11
22
6

output:

BWWWWWWWWWWBBBBBBBBBBBWWWWWWWWWWWWWWWWWWWWWWBBBBBB

result:

ok single line: 'BWWWWWWWWWWBBBBBBBBBBBWWWWWWWWWWWWWWWWWWWWWWBBBBBB'

Test #6:

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

input:

50 1 17 1
4
1
1
1
6
2
3
1
3
5
1
4
5
1
6
2
4
1

output:

B
B
B
B
W
B
W
B
B
B
B
B
B
W
W
B
B
B
W
B
B
B
W
W
W
W
W
B
W
W
W
W
B
B
B
B
B
W
B
B
B
B
B
B
W
W
B
B
B
B

result:

ok 50 lines

Test #7:

score: 0
Accepted
time: 17ms
memory: 10624kb

input:

2 50 2 3
1
1
14
18
18

output:

BBBBBBBBBBBBBBWWWWWWWWWWWWWWWWWWBBBBBBBBBBBBBBBBBB
WWWWWWWWWWWWWWBBBBBBBBBBBBBBBBBBWWWWWWWWWWWWWWWWWW

result:

ok 2 lines

Test #8:

score: 0
Accepted
time: 17ms
memory: 10736kb

input:

50 50 29 44
2
1
1
1
2
1
3
1
1
2
3
3
1
1
2
1
1
3
2
3
3
1
1
2
1
3
1
1
2
1
1
1
2
1
1
2
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1

output:

BWBWWBWBBWBWBBWBWBWBWBWBBWBWWBWBWBWBWBWBBWBWBWBWBW
BWBWWBWBBWBWBBWBWBWBWBWBBWBWWBWBWBWBWBWBBWBWBWBWBW
WBWBBWBWWBWBWWBWBWBWBWBWWBWBBWBWBWBWBWBWWBWBWBWBWB
BWBWWBWBBWBWBBWBWBWBWBWBBWBWWBWBWBWBWBWBBWBWBWBWBW
WBWBBWBWWBWBWWBWBWBWBWBWWBWBBWBWBWBWBWBWWBWBWBWBWB
BWBWWBWBBWBWBBWBWBWBWBWBBWBWWBWBWBWBWBWBBWBWB...

result:

ok 50 lines