General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
174966720 Practice:
vigcancode
1234B2 - 27 C++20 (GCC 11-64) Accepted 218 ms 15424 KB 2022-10-07 15:07:00 2022-10-07 15:07:00
→ Source
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
//tc fori forj
//QUALITY>QUANTITY
// NO WRONG SUBMISSIONS ONLY CORRECT ANSWERS

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,s;
    queue <ll> v1;
    set <ll> s1;
    cin>>n>>s;

    while (n--)
    {
        ll x;
        cin>>x;
        if (v1.size()<s)
        {
            if (s1.count(x)==0)
            {
            v1.push(x);
            s1.insert(x);
            }
        }
        else
        {
            
            if (s1.count(x)==0)
            {
                ll t=v1.front();
                s1.erase(t);
                v1.pop();
                v1.push(x);
                s1.insert(x);
            }

        }

    }
   
    vector <ll> v2;
    while (!v1.empty())
    {
        v2.push_back(v1.front());
        v1.pop();
    }
    cout<<v2.size()<<"\n";
    for (ll i=v2.size()-1;i>=0;i--)
    {
        cout<<v2[i]<<" ";
    }
    
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details