提出 #33497709


ソースコード 拡げる

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
  cerr << "[";
  for (auto e : aux) cerr << e << ' ';
  cerr << "]";
  return cerr;
}

int n, k;

int main()
{
  cin >> n >> k;

  if (2 * k > n) {
    cout << -1;
    return 0;
  }

  int pos = 0;
  while (pos + 4 * k <= n) {
    for (int i = 1; i <= k; i++)
      cout << pos + k + i << ' ';

    for (int i = 1; i <= k; i++)
      cout << pos + i << ' ';

    pos += 2 * k;
  } 

  if (pos + 3 * k <= n) {
    for (int i = 1; i <= k; i++)
      cout << pos + k + i << ' ';

    int diff = n - pos - 3 * k;

    for (int i = 1; i <= diff; i++)
      cout << pos + i << ' ';

    for (int i = 1; i <= k; i++) 
      cout << n - k + i << ' ';

    for (int i = diff + 1; i <= k; i++)
      cout << pos + i << ' ';

    for (int i = 1; i <= diff; i++)
      cout << pos + 2 * k + i << ' ';

  } else {
    for (int i = k + 1; pos + i <= n; i++)
      cout << pos + i << ' ';

    for (int i = 1; i <= k; i++)
      cout << pos + i << ' ';
  }

  cout << '\n';

  return 0;
}

提出情報

