結果
| 問題 |
No.510 二次漸化式
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-02-28 21:04:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 562 ms / 3,000 ms |
| コード長 | 1,107 bytes |
| コンパイル時間 | 1,754 ms |
| コンパイル使用メモリ | 169,212 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-02-28 21:04:36 |
| 合計ジャッジ時間 | 11,531 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | scanf(" %c",&op[i]);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<48||ch>57){if(ch=='-')f=-1;ch=getchar();}
while(ch>=48&&ch<=57)x=(x<<1)+(x<<3)+(ch&15),ch=getchar();
return x*f;
}
inline void write(int x)
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+48);
return;
}
inline void openfile()
{
freopen("generator.in","r",stdin);
freopen("generator.out","w",stdout);
}
constexpr int M=1e5+4,mod=1e9+7;
int X[M],Y[M],id[M],v[M];
char op[M];
vector<int>mk;
int main()
{
int n=read(),q=read();
for(int i=1;i<=q;++i)
{
scanf(" %c",&op[i]);
id[i]=read();
if(op[i]=='x'||op[i]=='y')v[i]=read();
mk.emplace_back(id[i]);
mk.emplace_back(id[i]+1);
}
sort(mk.begin(),mk.end());
mk.erase(unique(mk.begin(),mk.end()),mk.end());
for(int i=1;i<=q;++i)
{
if(op[i]=='x')X[id[i]]=v[i];
if(op[i]=='y')Y[id[i]]=v[i];
if(op[i]=='a')
{
int A=1,B=1;
for(auto&t:mk)
{
if(t==id[i])break;
if(X[t])A=(A+1ll*X[t]*B%mod*B)%mod;
if(Y[t])B=(1ll*B*Y[t]%mod+1)%mod;
else B=1;
}
write(A),puts("");
}
}
return 0;
}
vjudge1