日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【Codeforces - 977F】Consecutive Subsequence(STLmap,输出路径,dp)

發布時間:2023/12/10 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Codeforces - 977F】Consecutive Subsequence(STLmap,输出路径,dp) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題干:

You are given an integer array of length?nn.

You have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to?[x,x+1,…,x+k?1][x,x+1,…,x+k?1]?for some value?xx?and length?kk.

Subsequence of an array can be obtained by erasing some (possibly zero) elements from the array. You can erase any elements, not necessarily going successively. The remaining elements preserve their order. For example, for the array?[5,3,1,2,4][5,3,1,2,4]?the following arrays are subsequences:?[3][3],?[5,3,1,2,4][5,3,1,2,4],?[5,1,4][5,1,4], but the array?[1,3][1,3]?is not.

Input

The first line of the input containing integer number?nn?(1≤n≤2?1051≤n≤2?105) — the length of the array. The second line of the input containing?nn?integer numbers?a1,a2,…,ana1,a2,…,an?(1≤ai≤1091≤ai≤109) — the array itself.

Output

On the first line print?kk?— the maximum length of the subsequence of the given array that forms an increasing sequence of consecutive integers.

On the second line print the sequence of the indices of the?any?maximum length subsequence of the given array that forms an increasing sequence of consecutive integers.

Examples

Input

7 3 3 4 7 5 6 8

Output

4 2 3 5 6

Input

6 1 3 5 2 4 6

Output

2 1 4

Input

4 10 9 8 7

Output

1 1

Input

9 6 7 8 3 4 5 9 10 11

Output

6 1 2 3 7 8 9

Note

All valid answers for the first example (as sequences of indices):

  • [1,3,5,6][1,3,5,6]
  • [2,3,5,6][2,3,5,6]

All valid answers for the second example:

  • [1,4][1,4]
  • [2,5][2,5]
  • [3,6][3,6]

All valid answers for the third example:

  • [1][1]
  • [2][2]
  • [3][3]
  • [4][4]

All valid answers for the fourth example:

  • [1,2,3,7,8,9]

題目大意:

找一個最長的子序列,使得這個序列的數字是連續的。要求你輸出最長子序列長度,和分別位于原序列中的位置下標,spj。

解題報告:

直接map暴力一下就好。假的dp。

AC代碼:

#include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<stack> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define FF first #define SS second #define ll long long #define pb push_back #define pm make_pair using namespace std; typedef pair<int,int> PII; const int MAX = 2e5 + 5; int n,ans,mx,a[MAX]; map<int,int> mp; int main() {cin>>n;for(int x,i = 1; i<=n; i++) {scanf("%d",&x);a[i]=x;mp[x] = mp[x-1]+1;if(mp[x] > ans) {ans = mp[x];mx=x;}}cout << ans << endl;int cur = mx-ans+1;for(int i = 1; i<=n; i++) {if(a[i] == cur) printf("%d ",i),cur++;}return 0 ; }

?

總結

以上是生活随笔為你收集整理的【Codeforces - 977F】Consecutive Subsequence(STLmap,输出路径,dp)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 网站av| 日本福利小视频 | 久热精品免费视频 | 国产欧美一区在线观看 | 在线观看麻豆 | 国产一区日韩精品 | 久久国产精品无码一区二区 | 亚洲国产毛片 | 国产不卡在线观看视频 | 少妇av在线播放 | www色综合| 99在线无码精品入口 | 97精品国产97久久久久久粉红 | 性高跟鞋xxxxhd国产电影 | 国产一级淫片a | 国产99久久九九精品无码免费 | 狠狠干2024| 一区二区三区四区亚洲 | 熟女视频一区二区三区 | 日韩一区二区免费在线观看 | 在线免费观看黄 | 蜜桃视频在线入口www | julia一区二区三区中文字幕 | 色爱亚洲| 在线麻豆视频 | 中文字幕9| 天堂av网手机版 | 色吊妞| 国产1页 | 中文字幕av网址 | 视频在线一区二区三区 | 欧美成人片在线观看 | 色爱AV综合网国产精品 | 蜜桃精品成人影片 | 欧美综合自拍亚洲综合图片区 | 在线观看成人黄色 | av番号网 | 亚洲一区二区激情 | 亚洲天堂免费看 | 国产精品乱码一区二区视频 | 精品一区二区三区在线观看视频 | 免费在线观看你懂的 | 国产精品黑人一区二区三区 | 奇米成人网 | 久久婷婷亚洲 | 国产免费一区二区三区在线观看 | 全部毛片永久免费看 | 在线一区二区三区四区五区 | 欧美亚洲| 中国性老太hd大全69 | 美女成人在线 | 巨胸大乳www视频免费观看 | www.久久av.com| 先锋av资源 | 国产真实乱在线更新 | 黄色成人影视 | 久草a视频 | 性色生活片 | 成人手机在线播放 | 欧美20p| 亚洲精品www久久久久久 | 亚洲第一av网站 | 国产鲁鲁视频在线观看特色 | 久久久av电影 | 欧亚av | 国产精品一区二区av日韩在线 | 国产美女精品视频国产 | 日韩欧美在线观看一区二区 | 人妖和人妖互交性xxxx视频 | 精品偷拍一区 | 人妻熟女一区二区三区app下载 | 老司机在线观看视频 | 亚洲夜色 | 久久亚洲精精品中文字幕早川悠里 | 国产精品久久影院 | 精品成在人线av无码免费看 | 91在线看黄| 亚洲AV成人无码精品久久盆瓶 | 精品无码一区二区三区蜜臀 | 一区二区三区免费网站 | 天天干妹子 | 亚洲国产麻豆 | 亚洲另类一区二区 | 欧美一级特黄aa大片 | 自拍视频在线播放 | youjizz中国少妇 | 精品动漫一区二区三区 | 无码人妻精品一区二区蜜桃视频 | 日韩一级免费毛片 | 好吊妞在线 | 成人av无码一区二区三区 | 男人插入女人阴道视频 | 91九色高潮 | 一级免费观看视频 | 午夜影院一区二区三区 | 亚洲黄色片在线观看 | 亚洲欧美日韩精品久久亚洲区 | 99久久久国产精品免费蜜臀 | 日韩久久久久久久久久 |