当前位置:网站首页>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 language flight booking system
- [unity] several ideas about circular motion of objects
- Pytest + allure + Jenkins Environment - - achèvement du remplissage de la fosse
- 2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
- Linux server development, redis source code storage principle and data model
- Chip information website Yite Chuangxin
- 2022年茶艺师(中级)考试试题及模拟考试
- Info | webrtc M97 update
- QT learning 28 toolbar in the main window
- 微信小程序基本组件使用介绍
猜你喜欢
Explore dry goods! Apifox construction ideas
Linux server development, MySQL index principle and optimization
Custom class loader loads network class
开源生态|打造活力开源社区,共建开源新生态!
Detailed explanation of Kalman filter for motion state estimation
Idea add class annotation template and method template
Numbers that appear only once
A bit of knowledge - about Apple Certified MFI
Hands on deep learning (IV) -- convolutional neural network CNN
Common method signatures and meanings of Iterable, collection and list
随机推荐
Explore Cassandra's decentralized distributed architecture
misc ez_ usb
C language flight booking system
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
2022年茶艺师(中级)考试试题及模拟考试
Cnopendata American Golden Globe Award winning data
SQL优化的魅力!从 30248s 到 0.001s
pytest+allure+jenkins安装问题:pytest: error: unrecognized arguments: --alluredir
C language queue
Implementation of replacement function of shell script
[UVM basics] summary of important knowledge points of "UVM practice" (continuous update...)
What are the positions of communication equipment manufacturers?
Rust Versus Go(哪种是我的首选语言?)
Zhilian + AV, AITO asked M7 to do more than ideal one
Ansible
[GUET-CTF2019]虚假的压缩包
[matlab] when matrix multiplication in Simulink user-defined function does not work properly, matrix multiplication module in module library can be used instead
2022 recurrent training question bank and answers of refrigeration and air conditioning equipment operation
C language communication travel card background system
Pytest+allure+jenkins environment -- completion of pit filling