結果

問題 No.510 二次漸化式
ユーザー kazumakazuma
提出日時 2017-04-29 01:24:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 696 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 166,324 KB
実行使用メモリ 10,924 KB
最終ジャッジ日時 2023-10-11 20:10:13
合計ジャッジ時間 23,897 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 42 ms
4,352 KB
testcase_03 AC 43 ms
4,348 KB
testcase_04 AC 42 ms
4,348 KB
testcase_05 AC 42 ms
4,348 KB
testcase_06 AC 373 ms
4,352 KB
testcase_07 AC 365 ms
4,348 KB
testcase_08 AC 367 ms
4,352 KB
testcase_09 AC 369 ms
4,352 KB
testcase_10 AC 6 ms
4,348 KB
testcase_11 AC 6 ms
4,348 KB
testcase_12 AC 6 ms
4,352 KB
testcase_13 AC 7 ms
4,352 KB
testcase_14 AC 6 ms
4,352 KB
testcase_15 AC 6 ms
4,352 KB
testcase_16 AC 2,204 ms
6,220 KB
testcase_17 AC 2,132 ms
6,476 KB
testcase_18 AC 2,166 ms
6,176 KB
testcase_19 AC 2,124 ms
6,244 KB
testcase_20 AC 2,163 ms
6,252 KB
testcase_21 AC 2,172 ms
6,168 KB
testcase_22 AC 2,199 ms
6,156 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

int main()
{
	cin.sync_with_stdio(false);
	int n, q, ii, vv;
	char c;
	cin >> n >> q;
	vector<ll> a(n + 1, 1), b(n + 1, 1), x(n + 1), y(n + 1);
	while (q--) {
		cin >> c;
		if (c == 'x') {
			cin >> ii >> vv;
			x[ii] = vv;
			for (int i = ii; i < n; i++) {
				a[i + 1] = (x[i] * b[i] % mod * b[i] % mod + a[i]) % mod;
			}
		}
		else if (c == 'y') {
			cin >> ii >> vv;
			y[ii] = vv;
			for (int i = ii; i < n; i++) {
				a[i + 1] = (x[i] * b[i] % mod * b[i] % mod + a[i]) % mod;
				b[i + 1] = (y[i] * b[i] + 1) % mod;
			}
		}
		else {
			cin >> ii;
			printf("%lld\n", a[ii]);
		}
	}
	return 0;
}
0