-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbowlers_strategy.cpp
91 lines (88 loc) · 1.53 KB
/
bowlers_strategy.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
85
86
87
88
89
90
91
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fr(i, a, n) for (int i = a; i < n; i++)
#define fre(i, a, b) for (int i = a; i <= b; i++)
#define endl '\n'
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define mem(name, value) memset(name, value, sizeof(name))
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define case cout << "Case " << t++ << ": ";
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--)
{
int n, k, l;
cin >> n >> k >> l;
int cnt = 0;
if(n%l==0 && n/l > k)
{
cout << -1;
}
else if(n%l==1 && (n/l+1) > k)
{
cout << -1;
}
else
{
int i = 1;
bool flag = 0;
int res = 0;
while (i <= k)
{
while (cnt < l && res < n)
{
if (k % 2 == 0)
{
if (res <= n - 2)
{
cout <<" "<< i << " " << i + 1;
cnt++;
res += 2;
}
else
{
cout << " " << i;
res += 1;
}
}
else
{
if (flag == 0 && res <= n - 3)
{ // k==5
cout <<" "<< i << " " << i + 1 << " " << k;
cnt++;
res += 3;
}
else if(flag==1 && res <= n - 2)
{
cout <<" "<<i << " " << i + 1;
cnt++;
res = res + 2;
}
else
{
cout <<" "<<i;
cnt++;
res = res + 1;
}
}
}
flag = 1;
i = i + 2;
cnt = 0;
}
}
cout<<endl;
}
}