結果

問題 No.2378 Cards and Subsequences
ユーザー 沙耶花沙耶花
提出日時 2023-07-10 19:41:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 5,225 ms
コンパイル使用メモリ 264,600 KB
実行使用メモリ 19,212 KB
最終ジャッジ日時 2023-10-10 01:21:48
合計ジャッジ時間 7,542 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 5 ms
5,188 KB
testcase_07 AC 6 ms
5,248 KB
testcase_08 AC 7 ms
5,456 KB
testcase_09 AC 9 ms
6,268 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 39 ms
19,044 KB
testcase_12 AC 39 ms
18,932 KB
testcase_13 AC 37 ms
19,008 KB
testcase_14 AC 37 ms
18,924 KB
testcase_15 AC 37 ms
19,160 KB
testcase_16 AC 38 ms
18,872 KB
testcase_17 AC 39 ms
18,936 KB
testcase_18 AC 39 ms
19,008 KB
testcase_19 AC 38 ms
19,068 KB
testcase_20 AC 39 ms
19,008 KB
testcase_21 AC 33 ms
18,916 KB
testcase_22 AC 33 ms
18,924 KB
testcase_23 AC 33 ms
18,968 KB
testcase_24 AC 33 ms
19,048 KB
testcase_25 AC 33 ms
18,932 KB
testcase_26 AC 50 ms
18,988 KB
testcase_27 AC 50 ms
19,064 KB
testcase_28 AC 51 ms
18,988 KB
testcase_29 AC 51 ms
18,924 KB
testcase_30 AC 51 ms
19,060 KB
testcase_31 AC 45 ms
19,212 KB
testcase_32 AC 29 ms
19,068 KB
testcase_33 AC 39 ms
18,984 KB
testcase_34 AC 38 ms
18,944 KB
testcase_35 AC 37 ms
19,044 KB
testcase_36 AC 38 ms
18,924 KB
testcase_37 AC 5 ms
4,576 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:34:21: 警告: ‘d’ may be used uninitialized [-Wmaybe-uninitialized]
   34 |                 int d;
      |                     ^

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	int N,M,K;
	cin>>N>>M>>K;
	
	vector<int> s(N);
	rep(i,N){
		cin>>s[i];
		s[i]--;
	}
	vector<int> a(M),b(M);
	rep(i,M)cin>>a[i];
	rep(i,M)cin>>b[i];
	
	vector<vector<int>> is(M);
	rep(i,N){
		is[s[i]].push_back(i);
	}
	
	vector dp(N+1,vector<mint>(K+1,0));
	dp[0][0] = 1;
	mint ans = 0;
	rep(i,N){
		int d;
		rep(j,is[s[i]].size()){
			if(is[s[i]][j]==i){
				d = j;
				break;
			}
		}
		rep(j,K+1){
			{
				int x = j - a[s[i]];
				if(x>=0){
					dp[i+1][j] += dp[i][x];
					if(d!=0){
						dp[i+1][j] -= dp[is[s[i]][d-1]][x];
					}
				}
			}
			{
				int x = j - b[s[i]];
				if(x>=0){
					dp[i+1][j] += dp[i][x];
					if(d!=0){
						dp[i+1][j] -= dp[is[s[i]][d-1]][x];
					}
				}
			}
		}
		rep(j,K+1){
			if(j==K)ans += dp[i+1][j];
			dp[i+1][j] += dp[i][j];
		}
	}
	
	cout<<ans.val()<<endl;
	
	return 0;
}
0