Problem:


Score : 300 points

Problem Statement

Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition:

For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.

Notes

A tree of N vertices is a connected undirected graph with N vertices and N-1 edges, and the distance between two vertices are the number of edges in the shortest path between them.

Two trees are considered different if and only if there are two vertices x and y such that there is an edge between x and y in one of those trees and not in the other.

Constraints

1 \leq N \leq 10^5

0 \leq D_i \leq N-1

Input

Input is given from Standard Input in the following format:

N
D_1 D_2 ... D_N

Output

Print the answer.

Sample Input 1

4
0 1 1 2

Sample Output 1

2

For example, a tree with edges (1,2), (1,3), and (2,4) satisfies the condition.

Sample Input 2

4
1 1 1 1

Sample Output 2

0

Sample Input 3

7
0 3 2 1 2 2 1

Sample Output 3

24



Sample input:
4
0 1 1 2


Sample output:
2

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
D={}
T=list(map(int,input().split()))
for i in range(N):
    if D.get(T[i],None)==None:
        D[T[i]]=1
    else:
        D[T[i]]+=1

Max=max(D)
Min=min(D)
Len=len(D)
Item=sorted((D.items()))
if(Item[0][0]!=0):
    print("0")
    exit()
ans=1
for i in range(1,Len):
    ans = (ans * (Item[i-1][1]**Item[i][1])) % 998244353
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
D={}
T=list(map(int,input().split()))
for i in range(N):
    if D.get(T[i],None)==None:
        D[T[i]]=1
    else:
        D[T[i]]+=1

Max=max(D)
Min=min(D)
Len=len(D)
Item=sorted((D.items()))
for i in range(Len):
    if(Item[i][0]!=i):
        print("0")
        exit()
ans=1
for i in range(1,Len):
    ans = (ans * (Item[i-1][1]**Item[i][1])) % 998244353
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
D={}
T=list(map(int,input().split()))
for i in range(N):
    if D.get(T[i],None)==None:
        D[T[i]]=1
    else:
        D[T[i]]+=1

Max=max(D)
Min=min(D)
Len=len(D)
Item=sorted((D.items()))
for i in range(Len):
    if(Item[i][0]!=i):
        print("0")
        exit()
ans=1
for i in range(2,Len):
    ans = (ans * (Item[i-1][1]**Item[i][1])) % 998244353
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
D={}
T=list(map(int,input().split()))
for i in range(N):
    if D.get(T[i],None)==None:
        D[T[i]]=1
    else:
        D[T[i]]+=1

Max=max(D)
Min=min(D)
Len=len(D)
if(Max-Min+1!=Len):
    print("0")
    exit()
Item=sorted((D.items()))

ans=1
for i in range(2,Len):
    ans = (ans * (Item[i-1][1]**Item[i][1])) % 998244353
    
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力
 
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
 
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
 
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    D = inputList()
    
    D.sort()
    if D[0] != 0:
        print(0)
        sys.exit()
        
    if N == 1:
        print(1)
        sys.exit()
    
    if D[1] != 1:
        print(0)
        sys.exit()
        
    ck = 0
    dict_tmp = {}
    for i,val in enumerate(D):
        if ck == val:
            pass
        elif ck+1 == val:
            ck += 1
        else:
            print(0)
            sys.exit()
            
        if val in dict_tmp:
            dict_tmp[val] += 1
        else:
            dict_tmp[val] = 1
            
    ans = 1
    for k,v in dict_tmp.items():
        if k == 0 or k == 1:
            pass
        else:
            tmp = dict_tmp[k-1]
            for i in range(v):
                ans *= tmp
                ans = ans % 998244353
                
    print(ans)
            
    
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力
 
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
 
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
 
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    D = inputList()
    
    D.sort()
    if D[0] != 0:
        print(0)
        sys.exit()
    
    if D[1] != 1:
        print(0)
        sys.exit()
        
    ck = 0
    dict_tmp = {}
    for i,val in enumerate(D):
        if ck == val:
            pass
        elif ck+1 == val:
            ck += 1
        else:
            print(0)
            sys.exit()
            
        if val in dict_tmp:
            dict_tmp[val] += 1
        else:
            dict_tmp[val] = 1
            
    ans = 1
    for k,v in dict_tmp.items():
        if k == 0 or k == 1:
            pass
        else:
            tmp = dict_tmp[k-1]
            for i in range(v):
                ans *= tmp
                ans = ans % 998244353
                
    print(ans)
            
    
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力
 
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
 
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
 
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    D = inputList()
    
    D.sort()
    if D[0] != 0:
        print(0)
        sys.exit()
    
    if D[1] == 0:
        print(0)
        sys.exit()
        
    ck = 0
    dict_tmp = {}
    for i,val in enumerate(D):
        if ck == val:
            pass
        elif ck+1 == val:
            ck += 1
        else:
            print(0)
            sys.exit()
            
        if val in dict_tmp:
            dict_tmp[val] += 1
        else:
            dict_tmp[val] = 1
            
    ans = 1
    for k,v in dict_tmp.items():
        if k == 0 or k == 1:
            pass
        else:
            tmp = dict_tmp[k-1]
            for i in range(v):
                ans *= tmp
                ans = ans % 998244353
                
    print(ans)
            
    
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline
 
