Submission #8350477


Source Code Expand

Copy
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int mod_pow(Int x, Int a, Int m = MOD){
    if(a == 0)return 1;
    Int res = mod_pow(x, a / 2, m);
    res = res * res % m;
    if(a % 2)res *= x;
    return res % m;
}

Int inv(Int x, Int m = MOD){
    return mod_pow(x, m-2, m);
}
Int n, d;
Int cnt[110000];


int main(){
    cin >> n;
    Int maxd = 0;
    for(int i = 0;i < n;i++){
        cin >> d;
        cnt[d]++;
        maxd = max(maxd, d);
    }
    if(cnt[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    Int ans = 1;
    for(int i = 1;i <= maxd;i++){
        ans = ans * mod_pow(cnt[i-1], cnt[i]) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task B - Counting of Trees
User catupper
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1002 Byte
Status WA
Exec Time 82 ms
Memory 1528 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 25
WA × 2
Set Name Test Cases
Sample sample01.txt, sample02.txt, sample03.txt
All sample01.txt, sample02.txt, sample03.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, sample01.txt, sample02.txt, sample03.txt
Case Name Status Exec Time Memory
in01.txt AC 82 ms 1528 KB
in02.txt AC 72 ms 768 KB
in03.txt AC 73 ms 896 KB
in04.txt AC 71 ms 512 KB
in05.txt AC 72 ms 512 KB
in06.txt AC 77 ms 640 KB
in07.txt AC 79 ms 768 KB
in08.txt AC 75 ms 768 KB
in09.txt AC 71 ms 640 KB
in10.txt AC 16 ms 256 KB
in11.txt AC 4 ms 256 KB
in12.txt WA 66 ms 256 KB
in13.txt WA 5 ms 256 KB
in14.txt AC 81 ms 1024 KB
in15.txt AC 79 ms 640 KB
in16.txt AC 62 ms 256 KB
in17.txt AC 54 ms 256 KB
in18.txt AC 47 ms 256 KB
in19.txt AC 46 ms 256 KB
in20.txt AC 77 ms 640 KB
in21.txt AC 1 ms 256 KB
sample01.txt AC 1 ms 256 KB
sample02.txt AC 1 ms 256 KB
sample03.txt AC 1 ms 256 KB