当前位置:网站首页>Substring Inversion (Easy Version)
Substring Inversion (Easy Version)
2022-04-23 06:21:00 【Bzdhxs_ nt】
Ideas

Record
If in an orderly map in , key yes int, perhaps string, They naturally compare in size , In itself is orderly . No extra operation .
Sort in ascending order of key values
map<string, int, greater<string> > mp;
Code
nt n;
string s;
int num[550];
void solve(){
cin >> n;
cin >> s;
int res = 0;
mem(num,0);
map<string,vector<int>,greater<string>> mp;
forr(i,0,n-1)forr(j,i,n-1){
string t = s.substr(i,j-i+1);
mp[t].push_back(i);
}
for(auto [str,be]:mp){
for(auto v:be){
forr(i,v+1,n-1) res = (res +num[i])%mod;
}
for(auto v:be) num[v]++;
}
cout << res << endl;
}
signed main()
{
int t;cin>>t;
while(t--) solve();
return 0;
}
版权声明
本文为[Bzdhxs_ nt]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210617219361.html
边栏推荐
- Understanding and use of tp50, tp90 and tp99
- PyQt5学习(一):布局管理+信号和槽关联+菜单栏与工具栏+打包资源包
- Linear algebra Chapter 2 - matrices and their operations
- Customized communication between threads (reentrantlock)
- Create enterprise mailbox account command
- Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi
- 自动控制(韩敏版)
- Complete example demonstration of creating table to page - joint table query
- MySQL occasional Caton
- Latex quick start
猜你喜欢

A general U-shaped transformer for image restoration

线性代数第三章-矩阵的初等变换与线性方程组

PyTorch笔记——观察DataLoader&用torch构建LeNet处理CIFAR-10完整代码

SQL injection

Illustrate the significance of hashcode

自动控制原理知识点整合归纳(韩敏版)

PyTorch笔记——实现线性回归完整代码&手动或自动计算梯度代码对比

图像恢复论文简记——Uformer: A General U-Shaped Transformer for Image Restoration

Programming record - picture rotation function SciPy ndimage. Simple use and effect observation of rotate()

线代第四章-向量组的线性相关
随机推荐
自动控制原理知识点整合归纳(韩敏版)
Create enterprise mailbox account command
Understanding and use of tp50, tp90 and tp99
RPC must know and know
ValueError: loaded state dict contains a parameter group that doesn‘t match the size of optimizer‘s
1. Calculate a + B
Comparative study paper - [Moco, cvpr2020] momentum contract for unsupervised visual representation learning
6.Reversal
線性代數第一章-行列式
IO multiplexing of 09 redis
图像恢复论文——[RED-Net, NIPS16]Image Restoration Using Very Deep Convolutional Encoder-Decoder Networks wi
治療TensorFlow後遺症——簡單例子記錄torch.utils.data.dataset.Dataset重寫時的圖片維度問題
深度学习基础——简单了解meta learning(来自李宏毅课程笔记)
Fundamentals of SQL: first knowledge of database and SQL - installation and basic introduction - Alibaba cloud Tianchi
JDBC tool class encapsulation
Code neat way to learn
Reading of denoising papers - [cvpr2022] blind2blind: self supervised image denoising with visible blind spots
What is the difference between the basic feasible solution and the basic feasible solution in linear programming?
Unsupervised denoising - [tmi2022] ISCL: dependent self cooperative learning for unpaired image denoising
Framework analysis 2 Source code - login authentication