当前位置:网站首页>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();
}
边栏推荐
- What is the interval in gatk4??
- 芯片 設計資料下載
- [UVM practice] Chapter 1: configuring the UVM environment (taking VCs as an example), run through the examples in the book
- pytest+allure+jenkins環境--填坑完畢
- 【斯坦福计网CS144项目】Lab4: TCPConnection
- [UTCTF2020]file header
- Kbu1510-asemi power supply special 15A rectifier bridge kbu1510
- MySQL multi column index (composite index) features and usage scenarios
- 【数字IC验证快速入门】15、SystemVerilog学习之基本语法2(操作符、类型转换、循环、Task/Function...内含实践练习)
- Force buckle 144 Preorder traversal of binary tree
猜你喜欢
misc ez_ usb
@component(““)
Resource create package method
QT learning 28 toolbar in the main window
Common method signatures and meanings of Iterable, collection and list
Jenkins remote build project timeout problem
2022 recurrent training question bank and answers of refrigeration and air conditioning equipment operation
IO stream file
A bit of knowledge - about Apple Certified MFI
Operation suggestions for today's spot Silver
随机推荐
Few shot Learning & meta learning: small sample learning principle and Siamese network structure (I)
Pytest + allure + Jenkins Environment - - achèvement du remplissage de la fosse
C语言通信行程卡后台系统
A bit of knowledge - about Apple Certified MFI
The principle and implementation of buffer playback of large video files
Qt学习28 主窗口中的工具栏
The configuration that needs to be modified when switching between high and low versions of MySQL 5-8 (take aicode as an example here)
[guess-ctf2019] fake compressed packets
Quickly use Jacobo code coverage statistics
[UVM basics] summary of important knowledge points of "UVM practice" (continuous update...)
Main window in QT learning 27 application
Linux server development, redis source code storage principle and data model
Introduction to basic components of wechat applet
CentOS7下安装PostgreSQL11数据库
Padavan manually installs PHP
Chip information website Yite Chuangxin
Linux server development, detailed explanation of redis related commands and their principles
Pytorch parameter initialization
Qt学习27 应用程序中的主窗口
C language queue