結果

問題 No.510 二次漸化式
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2017-04-29 00:13:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 637 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 163,428 KB
実行使用メモリ 8,816 KB
最終ジャッジ日時 2023-10-11 20:44:29
合計ジャッジ時間 36,976 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 32 ms
4,352 KB
testcase_03 AC 32 ms
4,348 KB
testcase_04 AC 31 ms
4,352 KB
testcase_05 AC 31 ms
4,348 KB
testcase_06 AC 256 ms
4,352 KB
testcase_07 AC 251 ms
4,352 KB
testcase_08 AC 251 ms
4,352 KB
testcase_09 AC 253 ms
4,348 KB
testcase_10 AC 7 ms
4,352 KB
testcase_11 AC 6 ms
4,352 KB
testcase_12 AC 6 ms
4,352 KB
testcase_13 AC 6 ms
4,352 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 6 ms
4,348 KB
testcase_16 AC 1,269 ms
5,072 KB
testcase_17 AC 1,224 ms
5,080 KB
testcase_18 AC 1,245 ms
5,120 KB
testcase_19 AC 1,214 ms
5,088 KB
testcase_20 AC 1,238 ms
5,192 KB
testcase_21 AC 1,240 ms
5,016 KB
testcase_22 AC 1,254 ms
5,080 KB
testcase_23 AC 2,494 ms
5,068 KB
testcase_24 AC 2,503 ms
5,080 KB
testcase_25 AC 2,477 ms
5,012 KB
testcase_26 AC 2,473 ms
5,140 KB
testcase_27 AC 2,450 ms
5,080 KB
testcase_28 AC 2,480 ms
5,080 KB
testcase_29 AC 2,455 ms
5,308 KB
testcase_30 AC 2,438 ms
5,316 KB
testcase_31 TLE -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll MOD=1000000007;
unsigned int a[100001],b[100001],x[100001],y[100001];
int main(){
	a[0]=b[0]=1;
	int n,q,p,v;
	char c;
	scanf("%d%d\n",&n,&q);
	for(int i=0;i<n;i++){
		b[i+1]=(1ULL*y[i]*b[i]+1)%MOD;
		a[i+1]=(1ULL*(x[i]*b[i])%MOD*b[i]+a[i])%MOD;
	}
	for(int k=0;k<q;k++){
		scanf("%c",&c);
		if(c=='a'){
			scanf("%d\n",&p);
			printf("%d\n",a[p]);
		}
		else
		{
			scanf("%d %d\n",&p,&v);
			if(c=='x')x[p]=v;
			else y[p]=v;
			for(int i=p;i<n;i++){
				b[i+1]=(1ULL*y[i]*b[i]+1)%MOD;
				a[i+1]=((1ULL*x[i]*b[i])%MOD*b[i]+a[i])%MOD;
			}
		}
	}

}
0