Submission #71159977


Source Code Expand

# D12
# D11: sample3 で WA

import sys
# sys.setrecursionlimit(10 ** 6)

import numpy as np
from numba import jit, boolean, int64, float64, typeof, types, typeof, objmode

def main():
    from io import StringIO
    execute(StringIO(sample), sys.stderr)
    print("-- ^sample! --", file=sys.stderr)

    execute(sys.stdin, sys.stdout)

    if len(solve.nopython_signatures) != 1:
        raise KeyboardInterrupt("!! Unexpected: wrong use of jit !!")

def execute(src, dst):

    N, M,= map(int, src.readline().split())
    Astring = src.readline().strip()
    L = np.array([len(w) for w in Astring.split()] , dtype=np.int64)
    A = np.fromstring(Astring, dtype=np.int64, sep=' ')
    assert len(L) == len(A)

    ans = solve(N, M, L, A)
    print(ans, file=dst)

sample = """\
5 5 
10 10 10 10 10 
"""

@jit(nopython=True, cache=True)
def solve(N, M, L, A):

    ny = dict()
    for l, a in zip(L,A):
        m = a % M
        if (l,m) in ny :
            ny[(l,m)] += 1
        else :
            ny[(l,m)] = 1
    ans = 0
    for x in A:
        for l in range(1, 11):
            m1 = ( x % M ) * ((10 ** l) % M ) % M
            m2 = ( M - m1 ) % M
            if (l,m2) in ny :
                ans += ny[(l,m2)]
            else:
                pass


    return ans


main()

Submission Info

Submission Time
Task D - 183183
User tariaki
Language Python (CPython 3.13.7)
Score 400
Code Size 1342 Byte
Status AC
Exec Time 601 ms
Memory 167484 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.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
Case Name Status Exec Time Memory
00_sample_00.txt AC 461 ms 139232 KiB
00_sample_01.txt AC 455 ms 139460 KiB
00_sample_02.txt AC 456 ms 139048 KiB
00_sample_03.txt AC 452 ms 139344 KiB
01_random_00.txt AC 449 ms 139124 KiB
01_random_01.txt AC 451 ms 139284 KiB
01_random_02.txt AC 446 ms 138948 KiB
01_random_03.txt AC 451 ms 139444 KiB
01_random_04.txt AC 529 ms 156784 KiB
01_random_05.txt AC 484 ms 143756 KiB
01_random_06.txt AC 512 ms 150748 KiB
01_random_07.txt AC 511 ms 153012 KiB
01_random_08.txt AC 526 ms 152888 KiB
01_random_09.txt AC 575 ms 167484 KiB
01_random_10.txt AC 539 ms 156532 KiB
01_random_11.txt AC 601 ms 166880 KiB
01_random_12.txt AC 545 ms 156712 KiB
01_random_13.txt AC 468 ms 142400 KiB
01_random_14.txt AC 531 ms 149344 KiB
01_random_15.txt AC 547 ms 153964 KiB
01_random_16.txt AC 519 ms 147864 KiB
01_random_17.txt AC 465 ms 141572 KiB
01_random_18.txt AC 566 ms 153364 KiB
01_random_19.txt AC 538 ms 156252 KiB
01_random_20.txt AC 466 ms 143008 KiB