QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676638 | #6238. 转盘 | propane | 100 ✓ | 161ms | 12540kb | C++20 | 1.9kb | 2024-10-25 22:41:14 | 2024-10-25 22:41:15 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
using LL = long long;
const int maxn = 2e5 + 5;
struct Info{
int mn, mx, lmn;
}tr[maxn * 4];
int a[maxn];
int query(int u, int l, int r, int mx){
if (tr[u].mx <= mx) return l + mx;
if (l == r){
return tr[u].mn;
}
int mid = (l + r) / 2;
if (mx <= tr[2 * u + 1].mx){
return min(tr[u].lmn, query(2 * u + 1, mid + 1, r, mx));
}
return min(mid + 1 + mx, query(2 * u, l, mid, mx));
}
void pushup(int u, int l, int r){
int mid = (l + r) / 2;
tr[u].lmn = query(2 * u, l, mid, tr[2 * u + 1].mx);
tr[u].mn = min(tr[u].lmn, tr[2 * u + 1].mn);
tr[u].mx = max(tr[2 * u].mx, tr[2 * u + 1].mx);
}
void build(int u, int l, int r){
if (l == r){
tr[u].mn = a[r];
tr[u].mx = a[r] - r;
return;
}
int mid = (l + r) / 2;
build(2 * u, l, mid);
build(2 * u + 1, mid + 1, r);
pushup(u, l, r);
}
void modify(int u, int l, int r, int x, int v){
if (l == r){
tr[u].mn = v;
tr[u].mx = v - r;
return;
}
int mid = (l + r) / 2;
if (x <= mid) modify(2 * u, l, mid, x, v);
else modify(2 * u + 1, mid + 1, r, x, v);
pushup(u, l, r);
}
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n, m, t;
cin >> n >> m >> t;
for(int i = 1; i <= n; i++){
int x;
cin >> x;
a[i] = a[i + n] = x;
}
build(1, 1, 2 * n);
int lastans = 0;
cout << (lastans = tr[1].lmn + n - 1) << '\n';
while(m--){
int x, y;
cin >> x >> y;
if (t) x ^= lastans, y ^= lastans;
modify(1, 1, 2 * n, x, y);
modify(1, 1, 2 * n, x + n, y);
cout << (lastans = tr[1].lmn + n - 1) << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 1ms
memory: 5600kb
input:
10 10 0 7 2 5 1 2 0 8 6 7 10 10 7 3 2 4 9 4 1 7 4 2 8 4 4 4 0 10 1 7 10
output:
13 13 12 15 12 11 11 12 11 11 15
result:
ok 11 numbers
Test #2:
score: 10
Accepted
time: 0ms
memory: 3676kb
input:
1000 0 0 98 843 198 961 748 985 973 261 45 667 751 484 910 496 70 942 470 346 133 375 588 349 777 548 666 422 626 962 221 190 632 303 94 434 791 475 461 139 826 299 496 781 559 481 654 567 407 600 60 448 65 608 674 141 885 164 114 318 530 335 584 791 221 483 98 562 754 597 497 964 327 550 718 995 61...
output:
1883
result:
ok 1 number(s): "1883"
Test #3:
score: 10
Accepted
time: 6ms
memory: 12264kb
input:
100000 0 0 59004 63621 17833 27004 14614 93468 50752 73907 28069 34389 73598 88020 8078 890 57855 83403 50743 99186 45245 62265 2954 74936 80779 28835 84127 91169 31056 26064 44532 10413 4769 95815 1887 58857 18148 92670 62295 54812 92480 77205 78262 83178 95403 45413 71547 9343 23251 94397 18891 56...
output:
198671
result:
ok 1 number(s): "198671"
Test #4:
score: 10
Accepted
time: 5ms
memory: 5636kb
input:
5000 5000 0 14148 29409 3253 67207 82747 81931 35637 61048 75968 68397 23309 77857 4890 23065 98671 60961 10456 32145 65884 62756 18971 85612 28374 57188 52530 15580 29884 48870 13528 21353 34905 87011 81849 10108 21751 90872 821 42031 3022 3774 44100 86052 3054 62127 52383 37324 10690 91214 94233 2...
output:
103921 103917 103758 103631 103631 103631 103631 103631 103543 103560 103560 103560 103560 103601 103601 103512 103794 103917 103917 104037 103917 103917 103917 103922 103755 103755 103854 103854 103854 103854 104147 104147 104178 103854 103854 103854 103810 103711 103680 103680 103680 103449 103449...
result:
ok 5001 numbers
Test #5:
score: 10
Accepted
time: 119ms
memory: 11020kb
input:
80000 80000 0 32989 45163 18813 22030 29154 77607 76050 28952 24261 63797 16775 55006 11628 31480 42566 42666 77036 31870 36709 40549 46520 71788 56170 10372 7203 77002 11366 52407 7430 1834 36789 67502 72165 1468 78366 46381 53868 43382 33178 22843 23929 77830 30927 41418 63338 32384 7601 55141 650...
output:
158803 158803 158803 158872 158872 158939 158782 158782 158782 158939 158939 158647 158647 158647 158584 158584 158745 158745 158745 158849 158939 158941 158941 158941 158941 158813 158857 158772 158772 158857 158857 158849 158849 158849 158849 158753 158753 158753 158753 158753 158753 158753 158753...
result:
ok 80001 numbers
Test #6:
score: 10
Accepted
time: 124ms
memory: 12044kb
input:
80000 80000 1 28275 66559 18397 65122 31932 34265 43768 69435 24298 28015 59714 28200 15471 37108 8579 73896 20454 42362 20107 69670 72432 47085 4226 16475 15286 35121 30828 21007 53806 79471 16718 29772 66366 26448 19300 51036 72583 78358 36985 33237 56652 64922 299 24743 31196 48755 58662 28483 21...
output:
159055 159055 159055 159055 159043 159043 159043 159043 159043 159042 159042 159042 159042 158952 158966 158966 158966 158966 158860 158812 158812 158812 158812 158812 158812 158864 158864 158850 158766 158766 158766 159042 158766 158938 158938 159042 159042 159042 159042 159042 159042 159042 159042...
result:
ok 80001 numbers
Test #7:
score: 10
Accepted
time: 140ms
memory: 12540kb
input:
90000 90000 0 61115 41446 89248 79732 23484 10999 24304 17649 61557 35940 79883 77970 88423 40021 3444 39359 9548 28808 40730 4690 38872 81321 83601 61148 34333 58364 24056 22984 35055 30667 27033 67404 72613 17793 20084 28468 57782 27276 15831 24527 31047 88784 53820 51689 36111 6476 69605 86968 47...
output:
178821 178821 178821 178842 178842 178842 178842 178842 178842 178848 178848 178848 178848 178848 178655 178848 178848 178848 178872 178872 178872 178872 178872 178872 178872 178848 178848 178872 178872 178842 178842 178872 178872 178855 178855 178855 178848 178848 178842 178842 178785 178785 178842...
result:
ok 90001 numbers
Test #8:
score: 10
Accepted
time: 134ms
memory: 12084kb
input:
90000 90000 1 70422 38508 81712 27997 47830 42518 17579 19061 88179 6464 32177 8006 26231 48876 49529 88786 81550 36501 46337 24935 26943 43133 65181 70088 68404 26243 37218 9124 43370 39807 81031 87092 50223 14296 81689 58993 68606 11802 47300 10854 83066 24629 73262 48152 51942 38147 46678 2114 76...
output:
178598 178598 178598 178598 178598 178598 178598 178598 178598 178598 178598 178598 178551 178509 178598 178598 178598 178598 178598 178937 178959 178959 178959 178959 178904 178904 178873 178873 178873 178873 178856 178850 178850 178850 178850 178750 178750 178750 178750 178750 178750 178750 178750...
result:
ok 90001 numbers
Test #9:
score: 10
Accepted
time: 161ms
memory: 11308kb
input:
100000 100000 0 3942 41909 47657 56785 14955 50170 85101 77135 50257 51840 47814 40120 37828 56084 9642 21599 98629 53287 24901 18955 91640 80817 66978 18668 12384 45906 70066 30238 24655 66440 7408 26321 33345 11756 17651 53253 66703 95051 35745 34425 11032 7776 41366 49162 637 36213 7120 81330 754...
output:
198793 198793 198793 198714 198667 198590 198714 198714 198714 198714 198714 198704 198642 198642 198540 198540 198540 198436 198436 198612 198612 198561 198561 198385 198342 198328 198328 198155 198117 198117 198117 198117 198213 198211 198211 198625 198625 198625 198625 198211 198115 198115 198691...
result:
ok 100001 numbers
Test #10:
score: 10
Accepted
time: 155ms
memory: 12152kb
input:
100000 100000 1 68406 4687 3244 87851 90742 84131 24281 91924 46876 23203 6438 20342 40964 90461 43485 29830 92415 66006 67866 67283 43730 8205 66624 25626 2683 17266 2465 7327 51934 26369 59169 67742 92326 30174 17969 37925 36963 46574 60757 66814 46645 70608 50003 69817 21485 7970 5399 82014 77105...
output:
198875 198875 198853 198826 198826 198821 198821 198821 198821 198821 198821 198762 198762 198762 198762 198762 198762 198762 198853 198825 198825 198853 198807 198807 198807 198807 198853 198853 198853 198853 198853 198774 198771 198853 198657 198657 198657 198899 198892 198892 198899 198899 198899...
result:
ok 100001 numbers