結果

問題 No.1239 Multiplication -2
ユーザー 沙耶花沙耶花
提出日時 2021-10-14 19:45:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 4,469 ms
コンパイル使用メモリ 272,136 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 19:24:21
合計ジャッジ時間 10,070 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 44 ms
4,348 KB
testcase_16 AC 73 ms
4,348 KB
testcase_17 AC 115 ms
4,348 KB
testcase_18 AC 116 ms
4,348 KB
testcase_19 AC 138 ms
4,348 KB
testcase_20 AC 140 ms
4,348 KB
testcase_21 AC 125 ms
4,348 KB
testcase_22 AC 126 ms
4,348 KB
testcase_23 AC 96 ms
4,348 KB
testcase_24 AC 94 ms
4,348 KB
testcase_25 AC 62 ms
4,348 KB
testcase_26 AC 71 ms
4,348 KB
testcase_27 AC 37 ms
4,348 KB
testcase_28 AC 117 ms
4,348 KB
testcase_29 AC 126 ms
4,348 KB
testcase_30 AC 58 ms
4,348 KB
testcase_31 AC 86 ms
4,348 KB
testcase_32 AC 145 ms
4,348 KB
testcase_33 AC 102 ms
4,348 KB
testcase_34 AC 94 ms
4,348 KB
testcase_35 AC 47 ms
4,348 KB
testcase_36 AC 42 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int main(){
	
	int N;
	cin>>N;
	
	vector<int> a(N);
	rep(i,N){
		cin>>a[i];
	}
	
	map<int,mint> dp;
	dp[1] = 1;
	
	mint ans = 0;
	
	rep(i,N){
		map<int,mint> ndp;
		for(auto x:dp){
			int t = x.first * a[i];
			if(t<=-3||t>=3)t = 3;
			ndp[t] += x.second;
		}
		if(i!=0)ndp[a[i]] += mint(2).pow(i-1);
		ans += ndp[-2] * mint(2).pow(max(0,(N-2)-i));
		
		swap(dp,ndp);
		//cout<<ans.val()<<endl;
	}
	
	rep(i,N-1)ans /= 2;
	
	cout<<ans.val()<<endl;
	
	return 0;
}
0