Submission #6497364


Source Code Expand

Copy
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<string>
#include<set>

const long long int MOD=1e9+7;

using namespace std;

int main(){
    long long int n,k,a[200009],to[200009];
    map<long long, long long > m;
    set<long long > S;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> a[i];
        to[m[a[i]]] = i;
        m[a[i]] = i;
    }
    for(int i=0;i<n;i++){
        to[m[a[i]]] = i;
        m[a[i]] = i;
    }
    long long cur=0, cnt=0;
    while(1){
        long long next = to[cur];
        if(next<=cur)cnt++;
        if(next==n-1){
            break;
        }
        cur=next+1;
    }
    cnt++;
    k %= cnt;

    cur = 0;
    while(1){
        if(cnt==1){
            break;
        }
        if(k>1){
            long long next = to[cur];
            if(next<=cur)k--;
            cur = next+1;
        }
        if(k==1){
            while(1){
                long long next = to[cur];
                if(next<=cur){
                    cout << a[cur] << ' ';
                    cur++;
                }
                else{
                    cur = next+1;
                }
                if(cur==n-1){
                    cout << a[n-1];
                }
                if(cur>=n-1)break;
            }
            break;
        }
    }
    cout << endl;
}

Submission Info

Submission Time
Task B - Do Not Duplicate
User minszsz
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1417 Byte
Status AC
Exec Time 263 ms
Memory 17152 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 4
AC × 34
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
All 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
Case Name Status Exec Time Memory
01-01.txt AC 1 ms 256 KB
01-02.txt AC 24 ms 1152 KB
01-03.txt AC 27 ms 2560 KB
01-04.txt AC 83 ms 3200 KB
01-05.txt AC 24 ms 1664 KB
01-06.txt AC 135 ms 4224 KB
01-07.txt AC 119 ms 4480 KB
01-08.txt AC 108 ms 8192 KB
01-09.txt AC 178 ms 10112 KB
01-10.txt AC 198 ms 10752 KB
01-11.txt AC 118 ms 9600 KB
01-12.txt AC 84 ms 8064 KB
01-13.txt AC 121 ms 9728 KB
01-14.txt AC 94 ms 5376 KB
01-15.txt AC 180 ms 8832 KB
01-16.txt AC 99 ms 3456 KB
01-17.txt AC 98 ms 3456 KB
01-18.txt AC 100 ms 3456 KB
01-19.txt AC 155 ms 4608 KB
01-20.txt AC 154 ms 4608 KB
01-21.txt AC 152 ms 4608 KB
01-22.txt AC 215 ms 11264 KB
01-23.txt AC 221 ms 11264 KB
01-24.txt AC 217 ms 11264 KB
01-25.txt AC 251 ms 16768 KB
01-26.txt AC 263 ms 16768 KB
01-27.txt AC 248 ms 16384 KB
01-28.txt AC 209 ms 9600 KB
01-29.txt AC 215 ms 9600 KB
01-30.txt AC 255 ms 17152 KB
sample-01.txt AC 2 ms 2304 KB
sample-02.txt AC 2 ms 2304 KB
sample-03.txt AC 2 ms 2304 KB
sample-04.txt AC 2 ms 2304 KB