Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define cin(v) for (auto &i : v) cin >> i;
- #define cout(v) for (auto &i : v) cout << i << " "; cout<<'\n';
- #define ll long long
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define MOD 1000000007
- #define Ceil(a,b) a / b + (a % b != 0)
- #define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs"<< "\n";
- void Warding()
- {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- /*
- STOP USING int
- */
- void solve(){
- ll n, k; cin>>n>>k;
- vector<ll> v(n); cin(v);
- ll times = ((n + 1) / 2), cycles = k / (times), change = k % times;
- bool flip = (cycles & 1);
- for(int i=0; i<Ceil(n,2); i++){
- if(i < change){
- if(!flip)
- swap(v[i],v[n - i - 1]);
- }else if(flip){
- swap(v[i], v[n - i - 1]);
- }
- }
- cout(v);
- }
- int main()
- {
- Warding();
- int TC = 1;
- cin >> TC;
- while (TC--)
- {
- solve();
- }
- Time
- }
Advertisement
Add Comment
Please, Sign In to add comment