結果

問題 No.510 二次漸化式
ユーザー e869120e869120
提出日時 2018-06-10 12:42:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 936 bytes
コンパイル時間 710 ms
コンパイル使用メモリ 75,948 KB
実行使用メモリ 4,760 KB
最終ジャッジ日時 2023-09-13 02:37:29
合計ジャッジ時間 19,159 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 195 ms
4,376 KB
testcase_03 AC 191 ms
4,376 KB
testcase_04 AC 192 ms
4,380 KB
testcase_05 AC 195 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 24 ms
4,376 KB
testcase_11 AC 24 ms
4,376 KB
testcase_12 AC 23 ms
4,380 KB
testcase_13 AC 24 ms
4,376 KB
testcase_14 AC 24 ms
4,380 KB
testcase_15 AC 24 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n, q, a[100009], b[100009], x[100009], y[100009], mod = 1000000007;
char c[100009]; vector<int>vec;

int main() {
	cin >> n >> q;
	for (int i = 1; i <= q; i++) {
		cin >> c[i];
		if (c[i] == 'x' || c[i] == 'y') {
			cin >> a[i] >> b[i]; vec.push_back(a[i]);
		}
		else cin >> a[i];
	}
	sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end());

	for (int i = 1; i <= q; i++) {
		if (c[i] == 'x') x[a[i]] = b[i];
		if (c[i] == 'y') y[a[i]] = b[i];
		if (c[i] == 'a') {
			long long s = a[i], ret = 1, K = 0;
			for (int j = 0; j < vec.size(); j++) {
				if (vec[j] >= a[i]) break;
				s--;
				if (j == 0 || vec[j] - vec[j - 1] >= 2) K = 1;
				if (x[vec[j]] >= 1) ret += 1LL * (1LL * K * K % mod) * x[vec[j]] % mod;
				K = (1LL * K * y[vec[j]] + 1LL) % mod;
			}
			cout << (ret + s + mod) % mod << endl;
		}
	}
	return 0;
}
0