QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102337#6353. Kth Lex Min Min Min SubpalindromesAlpha_Q#WA 2ms3688kbC++172.2kb2023-05-03 04:51:562023-05-03 04:51:58

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 04:51:58]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3688kb
  • [2023-05-03 04:51:56]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1000010;
const __int128 INF = 1e18 + 69;

int n, m; long long k, power[N];
vector <int> two[] = {{1, 1, 2, 1, 2, 2}, {1, 1, 2, 2, 1, 2}, {1, 2, 1, 1, 2, 2}, {1, 2, 1, 2, 2, 1}, {1, 2, 2, 1, 1, 2}, {1, 2, 2, 1, 2, 1}, {2, 1, 1, 2, 1, 2}, {2, 1, 1, 2, 2, 1}, {2, 1, 2, 1, 1, 2}, {2, 1, 2, 2, 1, 1}, {2, 2, 1, 1, 2, 1}, {2, 2, 1, 2, 1, 1}};

int main() {
  cin >> n >> m >> k;
  if (n == 1) {
    if (k > m) puts("-1");
    else printf("%lld\n", k);
    return 0;
  }
  if (m == 1) {
    if (k > 1) {
      puts("-1");
    } else {
      for (int i = 1; i <= n; ++i) printf("1 ");
      puts(""); 
    }
    return 0;
  }
  if (m == 2) {
    if (n <= 6) {
      vector <vector <int>> who;
      for (int i = 0; i < 12; ++i) {
        who.emplace_back(two[i].begin(), two[i].begin() + n);
      }
      who.erase(unique(who.begin(), who.end()), who.end());
      if (k > who.size()) {
        puts("-1");
      } else {
        for (int x : who[k - 1]) printf("%d ", x); 
        puts("");
      }
    } else {
      if (k > 12) {
        puts("-1");
      } else {
        for (int i = 0; i < n; ++i) printf("%d ", two[k - 1][i % 6]);
        puts("");
      }
    }
    return 0;
  }
  if (m == 3) {
    if (k > 6) {
      puts("-1");
    } else {
      vector <int> vec({1, 2, 3});
      for (int i = 1; i < k; ++i) next_permutation(vec.begin(), vec.end());
      for (int i = 0; i < n; ++i) printf("%d ", vec[i % 3]);
      puts("");
    }
    return 0;
  }
  power[0] = 1;
  for (int i = 1; i < N; ++i) {
    power[i] = min(INF, (__int128) power[i - 1] * (m - 2)); 
  }
  __int128 total = min(INF, (__int128) power[n - 2] * m * (m - 1));
  if (total < k) {
    puts("-1");
    return 0;
  }
  int last = m + 1, prevLast = m + 1;
  for (int i = 1; i <= n; ++i) {
    __int128 each = i == 1 ? min(INF, (__int128) power[n - 2] * (m - 1)) : power[n - i];
    int cur = (k + each - 1) / each;
    k -= (cur - 1) * each;
    if (last <= cur) ++cur;
    if (prevLast <= cur) ++cur;
    printf("%d ", cur);
    swap(last, prevLast), last = cur;
  }
  puts("");
  return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3580kb

input:

1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3688kb

input:

2 2 2

output:

1 2 

result:

wrong answer 1st numbers differ - expected: '2', found: '1'