Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
- // #pragma comment(linker, "/stack:200000000"]
- #include <iostream>
- #include <vector>
- #include <cmath>
- #include <algorithm>
- #include <unordered_set>
- #include <unordered_map>
- #include <set>
- #include <map>
- #include <queue>
- #include <deque>
- #include <bitset>
- #include <stack>
- #include <random>
- #include <fstream>
- #include <sstream>
- #include <chrono>
- #define fi first
- #define se second
- #define pb push_back
- #define ll long long
- #define ld long double
- #define hm unordered_map
- #define pii pair<int, int>
- #define sz(a) (int)a.size()
- #define all(a) a.begin(), a.end()
- #define cinv(v) for (auto& x: v) cin >> x
- #define fr(i, n) for (int i = 0; i < n; ++i)
- #define fl(i, l, n) for (int i = l; i < n; ++i)
- #define int ll
- using namespace std;
- #ifdef __LOCAL
- #define dbg(x) cerr << #x << " : " << x << '\n'
- const int maxn = 20;
- #else
- #define dbg(x)
- const int maxn = 2e5 + 20;
- #endif
- //tg: @galebickosikasa
- ostream& operator << (ostream& out, vector<int>& v) {
- for (auto& x: v) out << x << ' ';
- return out;
- }
- ostream& operator << (ostream& out, pii& v) {
- out << v.fi << ", " << v.se;
- return out;
- }
- istream& operator >> (istream& in, pii& a) {
- in >> a.fi >> a.se;
- return in;
- }
- const ll inf = (ll) 2e9;
- const ld pi = asin (1) * 2;
- const ld eps = 1e-8;
- const ll mod = (ll)1e9 + 7;
- const ll ns = 97;
- mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
- signed main () {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int n, q, k;
- cin >> n >> q >> k;
- vector<pii> moo (q);
- cinv (moo);
- vector<int> goo (n);
- cinv (goo);
- fr (j, 2) fr (i, n) goo.pb (goo[i]);
- reverse (all (moo));
- for (auto& x: moo) x.se *= -1;
- int block = 0, ost = 0;
- for (auto& t: moo) {
- if (t.fi == 1) {
- int x = t.se;
- x = abs (x);
- x %= k;
- if (t.se >= 0) ost += x;
- else ost -= x;
- if (ost >= k) ost -= k;
- if (ost < 0) ost += k;
- } else {
- int x = t.se;
- x = abs (x);
- int c = x / k;
- c %= n;
- if (t.se > 0) block += c;
- else block -= c;
- x %= k;
- if (t.se > 0) ost += x;
- else ost -= x;
- if (ost >= k) {
- ost -= k;
- ++block;
- }
- if (ost < 0) {
- ost += k;
- --block;
- }
- if (block >= n / k) block -= n / k;
- if (block < 0) block += n / k;
- }
- dbg (block);
- dbg (ost);
- }
- vector<vector<int>> ans (n / k);
- int st = n - ost, end = n - ost + k;
- fr (j, n / k) {
- fl (i, st, end) {
- ans[j].pb (goo[i]);
- }
- st = end, end += k;
- }
- int x = n / k - block;
- fl (i, x, sz (ans)) cout << ans[i];
- fr (i, x) cout << ans[i];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement