Submission #38485145


Source Code Expand

#include<bits/stdc++.h>
#define LL long long
#define MOD 998244353
using namespace std;
int mul(const int &a, const int &b)
{
    return 1LL * a * b % MOD;
}
void Inc(int &a, const int &b)
{
    ((a += b) >= MOD) && (a -= MOD);
}
void Mul(int &a, const int &b)
{
    a = 1LL * a * b % MOD;
}
void Sqr(int &a)
{
    a = 1LL * a * a % MOD;
}
int qwqmi(int x, int k = MOD - 2)
{
    int res = 1;
    while(k)
    {
        if(k & 1) Mul(res, x);
        Sqr(x), k >>= 1;
    }
    return res;
}
const int N = 1e7 + 5;
int fac[2 * N], facinv[2 * N], th[N];
void preprocess()
{
    fac[0] = facinv[0] = th[0] = 1;
    for(int i = 1; i < 2 * N; ++i)
        fac[i] = mul(fac[i - 1], i);
    facinv[2 * N - 1] = qwqmi(fac[2 * N - 1]);
    for(int i = 2 * N - 2; i >= 1; --i)
        facinv[i] = mul(facinv[i + 1], i + 1);
    for(int i = 1; i < N; ++i)
        th[i] = mul(th[i - 1], 3);
}
int binom(int n, int m)
{
    if(n < m) return 0;
    return mul(fac[n], mul(facinv[m], facinv[n - m]));
}
int n, ans;
int main()
{
    preprocess();
    scanf("%d", &n);
    for(int i = 0; i <= 2 * n && n - 1 - 2 * i >= 0; ++i)
    {
        int w = 1;
        Mul(w, binom(2 * n, i));
        Mul(w, binom(2 * n - i, n - 1 - 2 * i));
        Mul(w, th[n - 1 - 2 * i]);
        Inc(ans, w);
    }
    Mul(ans, qwqmi(n));
    printf("%d\n", ans);
    return 0;
}

Submission Info

Submission Time
Task H - Beautiful Binary Tree
User Schucking_Sattin
Language C++ (GCC 9.2.1)
Score 600
Code Size 1409 Byte
Status AC
Exec Time 399 ms
Memory 199052 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:53:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   53 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 4
AC × 35
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 02_medium_00.txt, 02_medium_01.txt, 02_medium_02.txt, 02_medium_03.txt, 02_medium_04.txt, 02_medium_05.txt, 02_medium_06.txt, 02_medium_07.txt, 02_medium_08.txt, 02_medium_09.txt, 03_large_00.txt, 03_large_01.txt, 03_large_02.txt, 03_large_03.txt, 03_large_04.txt, 04_max_00.txt, 04_max_01.txt, 04_max_02.txt, 05_random_00.txt, 05_random_01.txt, 05_random_02.txt, 05_random_03.txt, 05_random_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 316 ms 198948 KiB
00_sample_01.txt AC 309 ms 198884 KiB
00_sample_02.txt AC 314 ms 198832 KiB
00_sample_03.txt AC 315 ms 198932 KiB
01_small_00.txt AC 311 ms 199052 KiB
01_small_01.txt AC 310 ms 198928 KiB
01_small_02.txt AC 313 ms 199048 KiB
01_small_03.txt AC 313 ms 198952 KiB
01_small_04.txt AC 315 ms 199024 KiB
01_small_05.txt AC 316 ms 199044 KiB
01_small_06.txt AC 314 ms 198968 KiB
01_small_07.txt AC 310 ms 198952 KiB
02_medium_00.txt AC 312 ms 198832 KiB
02_medium_01.txt AC 313 ms 198836 KiB
02_medium_02.txt AC 310 ms 198972 KiB
02_medium_03.txt AC 310 ms 198856 KiB
02_medium_04.txt AC 317 ms 198948 KiB
02_medium_05.txt AC 311 ms 199024 KiB
02_medium_06.txt AC 314 ms 198932 KiB
02_medium_07.txt AC 313 ms 198968 KiB
02_medium_08.txt AC 309 ms 199024 KiB
02_medium_09.txt AC 310 ms 198876 KiB
03_large_00.txt AC 383 ms 199028 KiB
03_large_01.txt AC 389 ms 198880 KiB
03_large_02.txt AC 382 ms 198928 KiB
03_large_03.txt AC 394 ms 198948 KiB
03_large_04.txt AC 366 ms 199024 KiB
04_max_00.txt AC 399 ms 199024 KiB
04_max_01.txt AC 398 ms 198836 KiB
04_max_02.txt AC 399 ms 198944 KiB
05_random_00.txt AC 339 ms 199028 KiB
05_random_01.txt AC 359 ms 199028 KiB
05_random_02.txt AC 355 ms 198952 KiB
05_random_03.txt AC 383 ms 198944 KiB
05_random_04.txt AC 327 ms 198924 KiB