当前位置:网站首页>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();
}
边栏推荐
- C语言航班订票系统
- nacos
- Few-Shot Learning && Meta Learning:小样本学习原理和Siamese网络结构(一)
- 2022焊工(初级)判断题及在线模拟考试
- A bit of knowledge - about Apple Certified MFI
- 【webrtc】m98 screen和window采集
- pytest+allure+jenkins環境--填坑完畢
- C language communication travel card background system
- Linux server development, MySQL index principle and optimization
- Hands on deep learning (IV) -- convolutional neural network CNN
猜你喜欢
Linux server development, redis source code storage principle and data model
Most elements
Qt学习27 应用程序中的主窗口
Use and analysis of dot function in numpy
【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)
[webrtc] m98 Screen and Window Collection
Who has docker to install MySQL locally?
Technology cloud report: from robot to Cobot, human-computer integration is creating an era
【斯坦福计网CS144项目】Lab4: TCPConnection
Explore Cassandra's decentralized distributed architecture
随机推荐
【webrtc】m98 screen和window采集
nacos
2022制冷与空调设备运行操作复训题库及答案
[OBS] win capture requires winrt
Linux server development, MySQL index principle and optimization
【斯坦福计网CS144项目】Lab4: TCPConnection
Quickly use Jacobo code coverage statistics
padavan手动安装php
开源生态|打造活力开源社区,共建开源新生态!
[Stanford Jiwang cs144 project] lab3: tcpsender
buuctf misc USB
【webrtc】m98 screen和window采集
【p2p】本地抓包
[CV] Wu Enda machine learning course notes | Chapter 8
C language communication travel card background system
C语言二叉树与建堆
探索Cassandra的去中心化分布式架构
QT learning 26 integrated example of layout management
Linux server development, redis source code storage principle and data model
Numbers that appear only once