結果

問題 No.510 二次漸化式
ユーザー ldsybldsyb
提出日時 2017-04-29 00:41:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 721 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 63,644 KB
実行使用メモリ 6,692 KB
最終ジャッジ日時 2023-10-11 20:05:50
合計ジャッジ時間 37,880 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 53 ms
4,348 KB
testcase_03 AC 53 ms
4,352 KB
testcase_04 AC 39 ms
4,352 KB
testcase_05 AC 39 ms
4,352 KB
testcase_06 AC 231 ms
4,348 KB
testcase_07 AC 228 ms
4,348 KB
testcase_08 AC 356 ms
4,348 KB
testcase_09 AC 357 ms
4,352 KB
testcase_10 AC 19 ms
4,352 KB
testcase_11 AC 18 ms
4,352 KB
testcase_12 AC 18 ms
4,348 KB
testcase_13 AC 17 ms
4,352 KB
testcase_14 AC 18 ms
4,352 KB
testcase_15 AC 18 ms
4,348 KB
testcase_16 AC 1,754 ms
6,532 KB
testcase_17 AC 1,038 ms
6,600 KB
testcase_18 AC 1,058 ms
6,520 KB
testcase_19 AC 1,070 ms
6,536 KB
testcase_20 AC 1,716 ms
6,448 KB
testcase_21 AC 1,721 ms
6,480 KB
testcase_22 AC 1,737 ms
6,460 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 2,124 ms
6,456 KB
testcase_29 AC 2,103 ms
6,600 KB
testcase_30 AC 2,087 ms
6,456 KB
testcase_31 AC 12 ms
5,680 KB
testcase_32 AC 8 ms
5,672 KB
testcase_33 AC 9 ms
6,456 KB
testcase_34 AC 33 ms
4,992 KB
testcase_35 AC 33 ms
5,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

using ll = long long;

ll a[100001], b[100001], x[100001], y[100001];

int main(){
	constexpr ll mod = 1e9 + 7;
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, q, puni = 0;
	cin >> n >> q;
	a[0] = b[0] = 1;
	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 != 10000000){
				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 = 10000000;
			}
			cout << a[i] << endl;
		}
	}
}
0