結果

問題 No.1492 01文字列と転倒
ユーザー n_vipn_vip
提出日時 2021-04-30 21:34:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 482 ms / 4,000 ms
コード長 3,628 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 134,100 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2023-09-26 04:36:10
合計ジャッジ時間 7,259 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
13,300 KB
testcase_01 AC 17 ms
13,168 KB
testcase_02 AC 480 ms
13,144 KB
testcase_03 AC 450 ms
13,260 KB
testcase_04 AC 431 ms
13,240 KB
testcase_05 AC 384 ms
13,312 KB
testcase_06 AC 398 ms
13,236 KB
testcase_07 AC 422 ms
13,240 KB
testcase_08 AC 482 ms
13,192 KB
testcase_09 AC 21 ms
13,188 KB
testcase_10 AC 13 ms
13,184 KB
testcase_11 AC 18 ms
13,272 KB
testcase_12 AC 18 ms
13,192 KB
testcase_13 AC 14 ms
13,168 KB
testcase_14 AC 386 ms
13,188 KB
testcase_15 AC 40 ms
13,300 KB
testcase_16 AC 71 ms
13,188 KB
testcase_17 AC 375 ms
13,172 KB
testcase_18 AC 72 ms
13,144 KB
testcase_19 AC 31 ms
13,180 KB
testcase_20 AC 65 ms
13,192 KB
testcase_21 AC 335 ms
13,180 KB
testcase_22 AC 73 ms
13,188 KB
testcase_23 AC 56 ms
13,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"
#define cauto const auto

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
void ouT(ll x,int d=3){auto re=to_string(x);if((int)re.size()>d) re=x>0?"oo":"-oo";cout<<string(d-re.size(),' ')<<re<<",";}
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
template<class A,class B> pair<A,B> operator+(const pair<A,B> &p,const pair<A,B> &q){ return {p.X+q.X,p.Y+q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator+=(pair<A,B> &p,const pair<C,D> &q){ p.X+=q.X; p.Y+=q.Y; return p;}
template<class A,class B> pair<A,B> operator-(const pair<A,B> &p,const pair<A,B> &q){ return {p.X-q.X,p.Y-q.Y};}
template<class A,class B,class C,class D> pair<A,B>& operator-=(pair<A,B> &p,const pair<C,D> &q){ p.X-=q.X; p.Y-=q.Y; return p;}
template<class A,class B> istream& operator>>(istream &is, pair<A,B> &p){ is>>p.X>>p.Y; return is;}
template<class T=ll> T read(){ T re; cin>>re; return move(re);}
template<class T=ll> T read(const T &dec){ T re; cin>>re; return re-dec;}
template<class T=ll> vector<T> readV(const int sz){ vector<T> re(sz); for(auto &x:re) x=read<T>(); return move(re);}
template<class T=ll> vector<T> readV(const int sz, const T &dec){ vector<T> re(sz); for(auto &x:re) x=read<T>(dec); return move(re);}
vv<int> readG(const int &n,const int &m){ vv<int> g(n); rep(_,m){ cauto a=read<int>(1),b=read<int>(1); g[a].pb(b); g[b].pb(a);} return move(g);}
vv<int> readG(const int &n){ return readG(n,n-1);}
#define TT cauto TTT=read();rep(_,TTT)

int dp[2][112][11234];

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	cauto n=read();
	cauto mod=read();
	auto &cur=dp[0];
	auto &nxt=dp[1];
	cur[0][0]=1;
		// rep(i,n+1){rep(j,n*n+1) ouT(cur[i][j]); cout NL;} cout NL;
	rep(len,n+n){
		fill(nxt[0],nxt[112],0);
		rep(i,n+1)rep(j,n*n+1)if(cur[i][j]){
			cauto one=(len-i)/2;
			out(i,j,one,1);
			if(j+one<=n*n && (nxt[i+1][j+one]+=cur[i][j])>=mod) nxt[i+1][j+one]-=mod;
			if(i && (nxt[i-1][j]+=cur[i][j])>=mod) nxt[i-1][j]-=mod;
		}
		swap(cur,nxt);
		// rep(i,n+1){rep(j,n*n+1) ouT(cur[i][j]); cout NL;} cout NL;
	}
	rep(i,n*n+1) cout<<cur[0][i] NL;
  return 0;
}
0