Contest Duration: - (local time) (160 minutes) Back to Home

Submission #6497435

Source Code Expand

Copy
```#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
ll N;
ll K;
cin >> N >> K;
vector<pair<int,int>> A(N);
vector<int> cnt(N+1, 0);
vector<vector<int>> id(N+1);

rep(i, N) {
int x; cin >> x;
A[i].first = x;
cnt[x]++;
A[i].second = cnt[x];
id[x].push_back(i);
}

ll T = 0LL;
int k = 0;
vector<int> sub;
while (true) {
int x = A[k].first;

if (A[k].second == cnt[x]) {
sub.push_back(k);
T += (ll)(N + id[x][0] - k + 1);
k = id[x][0] + 1;
} else {
T += (ll)(id[x][A[k].second] - id[x][A[k].second-1] + 1);
k = id[x][A[k].second] + 1;
}

if (k == N) break;
}
sub.push_back(N);

ll t = T / N;
if (t == 0) return 0;
int mod = (int)(K % t);

//int mod = ((K * N) % T) / N;

if (mod == 0) {
cout << "" << endl;
} else {

int k = sub[mod-1];
while (true) {
int x = A[k].first;
if (A[k].second == cnt[x]) {
cout << x << " ";
k++;
} else {
k = id[x][A[k].second]+1;
}

if (k == N) break;
}

cout << endl;
}

return 0;
}```

#### Submission Info

Submission Time 2019-07-21 23:29:41+0900 B - Do Not Duplicate straycat C++14 (GCC 5.4.1) 0 1325 Byte RE 137 ms 15736 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
 AC × 4
 AC × 30 RE × 4
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 RE 102 ms 256 KB
01-02.txt AC 16 ms 2304 KB
01-03.txt AC 17 ms 2560 KB
01-04.txt AC 49 ms 7296 KB
01-05.txt AC 14 ms 1920 KB
01-06.txt AC 65 ms 7936 KB
01-07.txt AC 62 ms 7168 KB
01-08.txt RE 102 ms 3840 KB
01-09.txt RE 105 ms 6016 KB
01-10.txt RE 106 ms 6656 KB
01-11.txt AC 53 ms 8184 KB
01-12.txt AC 35 ms 6272 KB
01-13.txt AC 50 ms 8312 KB
01-14.txt AC 41 ms 5888 KB
01-15.txt AC 64 ms 9344 KB
01-16.txt AC 58 ms 8448 KB
01-17.txt AC 55 ms 8448 KB
01-18.txt AC 65 ms 8448 KB
01-19.txt AC 80 ms 9088 KB
01-20.txt AC 75 ms 8960 KB
01-21.txt AC 72 ms 8960 KB
01-22.txt AC 97 ms 11648 KB
01-23.txt AC 108 ms 11904 KB
01-24.txt AC 104 ms 11904 KB
01-25.txt AC 115 ms 15352 KB
01-26.txt AC 137 ms 15352 KB
01-27.txt AC 126 ms 14968 KB
01-28.txt AC 73 ms 10368 KB
01-29.txt AC 73 ms 10368 KB
01-30.txt AC 116 ms 15736 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB
sample-03.txt AC 1 ms 256 KB
sample-04.txt AC 1 ms 256 KB