QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#523748#6771. K-skip Permutationzzz111RE 40ms11492kbC++201.0kb2024-08-18 17:24:202024-08-18 17:24:20

Judging History

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

  • [2024-08-18 17:24:20]
  • 评测
  • 测评结果:RE
  • 用时:40ms
  • 内存:11492kb
  • [2024-08-18 17:24:20]
  • 提交

answer

#include <bits/stdc++.h>
//#define int long long
#define endl '\n'
#define fr(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define br(i, a, b) for (int(i) = (a); (i) >= (b); (i)--)
using namespace std;
const int N = 1e6 + 10 ;
int a[N];
int ans[N];
int cnt;
inline void solve()
{
    int n, k;
    cin >> n >> k;
    if (k == 1)
    {
        for (int i = 1; i <= n - 1; i++)
            cout << i << " ";
        cout << n;
        return;
    }
    fr(i, 1, n)
    {
        if(cnt >= n)
            break;
        if (a[i])
            continue;
        ans[++cnt] = i;
        a[i] = 1;
        int tem = i;
        while (tem + k <= n)
        {
            ans[++cnt] = tem + k;
            tem += k;
            a[tem + k] = 1;
        }
    }
    for (int i = 1; i <= n - 1; i++)
    {
        cout << ans[i] << ' ';
    }
    cout << ans[n];
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //   cin >> T;
    while (T--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3548kb

input:

3 1

output:

1 2 3

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

7 3

output:

1 4 7 2 5 3 6

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

3 7

output:

1 2 3

result:

ok ok

Test #4:

score: 0
Accepted
time: 40ms
memory: 11444kb

input:

1000000 2

output:

1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175 177...

result:

ok ok

Test #5:

score: 0
Accepted
time: 35ms
memory: 11492kb

input:

1000000 20

output:

1 21 41 61 81 101 121 141 161 181 201 221 241 261 281 301 321 341 361 381 401 421 441 461 481 501 521 541 561 581 601 621 641 661 681 701 721 741 761 781 801 821 841 861 881 901 921 941 961 981 1001 1021 1041 1061 1081 1101 1121 1141 1161 1181 1201 1221 1241 1261 1281 1301 1321 1341 1361 1381 1401 1...

result:

ok ok

Test #6:

score: 0
Accepted
time: 39ms
memory: 11372kb

input:

1000000 200

output:

1 201 401 601 801 1001 1201 1401 1601 1801 2001 2201 2401 2601 2801 3001 3201 3401 3601 3801 4001 4201 4401 4601 4801 5001 5201 5401 5601 5801 6001 6201 6401 6601 6801 7001 7201 7401 7601 7801 8001 8201 8401 8601 8801 9001 9201 9401 9601 9801 10001 10201 10401 10601 10801 11001 11201 11401 11601 118...

result:

ok ok

Test #7:

score: -100
Runtime Error

input:

1000000 2777

output:


result: