Submission #6497020


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 += N + id[x][0] - k + 1;
      k = id[x][0] + 1;
    } else {
      T += 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;
  int mod = 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
Task B - Do Not Duplicate
User straycat
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1275 Byte
Status RE
Exec Time 106 ms
Memory 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 96 ms 256 KB
01-02.txt AC 15 ms 2304 KB
01-03.txt AC 16 ms 2560 KB
01-04.txt AC 47 ms 7296 KB
01-05.txt AC 13 ms 1920 KB
01-06.txt AC 63 ms 7936 KB
01-07.txt AC 61 ms 7168 KB
01-08.txt RE 98 ms 3840 KB
01-09.txt RE 100 ms 6144 KB
01-10.txt RE 99 ms 6760 KB
01-11.txt AC 51 ms 8184 KB
01-12.txt AC 34 ms 6272 KB
01-13.txt AC 49 ms 8312 KB
01-14.txt AC 40 ms 5888 KB
01-15.txt AC 65 ms 9344 KB
01-16.txt AC 60 ms 8448 KB
01-17.txt AC 53 ms 8448 KB
01-18.txt AC 61 ms 8448 KB
01-19.txt AC 78 ms 9088 KB
01-20.txt AC 72 ms 8960 KB
01-21.txt AC 72 ms 8960 KB
01-22.txt AC 83 ms 11648 KB
01-23.txt AC 88 ms 11904 KB
01-24.txt AC 87 ms 11904 KB
01-25.txt AC 98 ms 15352 KB
01-26.txt AC 101 ms 15352 KB
01-27.txt AC 105 ms 14968 KB
01-28.txt AC 71 ms 10368 KB
01-29.txt AC 71 ms 10368 KB
01-30.txt AC 106 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