Submission #53847398


Source Code Expand

# ojp

import sys
# sys.setrecursionlimit((1<<30)-1)
# from math import gcd, lcm
# from copy import deepcopy
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# import bisect
# import numpy as np
# import atcoder as ac
# from atcoder.segtree import SegTree
# from atcoder.lazysegtree import LazySegTree
# from atcoder.fenwicktree import FenwickTree
# ???from heapq import heappop, heappush
input = lambda: sys.stdin.readline().rstrip()
_m = lambda type=int: map(type, input().split())
_l = lambda type=int: list(_m(type=type))
_mtx = lambda x, type=int: [_l(type=type) for _ in range(x)]
INF=10 ** 18

ans = 0
# n = int(input())
n,t = _m()
a = _l()
# a = list(input())
# a = _mtx(n)

row=[n]*n
col=[n]*n
nan1=n
nan2=n

for i in range(t):
    ai=a[i]
    ai-=1
    h=ai//n
    w=ai%n
    row[h]-=1
    col[w]-=1
    if h==w:
        nan1-=1
    if h+w==n-1:
        nan2-=1

    if row[h]==0 or col[w]==0 or nan1==0 or nan2==0:
        print(i+1)
        exit()

print(-1)

Submission Info

Submission Time
Task C - Bingo 2
User hoboki
Language Python (PyPy 3.10-v7.3.12)
Score 300
Code Size 1077 Byte
Status AC
Exec Time 86 ms
Memory 113384 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 39
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 54 ms 76620 KiB
00_sample_01.txt AC 55 ms 76512 KiB
00_sample_02.txt AC 54 ms 76316 KiB
01_random_00.txt AC 54 ms 76428 KiB
01_random_01.txt AC 55 ms 76612 KiB
01_random_02.txt AC 54 ms 76456 KiB
01_random_03.txt AC 54 ms 76584 KiB
01_random_04.txt AC 58 ms 81616 KiB
01_random_05.txt AC 55 ms 76444 KiB
01_random_06.txt AC 54 ms 76504 KiB
01_random_07.txt AC 54 ms 76488 KiB
01_random_08.txt AC 83 ms 112720 KiB
01_random_09.txt AC 83 ms 113048 KiB
01_random_10.txt AC 84 ms 112956 KiB
01_random_11.txt AC 84 ms 112808 KiB
01_random_12.txt AC 83 ms 113384 KiB
01_random_13.txt AC 81 ms 113088 KiB
01_random_14.txt AC 82 ms 112320 KiB
01_random_15.txt AC 84 ms 112316 KiB
01_random_16.txt AC 82 ms 112324 KiB
01_random_17.txt AC 83 ms 112336 KiB
01_random_18.txt AC 84 ms 112168 KiB
01_random_19.txt AC 83 ms 112704 KiB
01_random_20.txt AC 85 ms 112868 KiB
01_random_21.txt AC 86 ms 113032 KiB
01_random_22.txt AC 83 ms 112800 KiB
01_random_23.txt AC 82 ms 113364 KiB
01_random_24.txt AC 82 ms 113164 KiB
01_random_25.txt AC 82 ms 113020 KiB
01_random_26.txt AC 85 ms 113024 KiB
01_random_27.txt AC 84 ms 113028 KiB
01_random_28.txt AC 83 ms 112596 KiB
01_random_29.txt AC 84 ms 112380 KiB
01_random_30.txt AC 83 ms 112972 KiB
01_random_31.txt AC 84 ms 113092 KiB
01_random_32.txt AC 83 ms 112384 KiB
01_random_33.txt AC 83 ms 112276 KiB
01_random_34.txt AC 84 ms 113092 KiB
01_random_35.txt AC 85 ms 113216 KiB