当前位置:网站首页>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();
}
边栏推荐
- SQL优化的魅力!从 30248s 到 0.001s
- A bit of knowledge - about Apple Certified MFI
- php导出百万数据
- 芯片 设计资料下载
- Detailed explanation of Kalman filter for motion state estimation
- Wechat applet data binding multiple data
- 2022 tea master (intermediate) examination questions and mock examination
- Jenkins remote build project timeout problem
- [guess-ctf2019] fake compressed packets
- 开源生态|打造活力开源社区,共建开源新生态!
猜你喜欢
Hands on deep learning (IV) -- convolutional neural network CNN
Sign up now | oar hacker marathon phase III, waiting for your challenge
buuctf misc USB
自定义类加载器加载网络Class
Leetcode 40: combined sum II
What are the positions of communication equipment manufacturers?
Implementation of replacement function of shell script
buuctf misc USB
即刻报名|飞桨黑客马拉松第三期等你挑战
[2022 ciscn] replay of preliminary web topics
随机推荐
QT learning 28 toolbar in the main window
Explore dry goods! Apifox construction ideas
Wechat applet data binding multiple data
CentOS7下安装PostgreSQL11数据库
Button wizard script learning - about tmall grabbing red envelopes
【p2p】本地抓包
[Stanford Jiwang cs144 project] lab4: tcpconnection
【数字IC验证快速入门】17、SystemVerilog学习之基本语法4(随机化Randomization)
buuctf misc USB
Common validation comments
Qt学习26 布局管理综合实例
Technology cloud report: from robot to Cobot, human-computer integration is creating an era
Main window in QT learning 27 application
PHP exports millions of data
[VHDL parallel statement execution]
Ansible
芯片 設計資料下載
Cnopendata geographical distribution data of religious places in China
paddlepaddle 29 无模型定义代码下动态修改网络结构(relu变prelu,conv2d变conv3d,2d语义分割模型改为3d语义分割模型)
Resource create package method