-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.cpp
84 lines (72 loc) · 1.83 KB
/
template.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define f(i, n) for (ll i = 0; i < n; i++)
#define ia(a, n) \
ll a[n]; \
f(i, n) cin >> a[i]
#define iv(v,n) vector<ll> v(n); f(i,n) cin >> v[i]
#define MOD (1000000007)
#define INF 1000000000000000000LL // Infinity for ll
#define mp make_pair
#define nline '\n'
#define yes cout << "YES\n"
#define no cout << "NO\n"
template<typename T>
using os = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using oms = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
// read question properly
// don't forget newlines!!!!!!
// take care about cin >> t;
// comment the optimization before debugging
// ALWAYS USE FIXED << SETPRECISION WHILE OUTPUTTING FLOATS
void solve() {
ll n,k;
cin >> n >> k;
set<ll> st;
f(i,n) {
st.insert(i+1);
}
vector<ll> ans(n);
ll p1 = k-1;
while(p1 < n) {
ans[p1] = *st.begin();
st.erase(st.begin());
p1 += k;
}
f(i,n) {
if(ans[i]) {
cout << ans[i] << ' ';
}
else{
cout << *st.begin() << ' ';
st.erase(st.begin());
}
}
cout << nline;
}
int main() {
#ifdef PRADY
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
clock_t T = clock();
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t = 1;
cin >> t;
while (t--) {
solve();
}
#ifdef PRADY
cout << "\nTime taken: " << ((float) (clock() - T)) / CLOCKS_PER_SEC << " seconds";
#endif
return 0;
}