結果

問題 No.770 Median Sequence
ユーザー 👑 kmjpkmjp
提出日時 2018-12-18 02:00:21
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,195 bytes
コンパイル時間 2,306 ms
コンパイル使用メモリ 162,460 KB
実行使用メモリ 4,948 KB
最終ジャッジ日時 2023-10-25 23:34:15
合計ジャッジ時間 5,950 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,912 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 32 ms
4,912 KB
testcase_03 AC 3 ms
4,912 KB
testcase_04 AC 3 ms
4,912 KB
testcase_05 AC 5 ms
4,912 KB
testcase_06 AC 18 ms
4,912 KB
testcase_07 AC 14 ms
4,912 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll mo=1000000007;
ll from[303][303];
ll to[303][303];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	for(i=1;i<=N;i++) from[N-i][i]=1;
	FOR(i,N-1) {
		ZERO(to);
		for(r=1;r<N;r++) {
			(to[0][r]+=from[0][r+1])%=mo;
		}
		for(x=1;x<=N;x++) {
			ll ret=0;
			for(y=0;y<N;y++) {
				(to[max(0,y-1)][x]+=from[y][x])%=mo;
				ret+=from[y][x];
			}
			for(r=x+1;r<=N;r++) {
				(to[N-r][r]+=ret)%=mo;
			}
		}
		swap(from,to);
	}
	
	ll ret=0;
	FOR(x,N+1) FOR(y,N+1) ret+=from[x][y];
		cout<<ret%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0