当前位置:网站首页>C. The third problem
C. The third problem
2022-07-06 04:15:00 【Harris-H】
C. The Third Problem( Looking for a regular )
You can find 0 , 1 0,1 0,1 The position of the cannot be changed .
And then there's watching 2 2 2.
Might as well set p 0 < p 1 p_0<p_1 p0<p1
if p 2 < p 0 p_2<p_0 p2<p0 or p 2 > p 1 p_2>p_1 p2>p1 , be p 2 p_2 p2 Position cannot be changed .
because [ p 2 , p 1 ] [p_2,p_1] [p2,p1] or [ p 0 , p 2 ] [p_0,p_2] [p0,p2] Will receive p 2 p_2 p2 Location affects .
So only p 0 < p 2 < p 1 p_0<p_2<p_1 p0<p2<p1 Satisfy .
p 2 p_2 p2 The optional cases are : p 1 − p 0 + 1 − 2 p_1-p_0+1-2 p1−p0+1−2
about p 3 p_3 p3 If it is not within the range of these three numbers, it is also fixed .
Otherwise, it can be any one in the range r − l + 1 − 3 r-l+1-3 r−l+1−3
Therefore, direct simulation is sufficient .
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll NMAX=1e5+5,MOD=1e9+7;
ll v[NMAX],pos[NMAX];
void tc(){
ll n,l,r,ans=1;
cin>>n;
for(ll i=0;i<n;i++){
cin>>v[i];
pos[v[i]]=i;
}
l = r = pos[0];
for(ll i=1;i<n;i++){
if(pos[i]<l) l = pos[i];
else if(pos[i]>r) r = pos[i];
else ans=ans*(r-l+1-i)%MOD;
}
cout<<ans<<'\n';
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
ll t;
cin>>t;
while(t--)
tc();
return 0;
}
边栏推荐
- TCP/IP协议里面的网关地址和ip地址有什么区别?
- Web components series (VII) -- life cycle of custom components
- [adjustable delay network] development of FPGA based adjustable delay network system Verilog
- Lambda expression learning
- Mysql数据库慢sql抓取与分析
- Several important classes in unity
- 综合能力测评系统
- R note prophet
- How to execute an SQL statement in MySQL
- 20、 EEPROM memory (AT24C02) (similar to AD)
猜你喜欢
电脑钉钉怎么调整声音
Yyds dry goods inventory hcie security Day11: preliminary study of firewall dual machine hot standby and vgmp concepts
【可调延时网络】基于FPGA的可调延时网络系统verilog开发
Lombok principle and the pit of ⽤ @data and @builder at the same time
综合能力测评系统
Tips for using dm8huge table
Data processing methods - smote series and adasyn
Solution of storage bar code management system in food industry
Lora gateway Ethernet transmission
Thread sleep, thread sleep application scenarios
随机推荐
Global and Chinese markets for patent hole oval devices 2022-2028: Research Report on technology, participants, trends, market size and share
解决“C2001:常量中有换行符“编译问题
【按鍵消抖】基於FPGA的按鍵消抖模塊開發
1291_ Add timestamp function in xshell log
Mixed development of QML and QWidget (preliminary exploration)
Path of class file generated by idea compiling JSP page
[disassembly] a visual air fryer. By the way, analyze the internal circuit
Yyds dry goods inventory web components series (VII) -- life cycle of custom components
Lombok原理和同时使⽤@Data和@Builder 的坑
Basic use of MySQL (it is recommended to read and recite the content)
Global and Chinese markets for fire resistant conveyor belts 2022-2028: Research Report on technology, participants, trends, market size and share
asp. Core is compatible with both JWT authentication and cookies authentication
使用JS完成一个LRU缓存
During pycharm debugging, the view is read only and pause the process to use the command line appear on the console input
Determine which week of the month the day is
The Research Report "2022 RPA supplier strength matrix analysis of China's banking industry" was officially launched
Stable Huawei micro certification, stable Huawei cloud database service practice
Yyds dry goods inventory hcie security Day11: preliminary study of firewall dual machine hot standby and vgmp concepts
MLAPI系列 - 04 - 网络变量和网络序列化【网络同步】
Fedora/REHL 安装 semanage