Submission #33689796
Source Code Expand
#include <iostream>
using u32 = unsigned int;
using u64 = unsigned long long;
template <u32 MOD>
struct Mint {
u32 n;
constexpr Mint(u32 n = 0): n(n) {}
constexpr Mint operator-() const { return Mint(n ? MOD - n: 0); }
constexpr Mint &operator+=(const Mint &rhs){ n += rhs.n; if(n >= MOD) n -= MOD; return *this; }
constexpr Mint &operator-=(const Mint &rhs){ if(rhs.n > n) n += MOD; n -= rhs.n; return *this; }
constexpr Mint &operator*=(const Mint &rhs){ n = (u64) n * rhs.n % MOD; return *this; }
friend constexpr Mint operator+(const Mint &lhs, const Mint &rhs){ return Mint(lhs) += rhs; }
friend constexpr Mint operator-(const Mint &lhs, const Mint &rhs){ return Mint(lhs) -= rhs; }
friend constexpr Mint operator*(const Mint &lhs, const Mint &rhs){ return Mint(lhs) *= rhs; }
friend constexpr bool operator==(const Mint &lhs, const Mint &rhs){ return lhs.n == rhs.n; }
friend constexpr bool operator!=(const Mint &lhs, const Mint &rhs){ return lhs.n != rhs.n; }
};
template <class T>
T modpow(T x, int n){
T r(1);
for(; n; n >>= 1){
if(n&1) r *= x;
x *= x;
}
return r;
}
template <u32 MOD>
Mint<MOD> inv(Mint<MOD> n){
return modpow(n, MOD-2);
}
constexpr u32 mod = 998244353;
using mint = Mint<mod>;
mint fact[200001];
mint ifact[200001];
mint binom(int n, int k){ return k > n ? 0 : fact[n] * ifact[k] * ifact[n-k]; }
int deg[200000];
int main(){
int n, m, k;
std::cin >> n >> m >> k;
fact[0] = 1;
for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
ifact[n] = inv(fact[n]);
for(int i = n-1; i >=0; i--) ifact[i] = ifact[i+1] * (i+1);
for(int i = 0; i < m; i++){
int u, v;
std::cin >> u >> v;
--u, --v;
deg[u]++, deg[v]++;
}
int count = 0;
for(int i = 0; i < n; i++){
if(deg[i] & 1) count++;
}
mint ans = 0;
for(int i = 0; i <= k; i+=2){
ans += binom(count, i) * binom(n - count, k - i);
}
std::cout << ans.n << std::endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Red and Blue Graph |
| User | ryuhei |
| Language | C++ (GCC 9.2.1) |
| Score | 500 |
| Code Size | 2023 Byte |
| Status | AC |
| Exec Time | 91 ms |
| Memory | 5972 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 7 ms | 3600 KiB |
| example_01.txt | AC | 2 ms | 3412 KiB |
| test_00.txt | AC | 87 ms | 5972 KiB |
| test_01.txt | AC | 88 ms | 5748 KiB |
| test_02.txt | AC | 87 ms | 5792 KiB |
| test_03.txt | AC | 51 ms | 5892 KiB |
| test_04.txt | AC | 51 ms | 5860 KiB |
| test_05.txt | AC | 56 ms | 5784 KiB |
| test_06.txt | AC | 91 ms | 5924 KiB |
| test_07.txt | AC | 90 ms | 5972 KiB |
| test_08.txt | AC | 29 ms | 5028 KiB |
| test_09.txt | AC | 70 ms | 5372 KiB |
| test_10.txt | AC | 72 ms | 5280 KiB |
| test_11.txt | AC | 68 ms | 5312 KiB |
| test_12.txt | AC | 77 ms | 5352 KiB |
| test_13.txt | AC | 73 ms | 5320 KiB |
| test_14.txt | AC | 74 ms | 5348 KiB |