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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| #include<bits/stdc++.h> #define up(i,a,b) for(int i=a;i<b;i++) #define dw(i,a,b) for(int i=a;i>b;i--) #define upd(i,a,b) for(int i=a;i<=b;i++) #define dwd(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll; typedef unsigned long long ull; const double esp = 1e-6; const double pi = acos(-1.0); const int INF = 0x3f3f3f3f; const int inf = 1e9; using namespace std; ll read() { char ch = getchar(); ll x = 0, f = 1; while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } typedef pair<int, int> pir; #define lson l,mid,root<<1 #define rson mid+1,r,root<<1|1 #define lrt root<<1 #define rrt root<<1|1 const int N = 1e5 + 10; int T, n; ll l, r; int a[N]; vector<int>vec1; int main() { T = read(); while (T--) { n = read(); l = read(), r = read(); ll sum = 0; int pos_l = 0; int pos_r = 0; ll temp_l; ll l_sum; upd(i, 1, n) { ll tempsum = 2ll * (n - i) + sum; if (i == n)tempsum++; if (l <= tempsum && l >= sum) { temp_l = 2ll * (n - i); l_sum = sum; pos_l = i; break; } sum += 2 * (n - i); } sum = 0; ll temp_r; ll r_sum; upd(i, 1, n) { ll tempsum = 2ll * (n - i) + sum; if (i == n)tempsum++; if (r <= tempsum && r >= sum) { temp_r = 2ll * (n - i); r_sum = sum; pos_r = i; break; } sum += 2ll * (n - i); } if (pos_l == pos_r) { if (pos_l == n)printf("%d\n", 1); else { l -= l_sum; r -= r_sum; upd(j, l, r) { if (j % 2 == 0) printf("%d ", pos_l + (j / 2)); else printf("%d ", pos_r); } } continue; } l -= l_sum; upd(j, l, temp_l) { if (j % 2 == 0) printf("%d ", pos_l + (j / 2)); else printf("%d ", pos_l); } upd(i, pos_l + 1, pos_r - 1) { int block = 2 * (n - i); upd(j, 1, block) { if (j % 2 == 0) printf("%d ", i + (j / 2)); else printf("%d ", i); } } r -= r_sum; if (pos_r == n)printf("%d ", 1); else { upd(j, 1, r) { if (j % 2 == 0) printf("%d ", pos_r + (j / 2)); else printf("%d ", pos_r); } } printf("\n"); } return 0; }
|