結果
| 問題 |
No.510 二次漸化式
|
| コンテスト | |
| ユーザー |
ldsyb
|
| 提出日時 | 2017-04-29 00:41:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 721 bytes |
| コンパイル時間 | 653 ms |
| コンパイル使用メモリ | 65,240 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 18:55:40 |
| 合計ジャッジ時間 | 36,968 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 TLE * 5 |
ソースコード
#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;
}
}
}
ldsyb