##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力
 
# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと
 
##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順
 
# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    D = inputList()
    
    D.sort()
    if D[0] != 0:
        print(0)
        sys.exit()
        
    ck = 0
    dict_tmp = {}
    for i,val in enumerate(D):
        if ck == val:
            pass
        elif ck+1 == val:
            ck += 1
        else:
            print(0)
            sys.exit()
            
        if val in dict_tmp:
            dict_tmp[val] += 1
        else:
            dict_tmp[val] = 1
            
    ans = 1
    for k,v in dict_tmp.items():
        if k == 0 or k == 1:
            pass
        else:
            tmp = dict_tmp[k-1]
            for i in range(v):
                ans *= tmp
                ans = ans % 998244353
                
    print(ans)
            
    
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
N = int(input())
D = [int(x) for x in input().split()]
D = sorted(D)
res = [0]*(max(D)+1)
for n in range(N):
    res[D[n]] += 1
if D[0] == 0 and res[0] == 1:
  k = 1
  for n in range(max(D)):
    k *= pow(res[n],res[n+1],998244353)
    print(k%998244353)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = [int(x) for x in input().split()]
D = sorted(D)
res = [0]*(max(D)+1)
for n in range(N):
    res[D[n]] += 1
if D[0] != 0 or res[0] != 1:
  print(0)
else:
  k = 1
  for n in range(1,max(D)+1):
    k *= pow(res[n-1],res[n],998244353)
  print(k%998244353)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = [int(x) for x in input().split()]
D = sorted(D)
res = [0]*(max(D)+1)
for n in range(N):
    res[D[n]] += 1
if D[0] != 0 or res[0] != 1:
  print(0)
else:
  k = 1
  for n in range(1,max(D)+1):
    k *= (res[n-1]**res[n])%998244353
  print(k%998244353)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = [int(x) for x in input().split()]
D = sorted(D)
if D[0] != 0:
  print(0)
else:
  res = [0]*(max(D)+1)
  for n in range(N):
    res[D[n]] += 1
  k = 1
  for n in range(1,max(D)+1):
    k *= (res[n-1]**res[n])%998244353
  print(k%998244353)

Submission status: Wrong Answer

Solution code:
# N = int(input())
# D = [int(x) for x in input().split()]
# new_l = [0 for n in range(max(D)+1)]
# for n in range(N):
#     new_l[D[n]] += 1
# if new_l[0] == 1 and D[0] == 0:
#     res = 1
#     for n in range(max(D)):
#         res *= pow(new_l[n],new_l[n+1],998244353)
#     print(res%998244353)
# else:
#     print(0)
N = int(input())
D = [int(x) for x in input().split()]
D = sorted(D)
if D[0] != 0:
  print(0)
