QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#378139 | #7926. Color Inversion on a Huge Chessboard | kevinyang# | RE | 15ms | 12272kb | Python3 | 612b | 2024-04-06 06:55:20 | 2024-04-06 06:55:21 |
Judging History
answer
n, q = [int(i) for i in input().split()]
a = [i%2 for i in range(n)]
b = [i%2 for i in range(n)]
acnt = n
bcnt = n
def toggle(arr, pos):
arr[pos] = 1-arr[pos]
if pos == 0:
return -1 if arr[0] == arr[1] else 1
if pos == n-1:
return -1 if arr[n-1] == arr[n-2] else 1
return -2 if arr[pos-1] == arr[pos] == arr[pos+1] else 2
for _ in range(q):
type, pos = input().split()
pos = int(pos)
pos -= 1
if type == 'COLUMN':
acnt += toggle(a, pos)
if type == 'ROW':
bcnt += toggle(b, pos)
print(acnt*bcnt)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 9588kb
input:
3 3 ROW 2 COLUMN 3 ROW 2
output:
3 2 6
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 15ms
memory: 12272kb
input:
200000 2 ROW 1 ROW 1
output:
39999800000 40000000000
result:
ok 2 lines
Test #3:
score: -100
Dangerous Syscalls
input:
1 1 COLUMN 1