提出日時
問題 C - K Derangement
ユーザ atatomir
言語 C++ (GCC 9.2.1)
得点 600
コード長 1375 Byte
結果 AC
実行時間 36 ms
メモリ 3560 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 3
AC × 97
セット名 テストケース
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 02_small_07.txt, 02_small_08.txt, 02_small_09.txt, 02_small_10.txt, 02_small_11.txt, 02_small_12.txt, 02_small_13.txt, 02_small_14.txt, 02_small_15.txt, 02_small_16.txt, 02_small_17.txt, 02_small_18.txt, 02_small_19.txt, 02_small_20.txt, 02_small_21.txt, 02_small_22.txt, 02_small_23.txt, 02_small_24.txt, 02_small_25.txt, 02_small_26.txt, 02_small_27.txt, 02_small_28.txt, 02_small_29.txt, 02_small_30.txt, 02_small_31.txt, 02_small_32.txt, 02_small_33.txt, 02_small_34.txt, 02_small_35.txt, 02_small_36.txt, 02_small_37.txt, 02_small_38.txt, 02_small_39.txt, 02_small_40.txt, 02_small_41.txt, 02_small_42.txt, 02_small_43.txt, 02_small_44.txt, 02_small_45.txt, 02_small_46.txt, 02_small_47.txt, 02_small_48.txt, 02_small_49.txt, 02_small_50.txt, 02_small_51.txt, 02_small_52.txt, 02_small_53.txt, 02_small_54.txt, 03_rand_01.txt, 03_rand_02.txt, 03_rand_03.txt, 03_rand_04.txt, 03_rand_05.txt, 03_rand_06.txt, 03_rand_07.txt, 03_rand_08.txt, 03_rand_09.txt, 03_rand_10.txt, 03_rand_11.txt, 03_rand_12.txt, 03_rand_13.txt, 03_rand_14.txt, 03_rand_15.txt, 03_rand_16.txt, 03_rand_17.txt, 03_rand_18.txt, 03_rand_19.txt, 03_rand_20.txt, 03_rand_21.txt, 03_rand_22.txt, 03_rand_23.txt, 03_rand_24.txt, 03_rand_25.txt, 03_rand_26.txt, 03_rand_27.txt, 03_rand_28.txt, 03_rand_29.txt, 03_rand_30.txt, 03_rand_31.txt, 03_rand_32.txt, 03_rand_33.txt, 03_rand_34.txt, 03_rand_35.txt, 03_rand_36.txt, 03_rand_37.txt, 03_rand_38.txt, 03_rand_39.txt, 03_rand_40.txt
ケース名 結果 実行時間 メモリ
01_sample_01.txt AC 8 ms 3480 KiB
01_sample_02.txt AC 2 ms 3480 KiB
01_sample_03.txt AC 2 ms 3336 KiB
02_small_01.txt AC 2 ms 3496 KiB
02_small_02.txt AC 5 ms 3516 KiB
02_small_03.txt AC 2 ms 3408 KiB
02_small_04.txt AC 2 ms 3412 KiB
02_small_05.txt AC 2 ms 3508 KiB
02_small_06.txt AC 2 ms 3516 KiB
02_small_07.txt AC 2 ms 3452 KiB
02_small_08.txt AC 2 ms 3476 KiB
02_small_09.txt AC 2 ms 3356 KiB
02_small_10.txt AC 2 ms 3476 KiB
02_small_11.txt AC 2 ms 3352 KiB
02_small_12.txt AC 1 ms 3504 KiB
02_small_13.txt AC 2 ms 3476 KiB
02_small_14.txt AC 2 ms 3352 KiB
02_small_15.txt AC 2 ms 3480 KiB
02_small_16.txt AC 2 ms 3424 KiB
02_small_17.txt AC 2 ms 3408 KiB
02_small_18.txt AC 2 ms 3408 KiB
02_small_19.txt AC 2 ms 3448 KiB
02_small_20.txt AC 2 ms 3448 KiB
02_small_21.txt AC 2 ms 3416 KiB
02_small_22.txt AC 3 ms 3560 KiB
02_small_23.txt AC 2 ms 3340 KiB
02_small_24.txt AC 2 ms 3508 KiB
02_small_25.txt AC 2 ms 3416 KiB
02_small_26.txt AC 2 ms 3412 KiB
02_small_27.txt AC 3 ms 3480 KiB
02_small_28.txt AC 3 ms 3408 KiB
02_small_29.txt AC 2 ms 3340 KiB
02_small_30.txt AC 2 ms 3472 KiB
02_small_31.txt AC 1 ms 3340 KiB
02_small_32.txt AC 2 ms 3416 KiB
02_small_33.txt AC 2 ms 3344 KiB
02_small_34.txt AC 2 ms 3476 KiB
02_small_35.txt AC 2 ms 3412 KiB
02_small_36.txt AC 2 ms 3424 KiB
02_small_37.txt AC 2 ms 3504 KiB
02_small_38.txt AC 2 ms 3412 KiB
02_small_39.txt AC 3 ms 3356 KiB
02_small_40.txt AC 2 ms 3476 KiB
02_small_41.txt AC 1 ms 3504 KiB
02_small_42.txt AC 2 ms 3488 KiB
02_small_43.txt AC 2 ms 3472 KiB
02_small_44.txt AC 2 ms 3492 KiB
02_small_45.txt AC 2 ms 3556 KiB
02_small_46.txt AC 3 ms 3420 KiB
02_small_47.txt AC 2 ms 3492 KiB
02_small_48.txt AC 2 ms 3476 KiB
02_small_49.txt AC 2 ms 3452 KiB
02_small_50.txt AC 3 ms 3408 KiB
02_small_51.txt AC 3 ms 3448 KiB
02_small_52.txt AC 3 ms 3408 KiB
02_small_53.txt AC 2 ms 3452 KiB
02_small_54.txt AC 2 ms 3520 KiB
03_rand_01.txt AC 24 ms 3408 KiB
03_rand_02.txt AC 6 ms 3472 KiB
03_rand_03.txt AC 6 ms 3408 KiB
03_rand_04.txt AC 33 ms 3448 KiB
03_rand_05.txt AC 4 ms 3472 KiB
03_rand_06.txt AC 2 ms 3472 KiB
03_rand_07.txt AC 2 ms 3336 KiB
03_rand_08.txt AC 34 ms 3508 KiB
03_rand_09.txt AC 10 ms 3452 KiB
03_rand_10.txt AC 21 ms 3504 KiB
03_rand_11.txt AC 25 ms 3516 KiB
03_rand_12.txt AC 14 ms 3472 KiB
03_rand_13.txt AC 6 ms 3424 KiB
03_rand_14.txt AC 21 ms 3404 KiB
03_rand_15.txt AC 4 ms 3504 KiB
03_rand_16.txt AC 12 ms 3476 KiB
03_rand_17.txt AC 19 ms 3340 KiB
03_rand_18.txt AC 4 ms 3492 KiB
03_rand_19.txt AC 9 ms 3556 KiB
03_rand_20.txt AC 2 ms 3472 KiB
03_rand_21.txt AC 2 ms 3504 KiB
03_rand_22.txt AC 3 ms 3472 KiB
03_rand_23.txt AC 2 ms 3408 KiB
03_rand_24.txt AC 36 ms 3504 KiB
03_rand_25.txt AC 12 ms 3508 KiB
03_rand_26.txt AC 3 ms 3412 KiB
03_rand_27.txt AC 20 ms 3452 KiB
03_rand_28.txt AC 7 ms 3336 KiB
03_rand_29.txt AC 2 ms 3476 KiB
03_rand_30.txt AC 26 ms 3336 KiB
03_rand_31.txt AC 5 ms 3484 KiB
03_rand_32.txt AC 14 ms 3504 KiB
03_rand_33.txt AC 7 ms 3472 KiB
03_rand_34.txt AC 22 ms 3452 KiB
03_rand_35.txt AC 4 ms 3480 KiB
03_rand_36.txt AC 30 ms 3500 KiB
03_rand_37.txt AC 28 ms 3492 KiB
03_rand_38.txt AC 27 ms 3412 KiB
03_rand_39.txt AC 5 ms 3412 KiB
03_rand_40.txt AC 2 ms 3408 KiB