Submission #6497224
Source Code Expand
Copy
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair<int,int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; #define dame { puts("-1"); return 0;} #define yn {puts("Yes");}else{puts("No");} int main() { ll n,k; cin >> n >> k; int a[n]; int ccc[200005] = {}; rep(i,n){ cin >> a[i]; ccc[a[i]]++; } int count[200005]; int next[n]; int first[n]; rep(i,n){ next[i] = -1; first[i] = -1; } rep(i,200005)count[i] = -1; rep(i,n){ if(count[a[i]] == -1){ count[a[i]] = i; next[i] = i; first[a[i]] = i; }else{ next[count[a[i]]] = i; count[a[i]] = i; next[i] = -999; } } rep(i,n){ if(next[i]==-999){ next[i] = first[a[i]]; } } /* int head[200005][2]; int tale[200005][2]; rep(i,200005){ rep(j,2){ head[i][j] = -777; tale[i][j] = -777; } } int ddd[200005] = {}; rep(i,n){ if(ccc[a[i]]>=4){ if(ddd[a[i]]==0){ head[a[i]][0] = i; }else if(ddd[a[i]]==1){ head[a[i]][1] = i; }else if(ddd[a[i]]==ccc[a[i]]-2){ tale[a[i]][0] = i; }else if(ddd[a[i]]==ccc[a[i]]-1){ tale[a[i]][1] = i; } } ddd[a[i]]++; } */ ll now = 0; cout << '0' << endl; return 0; while(true){ ll tmp = now; int x = a[now%n]; int fff = 0; if(next[now%n]==now%n){ now += n; now++; }else if(next[now%n]>now%n){ now += (next[now%n]-now%n); now++; }else{ now += (n+next[now%n]-now%n); now++; } if(now>=n*k-1){ now = tmp; break; }else{ if(now%n==0){ ll loop = now; now += (((n*k-1)-now)/loop)*loop; } } } int ans[n+100] = {}; int c = 0; while(true){ if(now >= n*k)break; int x = a[now%n]; if(next[now%n]==now%n){ if(n*k-1<now+n){ cout << x << ' '; now++; }else{ now = now + n; now++; } }else if(next[now%n]>now%n){ if(n*k-1<now + (next[now%n]-now%n)){ cout << x << ' '; now++; }else{ now += (next[now%n]-now%n); now++; } }else{ if(n*k-1<now + (n+next[now%n]-now%n)){ cout << x << ' '; now++; }else{ now += (n+next[now%n]-now%n); now++; } } } cout << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Do Not Duplicate |
User | Shibuyap |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3335 Byte |
Status | WA |
Exec Time | 84 ms |
Memory | 3328 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||
Status |
|
|
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 | WA | 2 ms | 1024 KB |
01-02.txt | WA | 15 ms | 1536 KB |
01-03.txt | WA | 17 ms | 1664 KB |
01-04.txt | WA | 50 ms | 2944 KB |
01-05.txt | WA | 12 ms | 1408 KB |
01-06.txt | WA | 61 ms | 3072 KB |
01-07.txt | WA | 54 ms | 2816 KB |
01-08.txt | WA | 42 ms | 2176 KB |
01-09.txt | WA | 68 ms | 2944 KB |
01-10.txt | WA | 74 ms | 3200 KB |
01-11.txt | WA | 40 ms | 2304 KB |
01-12.txt | WA | 32 ms | 1920 KB |
01-13.txt | WA | 44 ms | 2304 KB |
01-14.txt | WA | 40 ms | 2304 KB |
01-15.txt | WA | 64 ms | 3072 KB |
01-16.txt | WA | 60 ms | 3328 KB |
01-17.txt | WA | 60 ms | 3328 KB |
01-18.txt | WA | 60 ms | 3328 KB |
01-19.txt | WA | 70 ms | 3328 KB |
01-20.txt | WA | 73 ms | 3328 KB |
01-21.txt | WA | 69 ms | 3328 KB |
01-22.txt | WA | 84 ms | 3328 KB |
01-23.txt | WA | 81 ms | 3328 KB |
01-24.txt | WA | 81 ms | 3328 KB |
01-25.txt | WA | 80 ms | 3328 KB |
01-26.txt | WA | 81 ms | 3328 KB |
01-27.txt | WA | 80 ms | 3328 KB |
01-28.txt | WA | 73 ms | 3328 KB |
01-29.txt | WA | 72 ms | 3328 KB |
01-30.txt | WA | 81 ms | 3328 KB |
sample-01.txt | WA | 2 ms | 1024 KB |
sample-02.txt | WA | 2 ms | 1024 KB |
sample-03.txt | WA | 2 ms | 1024 KB |
sample-04.txt | WA | 2 ms | 1024 KB |