結果

問題 No.1492 01文字列と転倒
ユーザー jutamajutama
提出日時 2021-04-30 22:31:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 473 ms / 4,000 ms
コード長 4,218 bytes
コンパイル時間 3,612 ms
コンパイル使用メモリ 190,168 KB
実行使用メモリ 7,116 KB
最終ジャッジ日時 2023-09-26 06:47:51
合計ジャッジ時間 8,495 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 471 ms
7,116 KB
testcase_03 AC 433 ms
6,712 KB
testcase_04 AC 395 ms
6,588 KB
testcase_05 AC 331 ms
6,244 KB
testcase_06 AC 347 ms
6,224 KB
testcase_07 AC 377 ms
6,448 KB
testcase_08 AC 473 ms
6,992 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 350 ms
6,172 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 333 ms
6,116 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 275 ms
5,972 KB
testcase_22 AC 7 ms
4,376 KB
testcase_23 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bitset>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<ld, ld> pid;
typedef std::pair<ll, std::string> pls;
typedef std::vector<bool> vb;
typedef std::vector<vb> vvb;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<vvi> vvvi;
typedef std::vector<vvvi> vvvvi;
typedef std::vector<ll> vl;
typedef std::vector<vl> vvl;
typedef std::vector<vvl> vvvl;
typedef std::vector<vvvl> vvvvl;
typedef std::vector<ld> vd;
typedef std::vector<vd> vvd;
typedef std::vector<std::string> vs;
#define rep(i,n) for(auto i=0; i<n; ++i)
#define repm(i,s,n) for(auto i=s; i<n; ++i)
#define repd(i,n) for(auto i=n-1; i>=0; --i)
#define repdm(i,e,n) for(auto i=n-1; i>=e; --i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template <class mint, internal::is_modint_t<mint>* = nullptr>
constexpr istream& operator>>(istream& is, mint& x) noexcept {long long v = 0; std::cin >> v; x = v; return is;}
template <class mint, internal::is_modint_t<mint>* = nullptr>
constexpr ostream& operator<<(ostream& os, const mint& x) noexcept {os << x.val(); return os;}
inline void _n() { std::cout << std::endl; }
template <class T> inline void _(const T a) { std::cout << a; }
template <class T> inline void _l(const T a) { _(a); _n(); }
template <class T> inline void _s(const T a) { _(a); _(' '); }
template <class T> inline void _v(const std::vector<T> v) { for(auto a : v) _(a); }
template <class T> inline void _vl(const std::vector<T> v) { for(auto a : v) _l(a); }
template <class T> inline void _vs(const std::vector<T> v) { for(auto a : v) _s(a); _n(); }
template <class T> inline void _vvl(const std::vector<std::vector<T>> v) { for(auto a : v) { _v(a); _n(); } }
template <class T> inline void _vvs(const std::vector<std::vector<T>> v) { for(auto a : v) { _vs(a); } }
inline void ynl(const bool b) {_l(b ? "yes" : "no");}
inline void yns(const bool b) {_l(b ? "Yes" : "No");}
inline void ynu(const bool b) {_l(b ? "YES" : "NO");}

const int INF = 1 << 30;
const long long INF_LL = 1LL << 62;
const long long MOD1 = 1000000007;
const long long MOD9 = 998244353;
using mint1 = atcoder::modint1000000007;
using mint9 = atcoder::modint998244353;


//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//

void input() {
   
    
}

void solve() {
    
    int N, M; cin >> N >> M;
    using mint = modint;
    mint::set_mod(M);
    
    int Km = N * (N-1) / 2;
    
//    vector<vector<vector<mint>>> dp(2*N, vector<vector<mint>>(N, vector<mint>(Km+1, mint(0))));
//    dp[0][0][0] = 1;
//    rep(i, 2*N-1) {
//        vector<vector<mint>> dp_tmp = dp;
//        rep(j, N) {
//            rep(k, Km+1) {
//                if(2*(j+1) <= i+1) dp[i+1][j+1][k] += dp[i][j][k];
//                if(k+j <= Km) dp[i+1][j][k+j] += dp[i][j][k];
//            }
//        }
//    }
    
    vector<vector<mint>> dp(N, vector<mint>(Km+1, mint(0)));
    dp[0][0] = 1;
    rep(i, 2*N-1) {
        vector<vector<mint>> dp_tmp(N, vector<mint>(Km+1, mint(0)));
        rep(j, N) {
            rep(k, Km+1) {
                if(2*(j+1) <= i+1) dp_tmp[j+1][k] += dp[j][k];
                if(k+j <= Km) dp_tmp[j][k+j] += dp[j][k];
            }
        }
        dp = dp_tmp;
    }
    
    rep(k, N*N+1) {
        if(k <= Km) _l(dp[N-1][k].val());
        else _l(0);
    }
    
    
    
    
    
}

//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//

int main() {
    
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    std::cin.tie(0);
    ios::sync_with_stdio(false);
    
    input();
    solve();
    
    return 0;
}
0