結果

問題 No.510 二次漸化式
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2017-04-29 00:19:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,498 ms / 3,000 ms
コード長 603 bytes
コンパイル時間 1,750 ms
コンパイル使用メモリ 163,748 KB
実行使用メモリ 5,168 KB
最終ジャッジ日時 2023-10-11 20:06:35
合計ジャッジ時間 28,495 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 31 ms
4,348 KB
testcase_03 AC 32 ms
4,352 KB
testcase_04 AC 22 ms
4,352 KB
testcase_05 AC 22 ms
4,352 KB
testcase_06 AC 159 ms
4,352 KB
testcase_07 AC 158 ms
4,352 KB
testcase_08 AC 252 ms
4,352 KB
testcase_09 AC 253 ms
4,352 KB
testcase_10 AC 6 ms
4,352 KB
testcase_11 AC 7 ms
4,348 KB
testcase_12 AC 6 ms
4,348 KB
testcase_13 AC 6 ms
4,352 KB
testcase_14 AC 6 ms
4,352 KB
testcase_15 AC 6 ms
4,348 KB
testcase_16 AC 1,262 ms
5,148 KB
testcase_17 AC 747 ms
5,092 KB
testcase_18 AC 758 ms
5,020 KB
testcase_19 AC 771 ms
4,960 KB
testcase_20 AC 1,237 ms
4,964 KB
testcase_21 AC 1,239 ms
5,092 KB
testcase_22 AC 1,250 ms
5,024 KB
testcase_23 AC 2,498 ms
4,956 KB
testcase_24 AC 2,492 ms
5,020 KB
testcase_25 AC 2,477 ms
4,964 KB
testcase_26 AC 2,476 ms
5,016 KB
testcase_27 AC 2,453 ms
5,092 KB
testcase_28 AC 1,524 ms
5,020 KB
testcase_29 AC 1,513 ms
5,048 KB
testcase_30 AC 1,505 ms
5,088 KB
testcase_31 AC 8 ms
4,916 KB
testcase_32 AC 8 ms
4,640 KB
testcase_33 AC 9 ms
5,168 KB
testcase_34 AC 8 ms
4,372 KB
testcase_35 AC 7 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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;
	int f=0;
	scanf("%d%d\n",&n,&q);
	
	for(int k=0;k<q;k++){
		scanf("%c",&c);
		if(c=='a'){
			if(f!=1000000){
				for(int i=f;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;
				}
				f=1000000;		
			}
			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;
			f=min(f,p);
		}
	}

}
0