秋祭 | 静岡高校工学部



卬高杯


提出詳細

提出id提出時刻ユーザー名問題言語判定状況判定実行時間
1149072023-10-24 12:57:03U_SIpython25/25TLE2004

import sys
sys.setrecursionlimit(10**7)
# input = sys.stdin.readline
# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
def lm1(LIST): return list(map(lambda x:x-1, LIST))
def mps(A):return [tuple(map(int, input().split())) for _ in range(A)]
def stoi(LIST):return list(map(int,LIST))
def itos(LIST):return list(map(str,LIST))
def atoi(LIST): return [ord(i)-ord("a") for i in LIST]
def Atoi(LIST): return [ord(i)-ord("A") for i in LIST]
def bitA(X,A):return X & 1<<A == 1<<A
import math
import bisect
import heapq
import time
from copy import copy as cc
from copy import deepcopy as dc
from itertools import accumulate, product
from collections import Counter, defaultdict, deque
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = (1<<63)-1
mod = 127237991

n = int(input())
a = [lmp() for i in range(5)]
for i in a:
    i.sort()

def f(x,y):
    if visit[x][y]:return memo[x][y]
    if x == 4:return 1
    m = bisect.bisect_right(a[x+1],a[x][y])
    if m == n:return 0
    cnt = 0
    for i in range(m,n):
        cnt += f(x+1,i)
        cnt %= mod
    memo[x][y] *= cnt
    memo[x][y] %= mod
    visit[x][y] = True
    return memo[x][y]

def g(x,y):
    m = bisect.bisect_right(a[x+1],a[x][y])
    if m == n:return 0
    return memo[x+1][m]

ans = 0
memo = [[1]*n for i in range(5)]
visit = [[False]*n for i in range(5)]
ans += f(0,0) % mod
for i in range(1,2):
    for j in range(n-1,0,-1):
        memo[i][j-1] += memo[i][j]
        memo[i][j-1] %= mod
for i in range(1,n):
    ans += g(0,i)%mod
print(ans%mod)

sample1.txt AC 18
sample2.txt AC 19
sample3.txt AC 31
sample4.txt AC 20
sample5.txt AC 21
case1.txt AC 24
case2.txt WA 22
case3.txt AC 20
case4.txt WA 21
case5.txt WA 22
case6.txt TLE 2003
case7.txt TLE 2004
case8.txt TLE 2003
case9.txt TLE 2002
case10.txt TLE 2002
case11.txt TLE 2003
case12.txt TLE 2003
case13.txt TLE 2003
case14.txt TLE 2003
case15.txt TLE 2003
case16.txt TLE 2003
case17.txt TLE 2003
case18.txt TLE 2003
case19.txt TLE 2003
case20.txt TLE 2003
2004 TLE