Submission #4998342


Source Code Expand

# -*- coding: utf-8 -*-

import sys
from math import factorial

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=sorted([INT() for i in range(N)])
B=sorted([INT() for i in range(N)])

i=j=cur=cnt=0
L=[]
if A[0]>B[0]:
    cur=1
while i<N and j<N:
    if cur==0 and A[i]<B[j]:
        i+=1
        cnt+=1
    elif cur==1 and A[i]<B[j]:
        i=j
        if cnt:
            L.append(cnt)
        cnt=0
        cur=0
    elif cur==1 and A[i]>B[j]:
        j+=1
        cnt+=1
    elif cur==0 and A[i]>B[j]:
        j=i
        if cnt:
            L.append(cnt)
        cnt=0
        cur=1
if cnt!=0:
    L.append(cnt)

ans=1
for a in L:
    ans=(ans*factorial(a))%MOD
print(ans)

Submission Info

Submission Time
Task A - 1D Matching
User Coki628
Language Python (3.4.3)
Score 0
Code Size 1205 Byte
Status WA
Exec Time 487 ms
Memory 12244 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 4
WA × 10
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt WA 169 ms 8552 KB
001.txt WA 68 ms 5088 KB
002.txt WA 98 ms 5824 KB
003.txt WA 104 ms 6176 KB
004.txt WA 255 ms 11108 KB
005.txt WA 273 ms 12112 KB
006.txt WA 280 ms 12132 KB
007.txt WA 269 ms 12116 KB
008.txt WA 282 ms 12236 KB
009.txt WA 273 ms 12112 KB
010.txt AC 487 ms 12244 KB
011.txt AC 368 ms 12112 KB
example0.txt AC 18 ms 3188 KB
example1.txt AC 18 ms 3188 KB