Submission #3775190


Source Code Expand

import sys
input = sys.stdin.readline

H, W = (int(i) for i in input().split())
A = [[int(i) for i in input().split()] for j in range(H)]

reslis = []
flag = False
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            if j == W-1:
                ne = (i + 1, j)
            else:
                ne = (i, j + 1)

            if A[i][j] % 2 == 1:
                if flag:
                    flag = False
                else:
                    flag = True
            
            if flag and ne[0] <= H - 1:
                reslis.append("{} {} {} {}".format(i+1,j+1,ne[0]+1,ne[1]+1))

    else:
        for j in range(W-1, -1, -1):
            if j == 0 :
                ne = (i + 1, j)
            else:
                ne = (i, j - 1)

            if A[i][j] % 2 == 1:
                if flag:
                    flag = False
                else:
                    flag = True

            if flag and ne[0] <= H - 1:
                reslis.append("{} {} {} {}".format(i+1,j+1,ne[0]+1,ne[1]+1))

print(len(reslis))
for st in reslis:
    print(st)

Submission Info

Submission Time
Task D - Make Them Even
User hagebooi
Language PyPy3 (2.4.0)
Score 400
Code Size 1124 Byte
Status AC
Exec Time 598 ms
Memory 70108 KB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 29
AC × 3
Set Name Test Cases
All hand_1, hand_2, hand_3, hand_4, hand_5, hand_6, max_1, max_10, max_2, max_3, max_4, max_5, max_6, max_7, max_8, max_9, random_1, random_10, random_2, random_3, random_4, random_5, random_6, random_7, random_8, random_9, sample_01, sample_02, sample_03
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_1 AC 162 ms 38256 KB
hand_2 AC 167 ms 38256 KB
hand_3 AC 175 ms 38256 KB
hand_4 AC 171 ms 38256 KB
hand_5 AC 556 ms 68316 KB
hand_6 AC 229 ms 43100 KB
max_1 AC 574 ms 69596 KB
max_10 AC 588 ms 69596 KB
max_2 AC 591 ms 70108 KB
max_3 AC 595 ms 69724 KB
max_4 AC 575 ms 69852 KB
max_5 AC 575 ms 69724 KB
max_6 AC 571 ms 69980 KB
max_7 AC 575 ms 70108 KB
max_8 AC 598 ms 69596 KB
max_9 AC 580 ms 69596 KB
random_1 AC 179 ms 39024 KB
random_10 AC 271 ms 46556 KB
random_2 AC 311 ms 49756 KB
random_3 AC 339 ms 50780 KB
random_4 AC 256 ms 46044 KB
random_5 AC 285 ms 47324 KB
random_6 AC 381 ms 53084 KB
random_7 AC 323 ms 49884 KB
random_8 AC 349 ms 51932 KB
random_9 AC 427 ms 57948 KB
sample_01 AC 174 ms 38256 KB
sample_02 AC 169 ms 38256 KB
sample_03 AC 162 ms 38256 KB