1473C - No More Inversions
14 Jan 2021 — Tags: constructive — URLThis comment explained it well.
Time complexity: $O(n)$
Memory complexity: $O(1)$
Click to show code.
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
int main(void)
{
ios::sync_with_stdio(false), cin.tie(NULL);
int t;
cin >> t;
while (t--)
{
int n, k;
cin >> n >> k;
for (int i = 1; i <= 2 * k - n - 1; ++i)
cout << i << " ";
for (int i = k; i >= 2 * k - n; --i)
cout << i << " ";
}
return 0;
}