usingnamespace Read; #define int long long constint maxn = 2e5 + 5; int n, m, T; int l[maxn], sl, r[maxn], sr; structNode { int op, d; }a[maxn]; int x[maxn], ans[maxn], id[maxn];
intQ2(int x){ int tmp = (x % m + m) % m, tmp1 = (x - tmp) / m; returnupper_bound(r, r + sr, tmp) - r + tmp1 * sr; }
intQ1(int x){ int tmp = (x % m + m) % m, tmp1 = (x - tmp) / m; returnupper_bound(l, l + sl, tmp) - l + tmp1 * sl; }
signedmain(){ int i, j; r1(n, m, T); for(i = 0; i < n; ++ i) { int op, x; r1(x, op); a[i] = {op, x}; if(op == 1) r[sr ++] = x; else l[sl ++] = x; } for(i = 0; i < n; ++ i) { x[i] = a[i].d; if(a[i].op == 1) { x[i] = (x[i] + T) % m; id[i] = (i + Q1(a[i].d + 2 * T) - Q1(a[i].d)) % n; } else { x[i] = ((x[i] - T) % m + m) % m; id[i] = (i - Q2(a[i].d - 1) + Q2(a[i].d - 2 * T - 1)) % n; id[i] = (id[i] + n) % n; } // printf("%d : %d\n", i, id[i]); ans[id[i]] = x[i]; } for(i = 0; i < n; ++ i) printf("%lld\n", ans[i]); return0; }
signedmain(){ int i, j, del(0); r1(n, m, T); for(i = 0; i < n; ++ i) { int x, op; r1(x, op); x += (op == 1 ? T : -T); del += (int)floor(1.0 * x / m); ans[i] = ((x % m) + m) % m; } del = (del % n + n) % n; sort(ans, ans + n); for(i = 0; i < n; ++ i) printf("%d\n", ans[(i + del) % n]); return0; }