QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#357506 | #3276. 出题高手 | edisnimorF | 0 | 577ms | 42104kb | C++14 | 1.9kb | 2024-03-18 22:04:25 | 2024-03-18 22:04:26 |
Judging History
answer
#include<bits/stdc++.h>
#define il inline
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define pii pair<int, int>
#define fr first
#define sc second
#define ll long long
#define mset(f, z) memset(f, z, sizeof(f))
#define mcpy(f, g) memcpy(f, g, sizeof(g))
using namespace std;
template<typename T=ll>
il T rd(){
T s=0; bool f=1; char c=getchar();
while(!isdigit(c)) f^=(c=='-'), c=getchar();
while(isdigit(c)) s=s*10+c-'0', c=getchar();
return f? s:-s;
}
template<typename T> il void ckmx(T &x, T y){if(x<y) x=y;}
template<typename T> il void ckmn(T &x, T y){if(y<x) x=y;}
char _begin;
#define int ll
const int N=5e5+5, M=705;
int n, m, a[N];
bool operator <(const pii &x, const pii &y){
return x.fr*y.sc<y.fr*x.sc;
}
vector<pii> q[N];
int B, bid, bel[N], lp[N], rp[N];
pii mx[N], bmx[M], ans[N];
char _end;
signed main(int argc, char *argv[]){
debug("%lfMB\n", (&_end-&_begin)/1024./1024.);
n=rd();
for(int i=1; i<=n; i++) a[i]=rd();
m=rd();
for(int i=1; i<=m; i++){
int l=rd(), r=rd();
q[r].push_back({l, i});
ans[i]={0, 1};
}
B=sqrt(n);
for(int i=1; i<=n; i++){
bid=bel[i]=(i-1)/B+1;
mx[i]={0, 1};
if(!lp[bid]) lp[bid]=i, bmx[bid]={0, 1};
rp[bid]=i;
}
//sweep
for(int i=1; i<=n; i++){
int sum=0;
for(int j=i; j>0 && i-j+1<=2000; j--){
sum+=a[j];
pii cur={sum*sum, i-j+1};
ckmx(mx[j], cur);
ckmx(bmx[bel[j]], cur);
}
for(auto [l, id]:q[i]){
for(int j=l; j<=i; j++) ckmx(ans[id], mx[j]);
// for(int j=bel[l]+1; j<bel[i]; j++) ckmx(ans[id], bmx[j]);
// for(int j=l; j<=min(rp[bel[l]], i); j++) ckmx(ans[id], mx[j]);
// if(bel[l]!=bel[i]) for(int j=lp[bel[i]]; j<=i; j++) ckmx(ans[id], mx[j]);
}
}
for(int i=1; i<=m; i++){
auto [a, b]=ans[i];
if(!a) puts("0 1");
else{
int gc=__gcd(a, b);
printf("%lld %lld\n", a/gc, b/gc);
}
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 28ms
memory: 26868kb
input:
2000 -113 314 -664 697 211 -199 -38 -190 8 -661 910 -811 -113 942 77 433 -261 -368 129 -525 968 -608 -21 38 -562 438 -935 -228 220 333 985 -430 916 586 764 476 794 664 383 503 206 -60 380 -130 -988 -904 -996 -304 -286 31 114 119 850 -942 714 -369 -842 250 -192 -462 -727 -427 -602 126 231 718 121 559...
output:
467262450 283 28590409 14 11142244 17 97259044 39 35892081 20 134560000 71 29127609 10 33744481 20 33744481 20 35916049 19 12460900 17 10719076 11 2122849 4 14938225 17 18020025 26 30228004 15 42458256 29 42237001 88 9065282 7 104076300 23 11249316 7 48594841 40 139877929 57 1836180 1 144216081 91 5...
result:
wrong answer 1st numbers differ - expected: '54826875', found: '467262450'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 229ms
memory: 26440kb
input:
100000 754 792 -680 426 425 347 481 -690 530 378 73 -907 -431 45 -530 -552 440 -890 -15 712 695 -679 -310 13 718 805 193 -291 -877 -74 -355 511 -679 -395 166 -710 -657 -19 874 26 832 507 854 -289 700 -404 472 -302 -977 8 -698 40 766 705 369 838 700 -964 552 -535 -75 -608 -181 -503 468 447 772 904 -2...
output:
649482416 177
result:
wrong answer 1st numbers differ - expected: '466344025', found: '649482416'
Subtask #3:
score: 0
Time Limit Exceeded
Test #11:
score: 0
Time Limit Exceeded
input:
500000 794 -75 -596 -322 -945 -908 -609 -164 488 626 -877 -710 140 -120 -475 -837 738 669 634 -643 -682 667 816 -785 -608 -836 -860 -932 242 70 -620 268 -121 288 209 -392 732 750 558 -480 565 327 -217 -891 767 211 -690 -66 813 -889 952 615 432 19 411 800 678 718 522 422 940 -510 -544 449 -357 640 40...
output:
result:
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 232ms
memory: 26476kb
input:
100000 -496 -233 354 -632 -196 177 -878 -255 -19 -636 685 -70 101 -975 -406 -988 -965 -205 563 -766 763 511 -116 -746 -129 14 106 928 -457 -257 -283 226 3 899 -359 -792 615 490 -57 986 -243 624 -239 931 -555 -821 -72 -611 -380 -397 248 -132 956 -195 -322 -231 319 -214 837 -379 -931 -301 -4 -673 280 ...
output:
4637065216 1999 362826304 331 766127041 548 758616849 521 803268964 233 305235841 118 323784036 479 377758096 299 341251729 285 7344100 23 699602500 431 181467841 178 61622500 97 295635987 115 34561298 17 75082225 144 17602475 16 430652552 217 11323225 19 37908649 74 206180881 267 24196561 15 116356...
result:
wrong answer 1st numbers differ - expected: '1352474176', found: '4637065216'
Subtask #5:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 577ms
memory: 42104kb
input:
100000 139 -485 -497 -818 254 169 -560 22 377 -67 -243 -75 743 -788 -676 -26 -775 371 576 -303 54 733 422 800 445 687 479 -16 -288 259 783 -586 912 616 439 -416 676 -555 172 659 501 -868 337 22 -60 260 603 -982 -149 466 769 -595 -117 949 -544 904 753 20 776 175 -888 937 -792 -647 -615 59 -298 452 -6...
output:
10301641009 1820 639988804 355 472149441 250 225480256 109 83350323 41 202557267 112 104878081 332 159769600 99 92874288 53 19474569 16 128391561 271 160985344 93 573219364 533 78397632 65 567535329 497 429303602 113 641153041 394 654489889 828 14394436 5 112954384 129 70812225 101 344139601 197 403...
result:
wrong answer 1st numbers differ - expected: '401594700', found: '10301641009'