結果
| 問題 |
No.510 二次漸化式
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-02-25 20:21:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 296 ms / 3,000 ms |
| コード長 | 960 bytes |
| コンパイル時間 | 2,326 ms |
| コンパイル使用メモリ | 196,720 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-02-25 20:21:59 |
| 合計ジャッジ時間 | 7,530 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘void AC::solve()’:
main.cpp:24:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | if(c=='x')scanf("%lld",&X[k]);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:25:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | else scanf("%lld",&Y[k]);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
template<typename T>istream&operator>>(istream&I,vector<T>&v){for(auto&i:v)I>>i;return I;}
template<typename T>ostream&operator<<(ostream&O,vector<T>&v){for(auto&i:v)O<<i<<' ';return O;}
namespace AC{
const int mod=1000000007;
int N,Q;
int X[100010],Y[100010];
int B[100010];
bool ex[100010];
void solve(){
cin>>N>>Q;
for(int i=0;i<N;i++)B[i]=1;
vector<int>lis;
for(int i=0;i<Q;i++){
char c;
int k;
cin>>c>>k;
if(c=='x'||c=='y'){
k++;
if(c=='x')scanf("%lld",&X[k]);
else scanf("%lld",&Y[k]);
if(!ex[k])lis.insert(lower_bound(all(lis),k),k);
ex[k]=true;
continue;
}
int a=1;
for(int j=0;j<lis.size()&&lis[j]<=k;j++){
int l=lis[j];
B[l]=(B[l-1]*Y[l]+1)%mod;
a=(a+X[l]*B[l-1]%mod*B[l-1])%mod;
}
cout<<a<<endl;
}
}
}
signed main(){
int t=1;
//cin>>t;
while(t--)AC::solve();
}
vjudge1