結果
| 問題 |
No.510 二次漸化式
|
| コンテスト | |
| ユーザー |
Dameningen
|
| 提出日時 | 2017-04-29 16:00:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,304 ms / 3,000 ms |
| コード長 | 1,586 bytes |
| コンパイル時間 | 921 ms |
| コンパイル使用メモリ | 89,512 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 22:52:01 |
| 合計ジャッジ時間 | 16,168 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
ソースコード
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<cstring>
#include<sstream>
#include<cassert>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAX_N = 100000, MAX_Q = 20000, MOD = 1e9+7;
int main()
{
int n, q;
static int x[MAX_N+1], y[MAX_N+1];
cin >> n >> q;
static char query[MAX_Q];
static int i[MAX_Q], v[MAX_Q];
rep(s, q) {
cin >> query[s];
if (query[s] == 'x') {
cin >> i[s] >> v[s];
} else if (query[s] == 'y') {
cin >> i[s] >> v[s];
} else {
cin >> i[s];
}
}
rep(s, q) {
if (query[s] == 'x') {
x[i[s]] = v[s];
} else if (query[s] == 'y') {
y[i[s]] = v[s];
} else {
ll A, B;
A = 1; B = 1;
rep(j, i[s]) {
if (x[j]) (A += x[j]*B%MOD*B) %= MOD;
if (y[j]) B = (y[j]*B+1)%MOD;
else B = 1;
}
cout << A << endl;
}
}
return 0;
}
Dameningen