結果

問題 No.510 二次漸化式
ユーザー はむこはむこ
提出日時 2016-09-07 21:52:26
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,465 bytes
コンパイル時間 1,093 ms
コンパイル使用メモリ 160,488 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-27 17:16:55
合計ジャッジ時間 23,016 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,624 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 90 ms
5,376 KB
testcase_03 AC 92 ms
5,376 KB
testcase_04 AC 57 ms
5,376 KB
testcase_05 AC 57 ms
5,376 KB
testcase_06 AC 379 ms
5,376 KB
testcase_07 AC 373 ms
5,376 KB
testcase_08 AC 722 ms
5,376 KB
testcase_09 AC 725 ms
5,376 KB
testcase_10 AC 23 ms
5,376 KB
testcase_11 AC 21 ms
5,376 KB
testcase_12 AC 21 ms
5,376 KB
testcase_13 AC 21 ms
5,376 KB
testcase_14 AC 21 ms
5,376 KB
testcase_15 AC 20 ms
5,376 KB
testcase_16 TLE -
testcase_17 AC 1,802 ms
6,272 KB
testcase_18 AC 1,829 ms
6,528 KB
testcase_19 AC 1,928 ms
6,528 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
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;

#define rep(i,n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define Min(x) *min_element(all(x))
#define Max(x) *max_element(all(x))
template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if (!v.empty()) { o << '['; copy(v.begin(), v.end(), ostream_iterator<T>(o, ", ")); o << "\b\b]"; } return o; }
using ll = long long; using ld = long double; using vll = vector<ll>; using vi = vector<int>;
typedef pair<ld, ld> P;

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;
#define MAX_N 100005

int main(void) {
    ll n; cin >> n;
    ll q; cin >> q;
    vll x(n), y(n);
    vll a(n+1, 0), b(n+1, 0);
    a[0] = b[0] = 1;

    bool updated = 1;
    rep(i, q) {
        char query; cin >> query;
        if (query == 'a') {
            if (updated) {
                rep(j, n) {
                    a[j+1] = (((x[j] * b[j]) % mo) * b[j] + a[j]) % mo;
                    b[j+1] = (y[j] * b[j] + 1) % mo;
                }
                updated = 0;
            }

            ll i; cin >> i;
            cout << a[i] << endl;
        } else {
            ll i, v; cin >> i >> v;
            (query == 'x' ? x : y)[i] = v;
            updated = 1;
        }
    }

    return 0;
}
0