結果

問題 No.510 二次漸化式
ユーザー 0x19f0x19f
提出日時 2017-04-28 23:54:10
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,092 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 52,864 KB
実行使用メモリ 6,796 KB
最終ジャッジ日時 2023-10-11 19:55:16
合計ジャッジ時間 45,423 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 56 ms
4,352 KB
testcase_03 AC 56 ms
4,352 KB
testcase_04 AC 55 ms
4,348 KB
testcase_05 AC 56 ms
4,352 KB
testcase_06 AC 351 ms
4,348 KB
testcase_07 AC 342 ms
4,348 KB
testcase_08 AC 343 ms
4,352 KB
testcase_09 AC 345 ms
4,348 KB
testcase_10 AC 23 ms
4,348 KB
testcase_11 AC 22 ms
4,348 KB
testcase_12 AC 23 ms
4,348 KB
testcase_13 AC 23 ms
4,352 KB
testcase_14 AC 23 ms
4,348 KB
testcase_15 AC 22 ms
4,352 KB
testcase_16 AC 1,662 ms
6,512 KB
testcase_17 AC 1,611 ms
6,528 KB
testcase_18 AC 1,630 ms
6,472 KB
testcase_19 AC 1,591 ms
6,460 KB
testcase_20 AC 1,632 ms
6,476 KB
testcase_21 AC 1,633 ms
6,484 KB
testcase_22 AC 1,654 ms
6,528 KB
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define REP(i, a, n) for(int i = (a); i <= (n); i++)
#define MOD 1000000007
using namespace std;

long a[100001], b[100001];
long x[100000], y[100000];

int main(void) {
  int N, Q; cin >> N >> Q;
  REP(i, 0, N) a[i] = b[i] = 1;

  REP(i, 1, Q) {
    char T; cin >> T;
    int j; cin >> j;
    int v;
    // cout << T << ' ' << j;
    if(T == 'x' || T == 'y') {
      cin >> v;
      // cout << ' ' << v;
    }
    // cout << endl;

    if(T == 'x') {
      x[j] = v;
      while(j <= N) {
        a[j + 1] = ((((x[j] * b[j]) % MOD) * b[j]) % MOD) + a[j];
        a[j + 1] %= MOD;
        j++;
      }
    }

    if(T == 'y') {
      y[j] = v;
      while(j < N) {
        b[j + 1] = y[j] * b[j] + 1;
        b[j + 1] %= MOD;
        a[j + 1] = ((((x[j] * b[j]) % MOD) * b[j]) % MOD) + a[j];
        a[j + 1] %= MOD;
        j++;
      }
    }

    if(T == 'a') {
      cout << a[j] << endl;
    }

    // REP(i, 0, N) {
    //   cout << ' ' << a[i] << ' ' << b[i];
    //   if(i < N) cout << ' ' << x[i] << ' ' << y[i];
    //   cout << endl;
    // }
  }

  return 0;
}
0