Contest Duration: - (local time) (160 minutes) Back to Home

Submission #6498060

Source Code Expand

Copy
```#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
long long mod_inv(long long a, long long mod = MOD) {
a %= mod;
if (__gcd(a, mod) != 1) return -1;
long long b = mod, x = 1, y = 0;
while (b > 0) {
long long tmp = a / b;
a -= tmp * b;
swap(a, b);
x -= tmp * y;
swap(x, y);
}
x %= mod;
if (x < 0) x += mod;
return x;
}

const int MAX = 10000000;
long long fact[MAX + 1], fact_inv[MAX + 1];
void nCk_init(int val = MAX, long long mod = MOD) {
fact[0] = 1;
FOR(i, 1, val + 1) fact[i] = fact[i - 1] * i % mod;
fact_inv[val] = mod_inv(fact[val], mod);
for (int i = val; i > 0; --i) fact_inv[i - 1] = fact_inv[i] * i % mod;
}

long long nCk(int n, int k, long long mod = MOD) {
if (n < 0 || n < k || k < 0) return 0;
return fact[n] * fact_inv[k] % mod * fact_inv[n - k] % mod;
}

// set<vector<int> > st;
// int m;
// void dfs(int cnt, vector<int> &v) {
//   if (cnt == m) {
//     st.emplace(v);
//     return;
//   }
//   REP(i, v.size()) REP(j, v.size()) if (i != j) {
//     v[i] += 1;
//     v[j] += 2;
//     dfs(cnt + 1, v);
//     v[i] -= 1;
//     v[j] -= 2;
//   }
// }

int main() {
cin.tie(0); ios::sync_with_stdio(false);
// freopen("input.txt", "r", stdin);

nCk_init();
// // vector<int> v(n, 0);
// // dfs(0, v);
// // cout << st.size() << '\n';
// // for (vector<int> vec : st) {
// //   REP(i, vec.size()) cout << vec[i] << ' ';
// //   cout << '\n';
// // }
int n, m; cin >> n >> m;
if (n % 2 == 0) assert(m < n / 2);
else assert(m <= (n + 1) / 2);
long long ans = nCk(3 * m + n - 1, n - 1), tmp = 0;
REP(i, m) (tmp += nCk(i + n - 2, n - 2)) %= MOD;
(tmp *= n) %= MOD;
ans -= tmp;
if (ans < 0) ans += MOD;
cout << ans << '\n';
return 0;
}
```

Submission Info

Submission Time 2019-07-21 23:39:53+0900 C - GP 2 emthrm C++14 (GCC 5.4.1) 0 2585 Byte RE 423 ms 156544 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
 AC × 1 RE × 3
 AC × 1 WA × 9 RE × 16
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
All 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Case Name Status Exec Time Memory
01-01.txt RE 422 ms 156544 KB
01-02.txt RE 421 ms 156544 KB
01-03.txt WA 326 ms 156544 KB
01-04.txt RE 422 ms 156544 KB
01-05.txt WA 326 ms 156544 KB
01-06.txt RE 422 ms 156544 KB
01-07.txt RE 423 ms 156544 KB
01-08.txt RE 421 ms 156544 KB
01-09.txt RE 422 ms 156544 KB
01-10.txt WA 329 ms 156544 KB
01-11.txt RE 421 ms 156544 KB
01-12.txt RE 423 ms 156544 KB
01-13.txt WA 327 ms 156544 KB
01-14.txt WA 327 ms 156544 KB
01-15.txt WA 327 ms 156544 KB
01-16.txt RE 420 ms 156544 KB
01-17.txt WA 326 ms 156544 KB
01-18.txt WA 326 ms 156544 KB
01-19.txt WA 326 ms 156544 KB
01-20.txt RE 421 ms 156544 KB
01-21.txt RE 421 ms 156544 KB
01-22.txt RE 421 ms 156544 KB
sample-01.txt RE 422 ms 156544 KB
sample-02.txt AC 326 ms 156544 KB
sample-03.txt RE 422 ms 156544 KB
sample-04.txt RE 422 ms 156544 KB