QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#895420 | #3399. 向量集 | liyujia | 100 ✓ | 396ms | 142060kb | C++14 | 2.2kb | 2025-02-12 13:49:55 | 2025-02-12 13:49:56 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 400005;
struct vec{
signed x, y;
vec(int X = 0, int Y = 0){ x = X, y = Y;}
bool operator <(vec Y){ return x != Y.x? x < Y.x: y < Y.y;}
} q[N * 2], f[N * 2];
int n, x, y, l, r, la, cnt;
void dec(int &x){ x = x ^ (la & 0x7fffffff);}
char c, tp;
bool cmp(int x1, int y1, int x2, int y2){ return x1 * y2 < x2 * y1;}
struct sgt{
vector <vec> f[N << 2][2];
int sz[N << 2];
void rec(int x){
for(int o = 0; o < 2; o++){
f[x][o] = f[x << 1][o];
for(auto j: f[x << 1 | 1][o]) f[x][o].push_back(j);
sort(f[x][o].begin(), f[x][o].end());
int tt = 0;
for(auto i: f[x][o]){
while(tt > 1 && cmp(q[tt].y - q[tt - 1].y, q[tt].x - q[tt - 1].x, i.y - q[tt].y, i.x - q[tt].x) == o) tt--;
q[++tt] = i;
} f[x][o].clear();
for(int i = 1; i <= tt; i++) f[x][o].push_back(q[i]);
}
}
int bs(int x, vec k){
int o = 1; k.x *= -1;
if(k.y < 0) k.x *= -1, k.y *= -1, o = 0;
int l = 0, r = f[x][o].size() - 1;
while(l < r){
int mid = l + r >> 1;
if(cmp(f[x][o][mid + 1].y - f[x][o][mid].y, f[x][o][mid + 1].x - f[x][o][mid].x, k.x, k.y) == o) r = mid;
else l = mid + 1;
}
return (1ll * f[x][o][l].x * -k.x + 1ll * f[x][o][l].y * k.y) * (o == 0? -1: 1);
}
void mdf(int x, int L, int R, int l, vec k){
if(L == R) return f[x][0].push_back(k), f[x][1].push_back(k), void();
int mid = L + R >> 1;
if(l <= mid) mdf(x << 1, L, mid, l, k);
else mdf(x << 1 | 1, mid + 1, R, l, k);
if(++sz[x] == R - L + 1) rec(x);
}
int qry(int x, int L, int R, int l, int r, vec k){
if(L >= l && R <= r) return bs(x, k);
int mid = L + R >> 1, ans = -1e18;
if(l <= mid) ans = max(ans, qry(x << 1, L, mid, l, r, k));
if(r > mid) ans = max(ans, qry(x << 1 | 1, mid + 1, R, l, r, k));
return ans;
}
} T;
signed main(){
ios::sync_with_stdio(0);
cin >> n >> tp;
for(int i = 1; i <= n; i++){
cin >> c >> x >> y;
if(c == 'A'){
if(tp != 'E') dec(x), dec(y);
T.mdf(1, 1, n, ++cnt, vec(x, y));
} else{
cin >> l >> r;
if(tp != 'E') dec(x), dec(y), dec(l), dec(r);
cout << (la = T.qry(1, 1, n, l, r, vec(x, y))) << '\n';
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 10
Accepted
time: 7ms
memory: 93548kb
input:
1000 A A -997373 6718 Q -121114 99459 1 1 Q 1205256654 1204870550 1204914797 1204914797 Q 474176630 474990439 474948979 474948979 Q 1167736388 1167866266 1167945251 1167945251 A -1405760629 1405187466 A 1405680792 1405140066 Q 1405473063 1405155544 1405194179 1405194177 Q 284397644 284474638 2845475...
output:
121463999084 -476266420878 -814875840990 -477483659326 184968141250 -310990847266 157821960426 4364672449 -14783970055 376576099060 322371162352 178699440066 358491051194 900433239392 179967524916 816523845656 371082799077 754551266092 309199972992 584988332168 963896585522 165473818671 35397133078 ...
result:
ok 339 lines
Test #2:
score: 10
Accepted
time: 8ms
memory: 93548kb
input:
1000 A A -989063 14611 A -752645 65987 A -405650 91582 A -473709 88243 A 249784 97045 A -949453 31440 A -164218 98836 A 17579 100187 A 996311 9345 Q 572217 82246 3 4 Q 897655856 898160720 898210166 898210170 Q 714527800 715084617 715002684 715002675 Q -501139152 500514589 500444835 500444841 A -1798...
output:
-224587572878 151038858042 573878578849 680932009379 -125053369872 330089121554 928390360051 912883393279 568293924345 941607429250 686808509620 135380147166 571609481280 211666387309 661879276896 70922198288 139877029970 197548216982 916990522282 289129714824 688438722786 814785193121 514574121564 ...
result:
ok 354 lines
Test #3:
score: 10
Accepted
time: 9ms
memory: 91496kb
input:
1000 A A -939769 34244 A 964713 26714 A 988651 15549 A 921761 39096 A 550277 83733 Q 124681 99427 3 4 A -257017166 257906973 Q -257664933 257865111 257934175 257934172 A 43869283 43638572 Q 43899655 43637550 43562692 43562692 A 563219279 563919390 A -564103842 563956912 A -563293044 563872420 A -563...
output:
124811985754 268479018691 144445290435 572999942673 190795614705 9723726855 316474357870 639268484591 354394388909 287822633415 608691607456 190403530315 673758077022 840784337078 474664605304 373408406757 579627375036 929019419741 611300739885 381095484363 315402097343 542300815512 372789694062 632...
result:
ok 329 lines
Test #4:
score: 10
Accepted
time: 243ms
memory: 141164kb
input:
400000 B A -999499 201 A -999499 203 A -999499 204 Q -234688 92208 1 3 A -513071819 513514065 A -513071819 513514066 A -513071819 513514067 Q -513242760 513466485 513514113 513514118 A -343162382 343637651 A -343162382 343637650 A -343162382 343637648 A -343162382 343637663 Q 343435491 343568030 343...
output:
234589231744 846452194887 -202287508212 771774774616 984879449642 -540636070075 989836516833 -997561260595 -770237326205 470546248936 -959064449034 -580771208507 -301494997029 699375269295 38170489130 -647638833732 780370098610 -442092736074 441830339054 -365664020678 -998776172908 305393807148 1554...
result:
ok 133825 lines
Test #5:
score: 10
Accepted
time: 234ms
memory: 128744kb
input:
300000 C A -999499 201 Q 616061 32302 1 1 Q -581108391 581865731 581946238 581946238 Q 184809349 185278141 185314875 185314875 A -628674369 628592576 A -628674369 628592577 A -628674369 628592583 A -628674369 628592581 A -628674369 628592602 A -628674369 628592601 A -628674369 628592606 Q 628667930 ...
output:
-615745860737 837703937594 -546979737846 -997128089444 576283551628 872883728232 -74984670150 994986233967 -976149839488 -970121172518 -78924214289 995449416994 -238688465350 945255532310 -803993548493 -818352582852 -292958480632 229908395880 629699742789 -109290711671 -587608062785 -925426763440 -7...
result:
ok 100040 lines
Test #6:
score: 10
Accepted
time: 245ms
memory: 128236kb
input:
300000 C A -999499 202 A -999499 203 Q 699717 66823 2 2 A -727628061 726792603 A -727628061 726792601 A -727628061 726792582 A -727628061 726792583 A -727628061 726792580 Q 727370609 726778898 726792528 726792529 A -1075351570 1075302542 A -1075351570 1075302540 Q 1075363893 1075308348 1075302489 10...
output:
-699352876714 -733364105125 -986748425507 -160736213422 -240915627846 905711784360 -515648495070 946313104851 973042221749 343152344732 -334517484473 -700997199178 987244545999 885810582865 -937123402172 8167423223 349846807647 723622199023 471903410925 685114441004 492620803910 -747582455109 996295...
result:
ok 100247 lines
Test #7:
score: 10
Accepted
time: 282ms
memory: 140652kb
input:
300000 D A 304662 95464 A 951846 31014 A 888365 46212 A -570224 82316 A 82039 99869 A -325758 94730 A -557573 83181 A 989099 15259 A -999468 1000 A 901834 43514 A 348861 93938 A 607552 79668 Q 466 100201 1 12 A 1454402931 1455230258 A -1454544966 1455270739 Q 1455268949 1455170282 1455269250 1455269...
output:
10045203843 10045531999 10045449960 10045696077 10044957726 10046270350 10044875687 10046844623 10044383453 10047336857 10049933068 10053265664 10049887416 10053539576 10049248288 10049065680 10054224356 10048082496 10054315660 10047964833 10055046092 10047729507 10055685220 10047454960 10056415652 ...
result:
ok 99846 lines
Test #8:
score: 10
Accepted
time: 230ms
memory: 125036kb
input:
200000 E A -532505 84813 A 900745 43740 Q 407 100201 2 2 A -322054 94857 Q 446 100201 2 3 A 22404 100178 A 989965 14679 A 460689 88984 Q 450 100201 4 5 Q 399 100201 1 4 A 764393 64736 Q 461 100201 2 7 Q 390 100201 1 5 A -213697 97881 Q 469 100201 2 3 A 801284 60097 Q 383 100201 7 7 Q 477 100201 1 4 ...
output:
4749394955 9361130173 10048017578 10046874974 10048264022 10046673338 9353722931 6779374455 10048622486 10046270066 9704985824 10045642754 9677621262 9735758192 9735971889 10049585858 9907875529 10050101150 10050145958 9722075862 9688958549 10044052070 9750075891 9964565438 9961807123 10040462402 99...
result:
ok 66577 lines
Test #9:
score: 10
Accepted
time: 358ms
memory: 142060kb
input:
300000 E A 194305 98306 A 190055 98389 A -995494 9143 A 731346 68456 A 626103 78216 A -340534 94207 A -995360 9291 Q 307 100201 3 5 A -387235 92379 Q 317 100201 1 7 A 373128 93000 A -993616 11033 Q 309 100201 2 9 A -599230 80222 A 42436 100114 Q 322 100201 1 8 A -359866 93483 Q 286 100201 9 11 Q 282...
output:
8029535037 9918923624 9917403184 9919873899 9425407608 9912271699 9922534669 755764801 10043150378 9004898174 9691007094 8653289803 10046840252 10047351542 10043577287 10042216786 9930326924 10043394317 10047755102 10043211347 10048370006 10042936892 10048751930 10042235507 10049473342 10041686597 8...
result:
ok 100035 lines
Test #10:
score: 10
Accepted
time: 396ms
memory: 142056kb
input:
300000 F A 996402 9246 A -991741 12634 A -619208 78685 Q 646 100201 2 3 A -1041581414 1041865790 Q 1041855974 1041821724 1041856369 1041856369 A 1213220534 1213868303 A -1213671003 1213979997 Q 1213935500 1213901417 1213934854 1213934854 A -1356348811 1355986214 Q 1356052416 1355952648 1356051811 13...
output:
7484307317 5508902144 5651019105 7467588701 7494214645 7170069458 7463873453 10046889291 7510314053 10047397807 10035829068 10047906323 9014880022 10052101580 1484443566 10029981134 10053245741 10008193186 10053499999 10056169708 9883405465 10003625926 7411859981 10067155464 10025023103 10059093675 ...
result:
ok 100275 lines