当前位置:网站首页>Longest isometric subsequence
Longest isometric subsequence
2022-07-02 08:07:00 【programmercherry】
#include <iostream>
using namespace std;
#include <vector>
#include <unordered_map>
/* Longest isometric subsequence */
int longestArithSeqLength(vector<int>& A) {
if (A.size() == 2) {
return 2;
}
if (A.size() == 3) {
return A[2] / A[1] == A[1] / A[0];
}
int n = A.size();
vector<vector<int>> dp(n, vector<int>(n, 2));
unordered_map<int, vector<int>> cntHashMap;
for (int i = 0; i < n; ++i) {
cntHashMap[A[i]].emplace_back(i);
}
int res = 2;
for (int i = 1; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
if (cntHashMap.count(A[i] * A[i] / A[j])) {
for (const auto m : cntHashMap[A[i] * A[i] / A[j]]) {
if (m < i) {
dp[i][j] = max(dp[i][j], dp[m][i] + 1);
}
else {
break;
}
}
res = max(res, dp[i][j]);
}
}
}
return res;
}
int main() {
/*vector<int> A = { 1, 3, 2, 5, 4 };*/
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
cout << longestArithSeqLength(A) << endl;
return 0;
}
边栏推荐
- 【Cascade FPD】《Deep Convolutional Network Cascade for Facial Point Detection》
- 使用C#语言来进行json串的接收
- jetson nano安装tensorflow踩坑记录(scipy1.4.1)
- 业务架构图
- 将恶意软件嵌入到神经网络中
- 【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
- 【双目视觉】双目立体匹配
- 【学习笔记】反向误差传播之数值微分
- Real world anti sample attack against semantic segmentation
- 【TCDCN】《Facial landmark detection by deep multi-task learning》
猜你喜欢
![[binocular vision] binocular stereo matching](/img/93/2e916038f0e7d0c7b3bf64f8dc1b4e.png)
[binocular vision] binocular stereo matching

针对语义分割的真实世界的对抗样本攻击

On the back door of deep learning model

【Batch】learning notes

【Cutout】《Improved Regularization of Convolutional Neural Networks with Cutout》
![[binocular vision] binocular correction](/img/fe/27fda48c36ca529eec21c631737526.png)
[binocular vision] binocular correction

CVPR19-Deep Stacked Hierarchical Multi-patch Network for Image Deblurring论文复现

Using super ball embedding to enhance confrontation training

Sequence problem for tqdm and print

【双目视觉】双目矫正
随机推荐
What if the laptop can't search the wireless network signal
Feature Engineering: summary of common feature transformation methods
【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》
Global and Chinese market of tillage finishing machines 2022-2028: Research Report on technology, participants, trends, market size and share
Eklavya -- infer the parameters of functions in binary files using neural network
高中数学必修一
SQL操作数据库语法
浅谈深度学习中的对抗样本及其生成方法
The internal network of the server can be accessed, but the external network cannot be accessed
SQLyog远程连接centos7系统下的MySQL数据库
【雙目視覺】雙目矯正
AR系统总结收获
静态库和动态库
用MLP代替掉Self-Attention
Using super ball embedding to enhance confrontation training
Get the width and height of the screen in real time (adaptive)
E-R draw clear content
Data reverse attack under federated learning -- gradinversion
How to wrap qstring strings
Nacos service registration in the interface