結果

問題 No.510 二次漸化式
ユーザー ldsybldsyb
提出日時 2017-04-29 00:48:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 695 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 69,384 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 19:42:30
合計ジャッジ時間 37,329 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#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 == '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;
		}else{
			ll i, v;
			cin >> i >> v;
			(c == 'x' ? x : y)[i] = v;
			puni = min(puni, i);
		}
	}
}
0