QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#523749 | #6771. K-skip Permutation | zzz111 | WA | 0ms | 3700kb | C++20 | 1.2kb | 2024-08-18 17:25:35 | 2024-08-18 17:25:35 |
Judging History
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)
{
if(a[tem + k])
{
tem += k;
continue;
}
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: 3700kb
input:
3 1
output:
1 2 3
result:
ok ok
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3572kb
input:
7 3
output:
1 4 2 5 3 6 4
result:
wrong answer not perm