結果

問題 No.1847 Good Sequence
ユーザー 👑 potato167
提出日時 2021-12-07 02:57:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 751 bytes
コンパイル時間 1,856 ms
コンパイル使用メモリ 193,192 KB
最終ジャッジ日時 2025-01-26 06:25:46
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 RE * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
const int INF=2100000000;
const ll mod=1e9+7;
#define rep(i,a) for (ll i=0;i<a;i++)

int L,N,M;
vector<int> K,p;
int ans=0;

void f(int ind){
	if(ind!=L){
		rep(i,N){
			p[ind]=i+1;
			f(ind+1);
		}
	}else{
		rep(j,M){
			int tmp=0;
			rep(i,L){
				if(p[i]==K[j]) tmp++;
				else if(tmp==K[j]) break;
				else tmp=0;
			}
			if(tmp==K[j]){
				ans++;
				break;
			}
		}
	}
	return ;
}

//  rainy ~ 雨に打たれて ~
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin>>L>>N>>M;
	p.resize(L);
	K.resize(M);
	rep(i,M) cin>>K[i];
	assert(L<=1000);
	if(M==0){
		cout<<"0\n";
		return 0;
	}
	f(0);
	cout<<ans<<"\n";
}
0