当前位置:网站首页>B. Value sequence thinking
B. Value sequence thinking
2022-07-07 08:01:00 【Wawa source】
Value sequence — thinking
Numerical peaks and valleys cannot be moved , Optional in other positions
We regard the same number as a whole
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int,int>PII;
#define int long long
const int N =100010,mod=998244353;
int n;
int a[N];
int qmi(int a,int b)
{
int res=1;
while(b)
{
if(b&1)res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res%mod;
}
void solve()
{
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
int res=1;
for(int i=0;i<n;i++)
{
int j=i;
while(j+1<n&&a[j+1]==a[i])j++;
if(i-1>=0&&j+1<n&&((a[i]>a[i-1]&&a[i]<a[j+1])||(a[i]<a[i-1]&&a[i]>a[j+1])))
{
res=res*qmi(2,j-i+1)%mod;
}
else res=res*(qmi(2,j-i+1)-1)%mod;
i=j;
}
cout<<res<<'\n';
}
signed main()
{
int T;
cin>>T;
while(T--)solve();
}
边栏推荐
- Qt学习27 应用程序中的主窗口
- 【webrtc】m98 screen和window采集
- Linux server development, MySQL process control statement
- Mysql高低版本切换需要修改的配置5-8(此处以aicode为例)
- [performance pressure test] how to do a good job of performance pressure test?
- [VHDL parallel statement execution]
- Who has docker to install MySQL locally?
- Installing postgresql11 database under centos7
- Pytest + allure + Jenkins Environment - - achèvement du remplissage de la fosse
- [2022 actf] Web Topic recurrence
猜你喜欢

探索Cassandra的去中心化分布式架构

微信小程序基本组件使用介绍

json 数据展平pd.json_normalize
![[2022 ciscn] replay of preliminary web topics](/img/1c/4297379fccde28f76ebe04d085c5a4.png)
[2022 ciscn] replay of preliminary web topics

Idea add class annotation template and method template

Iterable、Collection、List 的常见方法签名以及含义

Who has docker to install MySQL locally?

Cnopendata list data of Chinese colleges and Universities

开源生态|打造活力开源社区,共建开源新生态!

Hands on deep learning (IV) -- convolutional neural network CNN
随机推荐
Operation suggestions for today's spot Silver
Open source ecosystem | create a vibrant open source community and jointly build a new open source ecosystem!
[SUCTF 2019]Game
Pytest+allure+jenkins installation problem: pytest: error: unrecognized arguments: --alluredir
Hands on deep learning (IV) -- convolutional neural network CNN
Pytorch parameter initialization
nacos
有 Docker 谁还在自己本地安装 Mysql ?
【VHDL 并行语句执行】
[webrtc] M98 screen and window acquisition
Linux server development, MySQL cache strategy
Leanote private cloud note building
[SUCTF 2019]Game
Iterable、Collection、List 的常见方法签名以及含义
Few shot Learning & meta learning: small sample learning principle and Siamese network structure (I)
Binary tree and heap building in C language
Ansible
Linux server development, redis protocol and asynchronous mode
dash plotly
Cnopendata geographical distribution data of religious places in China