else:
  res = [0]*(max(D)+1)
  for n in range(N):
    res[D[n]] += 1
  k = 1
  for n in range(1,max(D)+1):
    k *= (res[n-1]**res[n])%998244353
  print(k)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = [int(x) for x in input().split()]
D = sorted(D)
if D[0] != 0:
  print(0)
else:
  res = [0]*(max(D)+1)
  for n in range(N):
    res[D[n]] += 1
  for n in range(1,max(D)+1):
    res[n] *= res[n-1]%998244353
  print(res[max(D)])

Submission status: Wrong Answer

Solution code:
from collections import Counter
mod = 998244353


N = int(input())
d = [int(i) for i in input().split()]
if d[0] != 0:
    print(0)
    exit()
else:
    D = Counter(d)

    ans = 1
    c = 1
    for i in range(max(D.keys())+1):
        ans *= c ** D[i]
        ans %= mod
        c = D[i]

    print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
mod = 998244353


N = int(input())
D = Counter([int(i) for i in input().split()])

ans = 1
c = 1
for i in range(max(D.keys())+1):
    ans *= c ** D[i]
    ans %= mod
    c = D[i]

print(ans % mod)

Submission status: Wrong Answer

Solution code:
from collections import Counter
mod = 998244353


N = int(input())
D = Counter([int(i) for i in input().split()])

ans = 1
c = 1
for i in range(max(D.keys())+1):
    ans *= c ** D[i]
    ans %= mod
    c = D[i]

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
d_lst=list(map(int,input().split()))
d_lst.sort(reverse=False)
d_lst2=[]
for i in range(1,n):
    if d_lst[i-1]+1==d_lst[i]:
        d_lst2.append(d_lst[i])
    elif d_lst[i-1]==d_lst[i]:
        continue
    else:
        d_lst=[1]
        break

if d_lst[0]==0:
    lst_len=len(d_lst2)
    count=1
    for j in range(1,lst_len):
        count*=d_lst.count(d_lst2[j-1])**d_lst.count(d_lst2[j])
    print(count%998244353)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
d_lst=list(map(int,input().split()))
d_lst.sort(reverse=False)
d_lst2=[]
for i in range(1,n):
    if d_lst[i-1]+1==d_lst[i]:
        d_lst2.append(d_lst[i])
    elif d_lst[i-1]==d_lst[i]:
        continue
    else:
        d_lst=[1]
        break

if d_lst[0]==0:
    lst_len=len(d_lst2)
    count=1
    for j in range(1,lst_len):
        count*=d_lst.count(d_lst2[j-1])**d_lst.count(d_lst2[j])
    print(count)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
d_lst=list(map(int,input().split()))
d_lst.sort(reverse=False)
d_lst2=[]
for i in range(1,n):
    if d_lst[i-1]+1==d_lst[i]:
        d_lst2.append(d_lst[i])
    elif d_lst[i-1]==d_lst[i]:
        continue
    else:
        break
lst_len=len(d_lst2)
count=1
for j in range(1,lst_len):
    count*=d_lst.count(d_lst2[j-1])**d_lst.count(d_lst2[j])
