Submission #8352769


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;
        if(i == 0){
            if(d != 0){cout << 0 << endl;
                return 0;}
        }else{
            if(d == 0){cout << 0 << endl;
                return 0;}
        }
        cnt[d]++;
        maxd = max(maxd, d);
    }
    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 (GCC 5.4.1)
Score 300
Code Size 1116 Byte
Status AC
Exec Time 31 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 27
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 30 ms 1024 KB
in02.txt AC 28 ms 768 KB
in03.txt AC 28 ms 896 KB
in04.txt AC 27 ms 512 KB
in05.txt AC 27 ms 512 KB
in06.txt AC 29 ms 640 KB
in07.txt AC 30 ms 768 KB
in08.txt AC 8 ms 768 KB
in09.txt AC 2 ms 640 KB
in10.txt AC 6 ms 256 KB
in11.txt AC 2 ms 256 KB
in12.txt AC 1 ms 256 KB
in13.txt AC 1 ms 256 KB
in14.txt AC 31 ms 1024 KB
in15.txt AC 31 ms 640 KB
in16.txt AC 22 ms 256 KB
in17.txt AC 19 ms 256 KB
in18.txt AC 16 ms 256 KB
in19.txt AC 16 ms 256 KB
in20.txt AC 1 ms 256 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