Submission #25589243


Source Code Expand

Copy
/*~Rainybunny~*/
#include <bits/stdc++.h>
#define rep( i, l, r ) for ( int i = l, rep##i = r; i <= rep##i; ++i )
#define per( i, r, l ) for ( int i = r, per##i = l; i >= per##i; --i )
const int MAXN = 200, MOD = 998244353;
int n, m, f[MAXN * 2 + 5][MAXN * 2 + 5], fac[MAXN * 2 + 5], ifac[MAXN * 2 + 5];
bool good[MAXN * 2 + 5][MAXN * 2 + 5];
inline void subeq( int& a, const int b ) { ( a -= b ) < 0 && ( a += MOD ); }
inline int sub( int a, const int b ) { return ( a -= b ) < 0 ? a + MOD : a; }
inline int mul( const long long a, const int b ) { return int( a * b % MOD ); }
inline int add( int a, const int b ) { return ( a += b ) < MOD ? a : a - MOD; }
inline void addeq( int& a, const int b ) { ( a += b ) >= MOD && ( a -= MOD ); }
inline int mpow( int a, int b ) {
int ret = 1;
for ( ; b; a = mul( a, a ), b >>= 1 ) ret = mul( ret, b & 1 ? a : 1 );
return ret;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/*~Rainybunny~*/

#include <bits/stdc++.h>

#define rep( i, l, r ) for ( int i = l, rep##i = r; i <= rep##i; ++i )
#define per( i, r, l ) for ( int i = r, per##i = l; i >= per##i; --i )

const int MAXN = 200, MOD = 998244353;
int n, m, f[MAXN * 2 + 5][MAXN * 2 + 5], fac[MAXN * 2 + 5], ifac[MAXN * 2 + 5];
bool good[MAXN * 2 + 5][MAXN * 2 + 5];

inline void subeq( int& a, const int b ) { ( a -= b ) < 0 && ( a += MOD ); }
inline int sub( int a, const int b ) { return ( a -= b ) < 0 ? a + MOD : a; }
inline int mul( const long long a, const int b ) { return int( a * b % MOD ); }
inline int add( int a, const int b ) { return ( a += b ) < MOD ? a : a - MOD; }
inline void addeq( int& a, const int b ) { ( a += b ) >= MOD && ( a -= MOD ); }
inline int mpow( int a, int b ) {
    int ret = 1;
    for ( ; b; a = mul( a, a ), b >>= 1 ) ret = mul( ret, b & 1 ? a : 1 );
    return ret;
}

inline void init() {
    fac[0] = 1;
    rep ( i, 1, n << 1 ) fac[i] = mul( i, fac[i - 1] );
    ifac[n << 1] = mpow( fac[n << 1], MOD - 2 );
    per ( i, ( n << 1 ) - 1, 0 ) ifac[i] = mul( ifac[i + 1], i + 1 );
}

inline int comb( const int a, const int b ) {
    return a < b ? 0 : mul( fac[a], mul( ifac[b], ifac[a - b] ) );
}

int main() {
    scanf( "%d %d", &n, &m ), init();
    rep ( i, 1, m ) {
        int u, v; scanf( "%d %d", &u, &v );
        good[u][v] = good[v][u] = true;
    }
    rep ( i, 1, n << 1 | 1 ) f[i][i - 1] = 1;
    rep ( len, 2, n << 1 ) if ( ~len & 1 ) {
        for ( int l = 1, r; ( r = l + len - 1 ) <= n << 1; ++l ) {
            rep ( i, l + 1, r ) if ( ( i - l ) & 1 ) {
                if ( good[l][i] ) {
                    addeq( f[l][r], mul( mul( f[l + 1][i - 1], f[i + 1][r] ),
                      comb( r - l + 1 >> 1, r - i >> 1 ) ) );
                }
            }
        }
    }
    printf( "%d\n", f[1][n << 1] );
    return 0;
}

Submission Info

Submission Time
Task F - Make Pair
User Rainybunny
Language C++ (GCC 9.2.1)
Score 500
Code Size 1924 Byte
Status AC
Exec Time 52 ms
Memory 4624 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:46:35: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
   46 |                       comb( r - l + 1 >> 1, r - i >> 1 ) ) );
      |                             ~~~~~~^~~
./Main.cpp:46:47: warning: suggest parentheses around ‘-’ inside ‘>>’ [-Wparentheses]
   46 |                       comb( r - l + 1 >> 1, r - i >> 1 ) ) );
      |                                             ~~^~~
./Main.cpp:35:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   35 |     scanf( "%d %d", &n, &m ), init();
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
./Main.cpp:37:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   37 |         int u, v; scanf( "%d %d", &u, &v );
      |                   ~~~~~^~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 28
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt
Case Name Status Exec Time Memory
example_00.txt AC 11 ms 3732 KB
example_01.txt AC 2 ms 3596 KB
example_02.txt AC 4 ms 3776 KB
hand_00.txt AC 52 ms 4520 KB
hand_01.txt AC 42 ms 4624 KB
hand_02.txt AC 13 ms 4368 KB
hand_03.txt AC 15 ms 4624 KB
hand_04.txt AC 13 ms 4520 KB
hand_05.txt AC 2 ms 3596 KB
hand_06.txt AC 3 ms 3740 KB
random_00.txt AC 16 ms 4496 KB
random_01.txt AC 13 ms 4516 KB
random_02.txt AC 15 ms 4516 KB
random_03.txt AC 38 ms 4404 KB
random_04.txt AC 43 ms 4396 KB
random_05.txt AC 3 ms 3948 KB
random_06.txt AC 41 ms 4592 KB
random_07.txt AC 42 ms 4500 KB
random_08.txt AC 45 ms 4396 KB
random_09.txt AC 33 ms 4408 KB
random_10.txt AC 3 ms 3868 KB
random_11.txt AC 39 ms 4536 KB
random_12.txt AC 31 ms 4356 KB
random_13.txt AC 26 ms 4540 KB
random_14.txt AC 32 ms 4516 KB
random_15.txt AC 2 ms 3648 KB
random_16.txt AC 22 ms 4516 KB
random_17.txt AC 15 ms 4528 KB


2025-04-21 (Mon)
16:25:32 +00:00