if d_lst[0]==0:
    print(count)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def main():

    N = input()
    D = list(map(int,input().split()))
    M = max(D)
    countlist=[0] * (M + 1)
    ans=1

    for i in D:
        countlist[i]+=1

    if countlist[0]!=1 :
        ans = 0
    else :
        if D[0]!=0 :
            ans = 0
        else:
            for i in range(2,M+1):
                ans *= (countlist[i-1]**countlist[i]) % 998244353

    print(ans) 

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    if D_list[0] != 0:
        ans = 0
    
    else:
        maxD = max(D_list)
        count_ele_Dlist = [0] * (maxD + 1)

        if count_ele_Dlist[0] == 1:
            ans = 1
            for i in D_list:
                count_ele_Dlist[i] = count_ele_Dlist[i] + 1

            for i in range(1, maxD + 1):
                ans = (ans * count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353
        else:
            ans = 0
        
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    if D_list[0] != 0:
        ans = 0
    
    else:
        maxD = max(D_list)
        count_ele_Dlist = [0] * (maxD + 1)
        ans = 1

        for i in D_list:
            count_ele_Dlist[i] = count_ele_Dlist[i] + 1

        for i in range(1, maxD + 1):
            ans = (ans * count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353
    
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    if D_list[0] == 0:
        ans = 0
    
    else:
        maxD = max(D_list)
        count_ele_Dlist = [0] * (maxD + 1)
        ans = 1

        for i in D_list:
            count_ele_Dlist[i] = count_ele_Dlist[i] + 1

        for i in range(1, maxD + 1):
            ans = (ans * count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353
    
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    if D_list == 0:
        ans = 0
    
    else:
        maxD = max(D_list)
        count_ele_Dlist = [0] * (maxD + 1)
        ans = 1

        for i in D_list:
            count_ele_Dlist[i] = count_ele_Dlist[i] + 1

        for i in range(1, maxD + 1):
            ans = (ans * pow(count_ele_Dlist[i - 1], count_ele_Dlist[i])) % 998244353
    
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N = int(input())
D = list(map(int,input().split()))
M = max(D)
countlist=list(map(int,np.zeros(M+1)))
ans=1

for i in D:
    countlist[i]+=1

if 0 in countlist or countlist[0]!=1 :
    print(0)
    sys.exit()
elif M<2:
    print(1)
    sys.exit()

for i in range(2,M+1):
    if countlist[i]>0:
        ans *= countlist[i-1]**countlist[i]
    elif i<M:
        ans=0
    else:
        break


print(ans%998244353)

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    if D_list == 0:
        ans = 0
    
    else:
        maxD = max(D_list)
        count_ele_Dlist = [0] * (maxD + 1)
        ans = 1

        for i in D_list:
            count_ele_Dlist[i] = count_ele_Dlist[i] + 1

        for i in range(1, maxD + 1):
            ans = (ans * (count_ele_Dlist[i - 1] ** count_ele_Dlist[i])) % 998244353
    
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N = int(input())
D = list(map(int,input().split()))
M = max(D)
countlist=list(map(int,np.zeros(M+1)))
ans=1

for i in D:
    countlist[i]+=1

if countlist[0]!=1 :
    print(0)
    sys.exit()
elif countlist[1]==0 and M==1:
    print(1)
    sys.exit()

for i in range(2,M+1):
    if countlist[i]>0:
        ans *= countlist[i-1]**countlist[i]
    elif i<M:
        ans=0
    else:
        break


print(ans%998244353)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N = int(input())
D = list(map(int,input().split()))
M = max(D)
countlist=list(map(int,np.zeros(M+1)))
ans=1

print(countlist)
for i in D:
    countlist[i]+=1

if countlist[0]!=1 :
    print(0)
    sys.exit()
elif countlist[1]==0 and M==1:
    print(1)
    sys.exit()

for i in range(2,M+1):
    if countlist[i]>0:
        ans *= countlist[i-1]**countlist[i]
    elif i<M:
        ans=0
    else:
        break


print(ans%998244353)

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_ele_Dlist = [0] * (maxD + 1)
    ans = 1

    for i in D_list:
        count_ele_Dlist[i] = count_ele_Dlist[i] + 1
    '''
    for i in range(1, maxD + 1):
        ans = (ans * (count_ele_Dlist[i - 1] ** count_ele_Dlist[i])) % 998244353
    '''

    for i in D_list:
        ans = (ans * count_ele_Dlist[i - 1]) % 998244353
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_ele_Dlist = [0] * (maxD + 1)
    ans = 1

    for i in D_list:
        count_ele_Dlist[i] = count_ele_Dlist[i] + 1

    for i in range(1, maxD + 1):
        ans = (ans * (count_ele_Dlist[i - 1] ** count_ele_Dlist[i])) % 998244353

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_ele_Dlist = [0] * (maxD + 1)
    ans = 1

    for i in D_list:
        count_ele_Dlist[i] = count_ele_Dlist[i] + 1

    if count_ele_Dlist.count(0) != 0:
        ans = 0
    else:
        for i in range(1, maxD + 1):
            ans = (ans * (count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353) % 998244353

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
D = list(map(int,input().split()))
ans=0

if D.count(0)!=1 :
    print(ans)
    sys.exit()
else:
    ans=1

mae=D.count(1)
if mae==0:
    print(ans)
    sys.exit()

for i in range(2,99999):
    ato=D.count(i)

    if ato>0:
        ans *= mae**ato
    elif ato==0 and i<max(D):
        ans=0
    else:
        break
    mae=ato


print(ans%998244353)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
D = list(map(int,input().split()))
ans=0

if D.count(0)!=1 :
    print(ans)
    sys.exit()
else:
    ans=1

mae=D.count(1)
if mae==0:
    print(ans)
    sys.exit()

for i in range(2,99999):
    ato=D.count(i)

    if ato>0:
        ans *= mae**ato
    elif ato==0 and i<max(D):
        ans=0
    else:
        break
    mae=ato
    ans=ans%998244353


print(ans%998244353)

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_ele_Dlist = [0] * (maxD + 1)
    ans = 1

    for i in D_list:
        count_ele_Dlist[i] = count_ele_Dlist[i] + 1

    if count_ele_Dlist.count(0) != 0:
        ans = 0
    
    else:
        for i in range(1, maxD + 1):
            ans = (ans * (count_ele_Dlist[i - 1] ** count_ele_Dlist[i])) % 998244353

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_ele_Dlist = [0] * (maxD + 1)
    ans = 1

    for i in D_list:
        count_ele_Dlist[i] = count_ele_Dlist[i] + 1

    if count_ele_Dlist.count(0) != 0:
        ans = 0
    
    else:
        for i in range(1, maxD + 1):
            ans = ans * (count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_ele_Dlist = [0] * (maxD + 1)
    ans = 1

    for i in D_list:
        count_ele_Dlist[i] = count_ele_Dlist[i] + 1

    if count_ele_Dlist[0] == 0:
        ans = 0
    
    else:
        for i in range(1, maxD + 1):
            if(count_ele_Dlist[i] == 0):
                ans = 0
                break
            
            ans = ans * (count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
D = list(map(int,input().split()))
ans=0

if D.count(0)!=1 :
    print(ans)
    sys.exit()
else:
    ans=1

for i in range(2,99999):
    mae=D.count(i-1)
    ato=D.count(i)

    if ato>0:
        ans *= mae**ato
    elif ato==0 and i<max(D):
        ans=0
    else:
        break
    
    ans=ans%998244353


print(ans%998244353)

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_ele_Dlist = [0] * (maxD + 1)
    ans = 1

    for i in D_list:
        count_ele_Dlist[i] = count_ele_Dlist[i] + 1

    if count_ele_Dlist[0] == 0:
        ans = 0
    
    else:
        for i in range(1, maxD + 1):
            ans = ans * (count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
D = list(map(int,input().split()))
ans=0

if D.count(0)!=1 :
    print(ans)
    sys.exit()
else:
    ans=1

for i in range(2,99999):
    mae=D.count(i-1)
    ato=D.count(i)

    if ato>0:
        ans *= mae**ato
    elif ato==0 and i<max(D):
        ans=0
    else:
        break

print(ans%998244353)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
D = list(map(int,input().split()))
ans=0

if D.count(0)==0 :
    print(ans)
    sys.exit()
else:
    ans=1

for i in range(2,99999):
    mae=D.count(i-1)
    ato=D.count(i)

    if ato>0:
        ans *= mae**ato
    elif ato==0 and i<max(D):
        ans=0
    else:
        break

print(ans%998244353)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
D = list(map(int,input().split()))
ans=0

if D.count(0)==0 :
    print(ans)
    sys.exit()
else:
    ans=1

for i in range(2,99999):
    mae=D.count(i-1)
    ato=D.count(i)

    if ato>0:
        ans *= mae**ato
    elif ato<max(D):
        ans=0
    else:
        break

print(ans%998244353)

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_nowD = D_list.count(0)
    lenD = len(D_list)

    if D_list.count(0) == 0:
        ans = 0
    elif count_nowD == lenD:
        ans = 1
    else:
        counter = 1
        ans = 1

        while counter <= maxD:
            count_beforeD = count_nowD
            count_nowD = D_list.count(counter)

            if(count_nowD == 0):
                ans = 0
                break

            ans = (ans * (count_beforeD ** count_nowD) % 998244353) % 998244353
            counter = counter + 1

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
D = list(map(int,input().split()))
ans=0

if D.count(0)==0 :
    print(ans)
    sys.exit()
else:
    ans=1

for i in range(2,99999):
    mae=D.count(i-1)
    ato=D.count(i)

    if mae>0:
        ans *= mae**ato
    else:
        break

print(ans%998244353)

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)

    if D_list.count(0) == 0:
        ans = 0
    else:
        counter = 1
        ans = 1

        count_nowD = D_list.count(0)

        while counter <= maxD:
            count_beforeD = count_nowD
            count_nowD = D_list.count(counter)

            if(count_nowD == 0):
                ans = 0
                break

            ans = (ans * (count_beforeD ** count_nowD) % 998244353) % 998244353
            counter = counter + 1

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

import sys
N = int(input())
D = list(map(int,input().split()))
ans=0

if D.count(0)==0 :
    print(ans)
    sys.exit()
else:
    ans=1

for i in range(2,99999):
    mae=D.count(i-1)
    ato=D.count(i)

    if mae>0:
        ans *= mae**ato
    else:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)
    count_nowD = D_list.count(0)
    D_list = [i for i in D_list if i != 0]

    if count_nowD == 0:
        ans = 0
    else:
        counter = 1
        ans = 1

        while counter <= maxD:
            count_beforeD = count_nowD
            new_D_list = [i for i in D_list if i != counter]
            count_nowD = len(D_list) - len(new_D_list)

            if(count_nowD == 0):
                ans = 0
                break

            ans = (ans * (count_beforeD ** count_nowD)) % 998244353
            counter = counter + 1
            D_list = new_D_list

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
D = list(map(int,input().split()))
ans=0

if D.count(0)==0 :
    print(ans)
    sys.exit()
else:
    ans=1

for i in range(2,99999):
    if D.count(i)>0:
        ans *= D.count(i-1)**D.count(i)
    else:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)

    if D_list.count(0) == 0:
        ans = 0
    else:
        counter = 1
        ans = 1

        count_nowD = D_list.count(0)

        while counter <= maxD:
            count_beforeD = count_nowD
            count_nowD = D_list.count(counter)

            if(count_nowD == 0):
                ans = 0
                break

            ans = (ans * (count_beforeD ** count_nowD)) % 998244353
            counter = counter + 1

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    D_list = list(map(int, input().split()))

    maxD = max(D_list)

    if D_list.count(0) == 0:
        ans = 0
    else:
        counter = 1
        ans = 1

        while counter <= maxD:
            beforeD = counter - 1
            nowD = counter

            count_beforeD = D_list.count(beforeD)
            count_nowD = D_list.count(nowD)

            if(nowD == 0):
                ans = 0
                break

            ans = ans * (count_beforeD ** count_nowD)
            counter = counter + 1

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys

n = int(input())
d = list(map(int, input().split()))
mod = 998244353

if d[0] != 0:
    print(0)
    sys.exit()

counter = Counter(sorted(d))
if counter[0] != 1:
    print(0)
    sys.exit()

patt = 1
for p, n in zip(counter, list(counter.keys())[1:]):
    if n > p+1:
        print(0)
        sys.exit()

    patt *= counter[p] ** counter[n] % mod

print(patt)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys

n = int(input())
d = list(map(int, input().split()))
mod = 998244353

if d[0] != 0:
    print(0)
    sys.exit()

counter = Counter(d)
if counter[0] != 1:
    print(0)
    sys.exit()

patt = 1
for i in range(1, len(counter)):
    patt *= counter[i-1]**counter[i] % mod

print(patt)