Submission

Status:
----------

Score: 0

User: osensunny

Problemset: Consecutive Subsequence

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-22 23:14:50

#include<bits/stdc++.h>
using namespace std;

int l, r, mxsz=INT_MIN;
string str;
vector<int> arr;
map<int, vector<int>> mp;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    while(true){
        cin >> str;
        if((str[0] >= 'a' && str[0] <= 'z') || (str[0] >= 'A' && str[0] <= 'Z')) break;
        arr.push_back(stoi(str));
    }

    while(l < arr.size() && r < arr.size()){
        if(l == r || arr[r] == arr[r-1] + 1){
            r++;
            if(r != arr.size()) continue;
        }
        vector<int> tmp(arr.begin()+l, arr.begin()+r);
        mp[tmp.size()] = tmp;
        mxsz = max(mxsz, (int)tmp.size());
        l = r;
    }

    for(auto x: mp[mxsz]) cout << x << ' ';

    return 0;
}