結果

問題 No.510 二次漸化式
ユーザー ldsybldsyb
提出日時 2017-04-29 00:32:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 712 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 65,424 KB
実行使用メモリ 6,828 KB
最終ジャッジ日時 2023-10-11 20:50:24
合計ジャッジ時間 37,248 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 53 ms
4,348 KB
testcase_03 AC 52 ms
4,352 KB
testcase_04 AC 38 ms
4,352 KB
testcase_05 AC 39 ms
4,348 KB
testcase_06 AC 226 ms
4,352 KB
testcase_07 AC 224 ms
4,348 KB
testcase_08 AC 353 ms
4,348 KB
testcase_09 AC 356 ms
4,348 KB
testcase_10 AC 18 ms
4,352 KB
testcase_11 AC 18 ms
4,352 KB
testcase_12 AC 18 ms
4,352 KB
testcase_13 AC 18 ms
4,348 KB
testcase_14 AC 18 ms
4,356 KB
testcase_15 AC 18 ms
4,352 KB
testcase_16 AC 1,743 ms
6,756 KB
testcase_17 AC 1,030 ms
6,520 KB
testcase_18 AC 1,052 ms
6,460 KB
testcase_19 AC 1,063 ms
6,744 KB
testcase_20 AC 1,710 ms
6,480 KB
testcase_21 AC 1,709 ms
6,612 KB
testcase_22 AC 1,723 ms
6,520 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 2,113 ms
6,468 KB
testcase_29 AC 2,088 ms
6,472 KB
testcase_30 AC 2,070 ms
6,496 KB
testcase_31 AC 8 ms
6,468 KB
testcase_32 AC 8 ms
6,596 KB
testcase_33 AC 9 ms
6,548 KB
testcase_34 AC 33 ms
6,540 KB
testcase_35 AC 31 ms
6,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
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 = 0;
	while(q--){
		char c;
		cin >> c;
		if(c == 'x'){
			ll i, v;
			cin >> i >> v;
			x[i] = v;
			puni = min(puni, i);
		}
		if(c == 'y'){
			ll i, v;
			cin >> i >> v;
			y[i] = v;
			puni = min(puni, i);
		}
		if(c == 'a'){
			ll i;
			cin >> i;
			if(puni != ll(1e7)){
				for(int j = puni; j < n; j++){
					a[j + 1] = (x[j] * b[j] % mod * b[j] + a[j]) % mod;
					b[j + 1] = (y[j] * b[j] + 1) % mod;
				}
				puni = 1e7;
			}
			cout << a[i] << endl;
		}
	}
}
0