Submission #6498346


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(200005, 0);
  vector<vector<int>> id(200005);

  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-1);

  
  ll t = T / N;
  int mod = K % t;

  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
Task B - Do Not Duplicate
User straycat
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1265 Byte
Status AC
Exec Time 117 ms
Memory 15736 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 4 ms 5760 KB
01-02.txt AC 18 ms 6400 KB
01-03.txt AC 18 ms 6528 KB
01-04.txt AC 49 ms 8192 KB
01-05.txt AC 16 ms 6528 KB
01-06.txt AC 66 ms 8576 KB
01-07.txt AC 66 ms 8448 KB
01-08.txt AC 54 ms 9344 KB
01-09.txt AC 82 ms 10752 KB
01-10.txt AC 88 ms 11008 KB
01-11.txt AC 53 ms 10872 KB
01-12.txt AC 36 ms 9600 KB
01-13.txt AC 51 ms 10744 KB
01-14.txt AC 42 ms 8320 KB
01-15.txt AC 65 ms 9856 KB
01-16.txt AC 59 ms 8448 KB
01-17.txt AC 54 ms 8448 KB
01-18.txt AC 64 ms 8448 KB
01-19.txt AC 84 ms 9088 KB
01-20.txt AC 73 ms 8960 KB
01-21.txt AC 72 ms 8960 KB
01-22.txt AC 88 ms 11648 KB
01-23.txt AC 109 ms 11904 KB
01-24.txt AC 94 ms 11904 KB
01-25.txt AC 105 ms 15352 KB
01-26.txt AC 102 ms 15352 KB
01-27.txt AC 99 ms 14968 KB
01-28.txt AC 73 ms 10368 KB
01-29.txt AC 73 ms 10368 KB
01-30.txt AC 117 ms 15736 KB
sample-01.txt AC 4 ms 5760 KB
sample-02.txt AC 4 ms 5760 KB
sample-03.txt AC 4 ms 5760 KB
sample-04.txt AC 4 ms 5760 KB