当前位置:网站首页>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();
}
边栏推荐
猜你喜欢

Explore dry goods! Apifox construction ideas

Figure out the working principle of gpt3

A bit of knowledge - about Apple Certified MFI

2022 National latest fire-fighting facility operator (primary fire-fighting facility operator) simulation questions and answers

MySQL multi column index (composite index) features and usage scenarios

Ansible

2022茶艺师(初级)考试题模拟考试题库及在线模拟考试

Linux server development, MySQL transaction principle analysis

You Li takes you to talk about C language 6 (common keywords)

【p2p】本地抓包
随机推荐
Explore dry goods! Apifox construction ideas
Live broadcast platform source code, foldable menu bar
leanote私有云笔记搭建
The principle and implementation of buffer playback of large video files
[CV] Wu Enda machine learning course notes | Chapter 8
Introduction to basic components of wechat applet
Qt学习28 主窗口中的工具栏
Binary tree and heap building in C language
Numbers that appear only once
Rust Versus Go(哪种是我的首选语言?)
[advanced digital IC Verification] command query method and common command interpretation of VCs tool
QT learning 28 toolbar in the main window
QT learning 26 integrated example of layout management
The charm of SQL optimization! From 30248s to 0.001s
[unity] several ideas about circular motion of objects
[2022 actf] Web Topic recurrence
CentOS7下安装PostgreSQL11数据库
These five fishing artifacts are too hot! Programmer: I know, delete it quickly!
Kbu1510-asemi power supply special 15A rectifier bridge kbu1510
芯片 設計資料下載