Submission #6497678


Source Code Expand

Copy
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(LL a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
//vector<int> FROM[200000+10];
map<int,int> LAS_app;
vector<vector<int> > GUI_LV;
map<int,int> FIR_app;
vector<int> dp[200000+10];
int a[200000+10];
map<int,int> MM;
int main(){
	LL n,k;
	cin>>n>>k;
	rb(i,1,n) cin>>a[i];
	rl(i,n,1){
		if(LAS_app[a[i]]){
			dp[i]=dp[LAS_app[a[i]]+1];
		}
		else{
			dp[i]=dp[i+1];
			dp[i].PB(a[i]);
		}
		LAS_app[a[i]]=i;
	}
	rb(i,1,n){
		if(!FIR_app[a[i]])
		FIR_app[a[i]]=i;
	}
	int NOW=-INF;
	FIR_app[NOW]=0;
	vector<int> EMPM;
	MM[n+1]=1;
	while(1){
			if(MM[FIR_app[NOW]+1]) break;
			MM[FIR_app[NOW]+1]=1;
			GUI_LV.PB(dp[FIR_app[NOW]+1]);
			if(!dp[FIR_app[NOW]+1].empty()){
				NOW=dp[FIR_app[NOW]+1][dp[FIR_app[NOW]+1].size()-1];
			}
			else{
				break;
			}
//			int SZ=dp[FIR_app[NOW]+1].size();
//			rl(i,SZ,1){
//				cout<<dp[FIR_app[NOW]+1][i-1]<<" ";
//			}
//			cout<<endl;
	}
	int IS=k%(GUI_LV.size());
	IS--;
	if(IS<0){
		IS=GUI_LV.size()-1;
	}
	int SZ=GUI_LV[IS].size();
	rl(i,SZ,1){
		cout<<GUI_LV[IS][i-1]<<" ";
	}
	return 0;
}

Submission Info

Submission Time
Task B - Do Not Duplicate
User Gary
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1444 Byte
Status
Exec Time 2337 ms
Memory 891440 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
All 0 / 700 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 3 ms 4992 KB
01-02.txt 40 ms 17664 KB
01-03.txt 45 ms 19328 KB
01-04.txt 135 ms 44928 KB
01-05.txt 98 ms 72380 KB
01-06.txt 285 ms 130304 KB
01-07.txt 271 ms 120248 KB
01-08.txt 481 ms 397496 KB
01-09.txt 731 ms 596408 KB
01-10.txt 857 ms 746044 KB
01-11.txt 2335 ms -811684 KB
01-12.txt 2337 ms -809604 KB
01-13.txt 2333 ms -824580 KB
01-14.txt 87 ms 12288 KB
01-15.txt 158 ms 19584 KB
01-16.txt 162 ms 49792 KB
01-17.txt 167 ms 53248 KB
01-18.txt 151 ms 40704 KB
01-19.txt 362 ms 167608 KB
01-20.txt 353 ms 172032 KB
01-21.txt 297 ms 112640 KB
01-22.txt 1008 ms 753588 KB
01-23.txt 1276 ms 891440 KB
01-24.txt 1192 ms 870448 KB
01-25.txt 2335 ms -868100 KB
01-26.txt 2333 ms -882564 KB
01-27.txt 2328 ms -892548 KB
01-28.txt 168 ms 18176 KB
01-29.txt 179 ms 21376 KB
01-30.txt 2330 ms -865540 KB
sample-01.txt 4 ms 4992 KB
sample-02.txt 4 ms 4992 KB
sample-03.txt 4 ms 4864 KB
sample-04.txt 4 ms 4992 KB