結果

問題 No.1359 [Zelkova 3rd Tune] 四人セゾン
ユーザー kerroggukerroggu
提出日時 2021-01-22 21:28:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 702 ms / 2,000 ms
コード長 3,397 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 144,524 KB
最終ジャッジ日時 2023-08-27 17:28:24
合計ジャッジ時間 46,392 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
82,680 KB
testcase_01 AC 229 ms
82,828 KB
testcase_02 AC 227 ms
82,956 KB
testcase_03 AC 492 ms
120,760 KB
testcase_04 AC 480 ms
120,688 KB
testcase_05 AC 434 ms
119,708 KB
testcase_06 AC 456 ms
119,720 KB
testcase_07 AC 539 ms
134,920 KB
testcase_08 AC 567 ms
134,700 KB
testcase_09 AC 320 ms
95,232 KB
testcase_10 AC 320 ms
95,144 KB
testcase_11 AC 619 ms
144,524 KB
testcase_12 AC 620 ms
144,160 KB
testcase_13 AC 486 ms
126,048 KB
testcase_14 AC 482 ms
125,744 KB
testcase_15 AC 454 ms
120,288 KB
testcase_16 AC 455 ms
120,272 KB
testcase_17 AC 687 ms
139,292 KB
testcase_18 AC 657 ms
138,960 KB
testcase_19 AC 593 ms
135,308 KB
testcase_20 AC 593 ms
135,260 KB
testcase_21 AC 623 ms
142,784 KB
testcase_22 AC 622 ms
142,740 KB
testcase_23 AC 522 ms
129,656 KB
testcase_24 AC 493 ms
129,312 KB
testcase_25 AC 275 ms
87,156 KB
testcase_26 AC 274 ms
86,968 KB
testcase_27 AC 382 ms
109,348 KB
testcase_28 AC 370 ms
109,060 KB
testcase_29 AC 402 ms
117,520 KB
testcase_30 AC 413 ms
117,396 KB
testcase_31 AC 466 ms
123,536 KB
testcase_32 AC 463 ms
123,912 KB
testcase_33 AC 410 ms
117,908 KB
testcase_34 AC 403 ms
117,604 KB
testcase_35 AC 451 ms
120,324 KB
testcase_36 AC 450 ms
120,176 KB
testcase_37 AC 283 ms
88,012 KB
testcase_38 AC 284 ms
88,288 KB
testcase_39 AC 281 ms
85,096 KB
testcase_40 AC 271 ms
85,276 KB
testcase_41 AC 309 ms
94,644 KB
testcase_42 AC 312 ms
94,988 KB
testcase_43 AC 305 ms
92,476 KB
testcase_44 AC 632 ms
139,920 KB
testcase_45 AC 411 ms
116,972 KB
testcase_46 AC 297 ms
90,796 KB
testcase_47 AC 533 ms
134,520 KB
testcase_48 AC 505 ms
130,724 KB
testcase_49 AC 509 ms
134,896 KB
testcase_50 AC 451 ms
119,592 KB
testcase_51 AC 250 ms
84,064 KB
testcase_52 AC 595 ms
134,208 KB
testcase_53 AC 648 ms
141,732 KB
testcase_54 AC 665 ms
141,756 KB
testcase_55 AC 702 ms
141,864 KB
testcase_56 AC 660 ms
141,376 KB
testcase_57 AC 675 ms
141,924 KB
testcase_58 AC 666 ms
142,244 KB
testcase_59 AC 664 ms
141,656 KB
testcase_60 AC 651 ms
142,136 KB
testcase_61 AC 637 ms
141,928 KB
testcase_62 AC 668 ms
141,988 KB
testcase_63 AC 661 ms
142,296 KB
testcase_64 AC 672 ms
141,496 KB
testcase_65 AC 656 ms
141,824 KB
testcase_66 AC 654 ms
142,720 KB
testcase_67 AC 684 ms
141,780 KB
testcase_68 AC 657 ms
141,272 KB
testcase_69 AC 623 ms
141,548 KB
testcase_70 AC 630 ms
142,228 KB
testcase_71 AC 635 ms
141,288 KB
testcase_72 AC 678 ms
141,904 KB
testcase_73 AC 664 ms
141,884 KB
testcase_74 AC 659 ms
141,796 KB
testcase_75 AC 659 ms
142,004 KB
testcase_76 AC 660 ms
143,252 KB
testcase_77 AC 660 ms
141,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()
import bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def I():return int(input())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def NLI(n):return [[int(i) for i in input().split()] for i in range(n)]
def NLI_(n):return [[int(i)-1 for i in input().split()] for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RLI(n=8,a=1,b=10):return [random.randint(a,b)for i in range(n)]
def RI(a=1,b=10):return random.randint(a,b)
def INP():
    N=9
    n=random.randint(1,N)
    A=[random.randint(1,n) for i in range(m)]
    return n,A
def Rtest(T):
    case,err=0,0
    for i in range(T):
        inp=INP()
        a1=naive(*inp)
        a2=solve(*inp)
        if a1!=a2:
            print(inp)
            print('naive',a1)
            print('solve',a2)
            err+=1
        case+=1
    print('Tested',case,'case with',err,'errors')
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:a,b=inp;c=1
        else:a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
#mo=998244353
inf=1<<63
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
alp=[chr(ord('a')+i)for i in range(26)]
sys.setrecursionlimit(10**7)

show_flg=False
show_flg=True

ans=0


n,k,m=map(int,input().split())
x=[]
for i in range(4):
    x+=sorted(LI())

for i in range(n):
    d=max(x[i::n])-min(x[i::n])
    ans+=pow(d,k,m)
    ans%=m
print(ans)
0