結果

問題 No.510 二次漸化式
ユーザー ldsybldsyb
提出日時 2017-04-29 00:17:52
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 779 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 67,936 KB
実行使用メモリ 6,816 KB
最終ジャッジ日時 2023-10-11 20:47:20
合計ジャッジ時間 26,121 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 9 ms
6,500 KB
testcase_32 AC 9 ms
6,504 KB
testcase_33 AC 9 ms
6,480 KB
testcase_34 WA -
testcase_35 AC 31 ms
6,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	using ll = long long;
	constexpr ll mod = 1e9 + 7;
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	ll a[n + 1], b[n + 1], x[n]{}, y[n]{};
	a[0] = b[0] = 1;
	ll puni = 1;
	while(q--){
		char c;
		cin >> c;
		if(c == 'x'){
			ll i, v;
			cin >> i >> v;
			x[i] = v;
			puni = max(1ll, min(puni, i));
		}
		if(c == 'y'){
			ll i, v;
			cin >> i >> v;
			y[i] = v;
			puni = max(1ll, min(puni, i));
		}
		if(c == 'a'){
			int i;
			cin >> i;
			if(puni <= i){
				for(int j = puni; j <= i; j++){
					a[j] = (x[j - 1] * b[j - 1] % mod * b[j - 1] % mod + a[j - 1]) % mod;
					b[j] = (y[j - 1] * b[j - 1] % mod + 1) % mod;
				}
				puni = n + 1;
			}
			cout << a[i] << endl;
		}
	}
}
0