結果

問題 No.510 二次漸化式
ユーザー 0x19f0x19f
提出日時 2017-04-28 23:54:10
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,092 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 55,668 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-09-13 18:45:33
合計ジャッジ時間 46,102 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
12,320 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 58 ms
6,944 KB
testcase_03 AC 59 ms
6,940 KB
testcase_04 AC 58 ms
6,944 KB
testcase_05 AC 58 ms
6,944 KB
testcase_06 AC 360 ms
6,940 KB
testcase_07 AC 353 ms
6,940 KB
testcase_08 AC 354 ms
6,944 KB
testcase_09 AC 356 ms
6,944 KB
testcase_10 AC 24 ms
6,940 KB
testcase_11 AC 24 ms
6,940 KB
testcase_12 AC 25 ms
6,944 KB
testcase_13 AC 24 ms
6,940 KB
testcase_14 AC 24 ms
6,944 KB
testcase_15 AC 24 ms
6,944 KB
testcase_16 AC 1,710 ms
6,940 KB
testcase_17 AC 1,651 ms
6,940 KB
testcase_18 AC 1,671 ms
6,940 KB
testcase_19 AC 1,640 ms
6,944 KB
testcase_20 AC 1,677 ms
6,940 KB
testcase_21 AC 1,677 ms
6,944 KB
testcase_22 AC 1,697 ms
6,944 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