QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61349 | #5025. 假期计划 | Minion | 0 | 3ms | 17988kb | C++23 | 2.5kb | 2022-11-12 14:47:12 | 2022-11-12 14:47:14 |
Judging History
answer
#include<cstdio>
#define fo(i,x,y) for(int i = x;i <= y;++i)
#define fd(i,x,y) for(int i = x;i >= y;--i)
#define _is 1048576 * 10
#define _os 1048576 * 10
#define gc() ib[++bi]
#define pc(ch) ob[++bo] = ch
#define ll long long
using namespace std;
char ib[_is],ob[_os];int bi = -1,bo = -1;
int rd()
{
int x = 0,sig = 0;char ch = gc();
while(ch < 48 || ch > 57) sig |= (ch == '-'),ch = gc();
while(ch >= 48 && ch <= 57) x = x * 10 + ch - 48,ch = gc();
return sig ? -x : x;
}
void pr(ll x)
{
if(x < 0) pc('-'),x = -x;
char ch[20];int w = -1;
if(x == 0) ch[++w] = 48;
while(x) ch[++w] = x % 10 + 48,x /= 10;
fd(i,w,0) pc(ch[i]);pc('\n');
}
int n,m,q,a[100010],b[100010],l1,l2,r1,r2;
int B[2][100010][17],lg[100010],N,A[4][100010][17];//0:+max 1:+min 2:-max 3:-min
ll max(ll x,ll y) {return x > y ? x : y;}
ll min(ll x,ll y) {return x < y ? x : y;}
ll ans = 0;
int Qa(int id,int l,int r)
{
int k = lg[r - l + 1];
if(id == 0 || id == 2) return max(A[id][l][k],A[id][r - (1 << k) + 1][k]);
else return min(A[id][l][k],A[id][r - (1 << k) + 1][k]);
}
int Qb(int id,int l,int r)
{
int k = lg[r - l + 1];
return (id == 0) ? max(B[id][l][k],B[id][r - (1 << k) + 1][k]) : min(B[id][l][k],B[id][r - (1 << k) + 1][k]);
}
void Mx(ll &x,ll y) {if(y > x) x = y;}
int main()
{
fread(ib,1,_is,stdin);
n = rd(),m = rd(),q = rd();
fo(i,1,n)
{
a[i] = rd();
if(a[i] >= 0) A[0][i][0] = A[1][i][0] = a[i],A[3][i][0] = 2147483647;
else A[2][i][0] = A[3][i][0] = -a[i],A[1][i][0] = 2147483647;
}
fo(i,1,m) B[0][i][0] = B[1][i][0] = b[i] = rd();
N = max(n,m);
fo(i,2,N) lg[i] = lg[i >> 1] + 1;
fo(j,1,lg[m]) fo(i,1,m - (1 << j) + 1)
{
B[0][i][j] = max(B[0][i][j - 1],B[0][i + (1 << j - 1)][j - 1]);
B[1][i][j] = min(B[1][i][j - 1],B[1][i + (1 << j - 1)][j - 1]);
}
fo(j,1,lg[n]) fo(i,1,n - (1 << j) + 1)
{
A[0][i][j] = max(A[0][i][j - 1],A[0][i + (1 << j - 1)][j - 1]);
A[1][i][j] = min(A[1][i][j - 1],A[1][i + (1 << j - 1)][j - 1]);
A[2][i][j] = max(A[2][i][j - 1],A[2][i + (1 << j - 1)][j - 1]);
A[3][i][j] = min(A[3][i][j - 1],A[3][i + (1 << j - 1)][j - 1]);
}
while(q--)
{
l1 = rd(),r1 = rd(),l2 = rd(),r2 = rd();
ll pmx = Qa(0,l1,r1),pmi = Qa(1,l1,r1),nmx = Qa(2,l1,r1),nmi = Qa(3,l1,r1);
ll bmx = Qb(0,l2,r2),bmi = Qb(1,l2,r2);
ans = -1000000000000000000ll;
if(pmx) Mx(ans,pmx * bmi);
if(pmi != 2147483647) Mx(ans,pmi * bmi);
if(nmx) Mx(ans,-nmx * bmx);
if(nmi != 2147483647) Mx(ans,-nmi * bmx);
pr(ans);
}
fwrite(ob,1,bo + 1,stdout);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 15620kb
input:
7 9 0 100 100 100 200 300 400 1 2 2 3 3 4 1 5 1 6 1 7 5 4 6 4 7 4
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 15620kb
input:
8 10 0 16 79 10 16 8 32 45 2 6 1 4 3 4 1 7 7 4 8 1 8 3 5 2 2 1 7 5
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Test #3:
score: 0
Wrong Answer
time: 3ms
memory: 13600kb
input:
10 15 0 17 11 4 12 27 10 28 20 15 7 10 9 8 4 6 6 3 2 1 8 1 7 8 4 9 3 9 7 1 3 7 10 8 3 2 7 9 8 5
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Test #4:
score: 0
Wrong Answer
time: 1ms
memory: 15644kb
input:
8 8 1 901 701 101 801 201 301 601 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 1
output:
1505
result:
wrong answer 1st numbers differ - expected: '2704', found: '1505'
Test #5:
score: 0
Runtime Error
input:
10 9 5 6 34 30 8 23 183 154 166 170 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
output:
result:
Test #6:
score: 0
Runtime Error
input:
20 19 10 8 54 38 10 19 9 60 34 46 39 44 39 34 29 61 309 270 294 300 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20
output:
result:
Test #7:
score: 0
Runtime Error
input:
15 20 20 104 118 198 206 93 189 202 146 70 209 116 139 84 224 11 1 1 3 6 2 3 9 9 2 2 5 3 8 2 3 9 10 5 3 10 6 13 14 7 10 9 7 10 1 9 8 12 13 8 11 7 11 9 4
output:
result:
Test #8:
score: 0
Runtime Error
input:
20 50 100 8 550 534 134 453 381 370 530 46 473 44 163 468 153 495 743 84 542 919 12 1 8 11 17 18 14 9 13 9 7 1 10 8 3 12 17 19 3 13 4 11 11 12 1 10 20 17 15 4 16 19 13 12 5 8 2 8 3 7 11 13 1 4 11 9 10 12 14 8 6 7 19 20 6 10 6 13 2 10 6 3 11 3 13 15 2 4 2 11 6 9 18 19 3 5 5 6 20 18 8 1 7 2 4 7 10 7 2...
output:
result:
Test #9:
score: 0
Wrong Answer
time: 1ms
memory: 15668kb
input:
150 280 0 404 472 438 356 213 705 88 338 46 377 710 697 300 99 579 119 708 314 116 76 473 402 331 678 471 227 528 384 599 473 189 557 391 673 287 710 498 623 572 183 517 247 489 160 500 738 685 156 298 73 493 119 620 674 371 161 612 140 21 231 10 610 517 175 144 667 295 346 409 319 354 323 582 583 4...
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Test #10:
score: 0
Wrong Answer
time: 1ms
memory: 13632kb
input:
300 760 0 464 142 318 86 813 165 178 458 406 17 620 67 300 609 39 839 108 254 746 556 383 72 361 288 411 557 18 114 809 113 369 647 181 793 677 830 408 263 632 333 457 457 219 130 80 18 295 66 298 703 613 629 320 764 191 191 792 380 381 561 130 580 457 775 684 697 715 16 439 709 294 233 432 343 97 5...
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Test #11:
score: 0
Wrong Answer
time: 1ms
memory: 15608kb
input:
300 1000 0 544 630 102 766 205 621 402 186 1014 769 740 427 548 457 87 79 172 422 338 804 63 592 617 456 987 357 562 1042 897 177 849 583 949 873 301 1030 128 327 56 845 657 185 891 810 560 346 207 362 482 7 533 549 592 356 551 255 544 716 677 777 418 300 793 871 276 1009 259 840 567 197 854 873 152...
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Test #12:
score: 0
Runtime Error
input:
300 300 100 194 302 38 196 143 195 308 158 46 287 230 287 220 29 309 309 208 294 176 56 173 262 71 48 31 237 148 264 69 113 229 7 111 83 177 310 28 203 22 283 17 77 179 60 60 108 5 296 188 193 103 109 210 134 1 181 82 50 101 231 270 30 207 75 64 187 125 86 149 39 194 243 132 213 227 5 168 146 83 132...
output:
result:
Test #13:
score: 0
Wrong Answer
time: 2ms
memory: 13648kb
input:
300 600 20 4 56 15 24 83 80 29 49 36 74 81 69 39 86 42 12 66 46 30 187 217 44 13 75 59 48 70 61 18 77 76 9 32 52 55 52 82 43 2 60 53 230 67 62 52 73 44 68 83 8 64 33 37 3 33 15 23 20 3 65 24 4 12 74 84 34 79 18 78 61 58 45 86 21 1 60 36 74 66 3 19 4 38 51 17 60 30 7 3 56 23 25 65 75 22 34 186 65 67 ...
output:
9344 86 66 2054 429 1190 516 975 3542 114 7410 16 8547 4000 55770 276 234 210 15652 4719
result:
wrong answer 1st numbers differ - expected: '820', found: '9344'
Test #14:
score: 0
Wrong Answer
time: 1ms
memory: 15692kb
input:
300 1000 31 44 32 14 5 120 59 74 2 90 78 142 26 33 44 28 107 99 50 139 53 148 85 102 143 105 100 89 2 145 92 100 1258 86 135 42 98 21 104 2 87 31 16 26 98 58 2 1 90 24 123 15 131 14 126 9 100 101 48 65 47 155 12 69 1479 43 109 138 69 94 21 3 90 84 153 152 45 143 100 133 114 87 10 61 50 78 2 135 137 ...
output:
9548 4158 141 96949 8208 6864 4830 11310 4575 12080 11929 9869 12035 11856 11778 170 304 6970 11778 11856 290 10132 6120 12920 3388 92 1368 0 5016 8424 5865
result:
wrong answer 1st numbers differ - expected: '5702', found: '9548'
Test #15:
score: 0
Wrong Answer
time: 1ms
memory: 15856kb
input:
1500 10000 0 17804 30922 31338 51806 11313 2805 46138 3938 41446 3077 13460 25147 30900 19749 45279 30719 49308 6914 41966 39076 16523 7752 1381 21528 24171 42977 51378 47934 18749 40073 17889 33107 16741 3973 20837 16310 48348 1223 39872 30033 217 24097 49239 29710 45200 39438 37435 11406 48298 524...
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Test #16:
score: 0
Wrong Answer
time: 1ms
memory: 15872kb
input:
2500 7500 0 10204 17222 38538 11606 55813 4805 67238 13738 5046 47077 14160 35247 44000 22249 58179 33519 58108 4914 7466 41776 46423 41052 2681 44528 12271 14477 29378 28434 53249 11973 5389 60807 65641 54773 52137 24810 32348 51623 54972 2733 67717 24697 14039 23710 17500 34338 23835 29206 59398 2...
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Test #17:
score: 0
Wrong Answer
time: 2ms
memory: 15872kb
input:
2500 10000 0 1252904 55929222 50172438 34136606 22456213 31819205 37421338 32972338 53136046 18220377 47373460 69616947 44800300 66374849 78701079 151119 27543708 74029814 53697866 8159076 7744223 44829152 75391081 193928 8332971 10016477 2371778 79157634 4003849 76401473 4645689 2377807 69501141 77...
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements
Test #18:
score: 0
Wrong Answer
time: 3ms
memory: 17912kb
input:
2000 10000 100 20344 9942 3958 31166 3333 16965 7178 34338 25326 13177 2580 20227 10940 7329 24679 34719 29788 13974 8026 22676 25583 11552 921 9528 31771 5597 578 21394 2489 22513 19689 23887 23701 36353 7397 12030 35408 33863 24432 13493 1857 6337 3019 25050 25840 28018 3655 4266 17658 6863 16573 ...
output:
109232 53929894 118914 11249580 868779 1510196 17605706 118914 93384 69234 17367064 6423285 119226 31796700 14310609 32047722 34128318 7634308 119226 4450000 27450744 119140 5206202 34235592 119226 1817184 119226 397420 15690957 31194445 30978365 158224 32628182 26833532 107454 293670 30229956 10256...
result:
wrong answer 1st numbers differ - expected: '158695', found: '109232'
Test #19:
score: 0
Wrong Answer
time: 1ms
memory: 17988kb
input:
2500 7500 100 3130 5489 1830 5334 6022 3914 6017 3626 4436 1107 64 1653 6233 1628 1566 1512 253 7285 6288 6431 4036 4253 3571 423 2032 3102 1997 4296 6772 6948 5505 1500 5557 119 4866 6043 103 7594 3611 3917 1103 4619 5884 239 504 1770 4469 3992 6512 717 4395 3622 2451 692 1149 7218 3375 4454 6707 2...
output:
9231600 3331872 1396344 808325 48412 1447761 220759 31835 7002 5652 7598 9025128 2018380 6500358 7122720 44417324 7182256 6306309 1118364 2055249 7582562 1731285 64083855 6700 6220764 6425380 3534 37996 9422229 2316336 79335648 1790826 1915 6224 384000 160384 37996 8657160 58931796 988512 168325 243...
result:
wrong answer 1st numbers differ - expected: '71832', found: '9231600'
Test #20:
score: 0
Runtime Error
input:
2500 10000 99 1252904 5929222 172438 4136606 2456213 1819205 7421338 2972338 3136046 8220377 7373460 9616947 4800300 6374849 8701079 151119 7543708 4029814 3697866 8159076 7744223 4829152 5391081 193928 8332971 16477 2371778 9157634 4003849 6401473 4645689 2377807 9501141 7502673 3460037 1943710 346...