当前位置:网站首页>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();
}
边栏推荐
- [Stanford Jiwang cs144 project] lab4: tcpconnection
- 【经验分享】如何为visio扩展云服务图标
- 2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
- Cnopendata list data of Chinese colleges and Universities
- Iterable、Collection、List 的常见方法签名以及含义
- dash plotly
- [unity] several ideas about circular motion of objects
- C language queue
- [Matlab] Simulink 自定义函数中的矩阵乘法工作不正常时可以使用模块库中的矩阵乘法模块代替
- C语言航班订票系统
猜你喜欢
buuctf misc USB
Custom class loader loads network class
Mysql高低版本切换需要修改的配置5-8(此处以aicode为例)
[Stanford Jiwang cs144 project] lab3: tcpsender
PHP exports millions of data
Wechat applet data binding multiple data
The configuration that needs to be modified when switching between high and low versions of MySQL 5-8 (take aicode as an example here)
Most elements
Why should we understand the trend of spot gold?
2022 welder (elementary) judgment questions and online simulation examination
随机推荐
Common validation comments
Detailed explanation of Kalman filter for motion state estimation
Cnopendata American Golden Globe Award winning data
buuctf misc USB
Linux server development, MySQL stored procedures, functions and triggers
Linux server development, MySQL cache strategy
Mysql高低版本切换需要修改的配置5-8(此处以aicode为例)
[UTCTF2020]file header
C语言通信行程卡后台系统
Leetcode 90: subset II
C语言队列
【经验分享】如何为visio扩展云服务图标
Introduction to basic components of wechat applet
Open source ecosystem | create a vibrant open source community and jointly build a new open source ecosystem!
自定义类加载器加载网络Class
paddlepaddle 29 无模型定义代码下动态修改网络结构(relu变prelu,conv2d变conv3d,2d语义分割模型改为3d语义分割模型)
Pytest+allure+jenkins environment -- completion of pit filling
Regular e-commerce problems part1
pytest+allure+jenkins環境--填坑完畢
Ansible