結果

問題 No.510 二次漸化式
ユーザー 👑 kmjpkmjp
提出日時 2017-04-28 22:48:04
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,047 bytes
コンパイル時間 1,188 ms
コンパイル使用メモリ 146,096 KB
実行使用メモリ 5,172 KB
最終ジャッジ日時 2023-10-11 19:33:19
合計ジャッジ時間 25,529 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 171 ms
4,352 KB
testcase_03 AC 170 ms
4,348 KB
testcase_04 AC 169 ms
4,352 KB
testcase_05 AC 173 ms
4,352 KB
testcase_06 AC 576 ms
4,348 KB
testcase_07 AC 560 ms
4,352 KB
testcase_08 AC 566 ms
4,352 KB
testcase_09 AC 565 ms
4,352 KB
testcase_10 AC 21 ms
4,348 KB
testcase_11 AC 21 ms
4,348 KB
testcase_12 AC 21 ms
4,348 KB
testcase_13 AC 21 ms
4,352 KB
testcase_14 AC 21 ms
4,352 KB
testcase_15 AC 21 ms
4,348 KB
testcase_16 AC 555 ms
4,960 KB
testcase_17 AC 540 ms
4,940 KB
testcase_18 AC 546 ms
5,172 KB
testcase_19 AC 539 ms
4,876 KB
testcase_20 AC 543 ms
4,936 KB
testcase_21 AC 543 ms
5,140 KB
testcase_22 AC 542 ms
4,964 KB
testcase_23 AC 1,398 ms
4,936 KB
testcase_24 AC 1,397 ms
4,948 KB
testcase_25 AC 1,375 ms
4,944 KB
testcase_26 AC 1,371 ms
4,884 KB
testcase_27 AC 1,359 ms
4,876 KB
testcase_28 AC 1,369 ms
4,944 KB
testcase_29 AC 1,376 ms
5,016 KB
testcase_30 AC 1,376 ms
5,140 KB
testcase_31 AC 8 ms
4,484 KB
testcase_32 AC 8 ms
4,388 KB
testcase_33 AC 8 ms
5,072 KB
testcase_34 AC 1,529 ms
4,352 KB
testcase_35 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
ll X[101010];
ll Y[101010];
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	while(Q--) {
		cin>>s>>x;
		if(s=="x") cin>>X[x];
		else if(s=="y") cin>>Y[x];
		else if(s=="a") {
			ll A=1,B=1;
			FOR(i,x) {
				if(X[i]) (A += X[i]*B%mo*B)%=mo;
				if(Y[i]) {
					B = (B*Y[i]+1)%mo;
				}
				else {
					B=1;
				}
			}
			cout<<A<<endl;
		}
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0