Submission #17756680


Source Code Expand

Copy
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
#define SZ(x) (int)((x).size())
const int INF = 1 << 29;
const int MOD = 998244353;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 3e3 + 10;
int dp[N][N];
int pre[N << 1];

void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int main() {
  int n, m;
  cin >> n >> m;
  dp[0][0] = 1;
  pre[0] = 1;
  for (int rem = 1; rem <= n; ++rem) {
    for (int target = n; target >= 1; --target) {
      if (target > rem) continue;
      add(dp[rem][target], pre[2 * (rem - target)]);
      add(pre[2 * rem - target], dp[rem][target]);
      // for (int k = max(0, target * 2 - rem); k <= rem && k <= target; ++k) {
      //   // if (k == 0) trace(rem, target, rem - k, (target - k) * 2, dp[rem - k][(target - k) * 2]);
      //   add(dp[rem][target], dp[rem - k][(target - k) * 2]);
      // }
      // trace(rem, target, dp[rem][target]);
    }
  }
  cout << dp[n][m] << '\n';
  return 0;
}

Submission Info

Submission Time
Task D - Number of Multisets
User cuiaoxiang
Language C++ (Clang 10.0.0)
Score 600
Code Size 3291 Byte
Status AC
Exec Time 48 ms
Memory 30712 KB

Compile Error

./Main.cpp:78:11: warning: unused variable 'INF' [-Wunused-const-variable]
const int INF = 1 << 29;
          ^
1 warning generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 50
Set Name Test Cases
Sample example_00, example_01
All example_00, example_01, handmade_00, handmade_01, handmade_02, handmade_03, handmade_04, handmade_05, handmade_06, handmade_07, max_random2_00, max_random2_01, max_random2_02, max_random2_03, max_random2_04, max_random2_05, max_random2_06, max_random2_07, max_random2_08, max_random2_09, max_random_00, max_random_01, max_random_02, max_random_03, max_random_04, max_random_05, max_random_06, max_random_07, max_random_08, max_random_09, random_00, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, small_00, small_01, small_02, small_03, small_04, small_05, small_06, small_07, small_08, small_09
Case Name Status Exec Time Memory
example_00 AC 7 ms 3124 KB
example_01 AC 33 ms 25112 KB
handmade_00 AC 43 ms 30712 KB
handmade_01 AC 37 ms 29868 KB
handmade_02 AC 39 ms 25044 KB
handmade_03 AC 2 ms 3156 KB
handmade_04 AC 2 ms 3156 KB
handmade_05 AC 2 ms 3060 KB
handmade_06 AC 43 ms 29268 KB
handmade_07 AC 2 ms 3160 KB
max_random2_00 AC 45 ms 30092 KB
max_random2_01 AC 43 ms 30400 KB
max_random2_02 AC 45 ms 30508 KB
max_random2_03 AC 42 ms 30204 KB
max_random2_04 AC 38 ms 29816 KB
max_random2_05 AC 48 ms 30512 KB
max_random2_06 AC 42 ms 29544 KB
max_random2_07 AC 39 ms 30504 KB
max_random2_08 AC 45 ms 30328 KB
max_random2_09 AC 44 ms 30712 KB
max_random_00 AC 40 ms 30136 KB
max_random_01 AC 46 ms 30268 KB
max_random_02 AC 39 ms 30452 KB
max_random_03 AC 47 ms 30264 KB
max_random_04 AC 44 ms 29752 KB
max_random_05 AC 38 ms 30616 KB
max_random_06 AC 46 ms 29624 KB
max_random_07 AC 45 ms 30584 KB
max_random_08 AC 43 ms 30252 KB
max_random_09 AC 41 ms 30612 KB
random_00 AC 12 ms 6884 KB
random_01 AC 2 ms 3872 KB
random_02 AC 2 ms 3424 KB
random_03 AC 14 ms 11288 KB
random_04 AC 41 ms 25696 KB
random_05 AC 15 ms 11028 KB
random_06 AC 12 ms 8212 KB
random_07 AC 18 ms 14828 KB
random_08 AC 21 ms 15936 KB
random_09 AC 2 ms 3524 KB
small_00 AC 2 ms 3248 KB
small_01 AC 2 ms 3396 KB
small_02 AC 2 ms 3396 KB
small_03 AC 2 ms 3292 KB
small_04 AC 2 ms 3248 KB
small_05 AC 2 ms 3444 KB
small_06 AC 2 ms 3144 KB
small_07 AC 2 ms 3552 KB
small_08 AC 2 ms 3376 KB
small_09 AC 2 ms 3524 KB