QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#335653 | #7771. 不是这一道据数构结题 | linrui | 0 | 1279ms | 192232kb | C++14 | 2.7kb | 2024-02-23 18:30:34 | 2024-02-23 18:30:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using u64=unsigned long long;
using u32=unsigned;
using i128=__int128;
using lf=long double;
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define F(i,l,r) for(int i=l,R_F=r;i<=R_F;++i)
#define G(i,r,l) for(int i=r,L_F=l;i>=L_F;--i)
#define il inline
#define ct const
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define CUT dbg("**********\n")
//ct int INF=1.02e9;
ct ll INF=4e18L;
ct lf PI=acos(-1L),EPS=1e-9L;
il int dcmp(lf x){return fabs(x)<=EPS?0:(x<0?-1:1);}
template<class T>
il void tomx(T&x,T y){x<y?x=y,0:0;}
template<class T>
il void tomn(T&x,T y){y<x?x=y,0:0;}
ct ll P=998244353;
il ll qpow(ll x,ll y){
ll r=1;for(;y;y>>=1,x=x*x%P)y&1?(r=r*x%P):0;return r;
}
il ll inv(ll x){return qpow(x,P-2);}
il void add(int&x,int y){x+=y,x-=(x>=P)*P;}
ct int N=1000500;
class BIT{
int d[N];
public:
void init(){
// dbg("BIT.init()\n");
memset(d,0,sizeof(d));
}
int qry(int i){
// dbg("BIT.qry(%d)=",i);
int x=0;for(;i;i-=(i&-i))x+=d[i];
// dbg("%d\n",x);
return x;
}
int kth(int k){
int i=0;
G(j,20,0){
int x=i+(1<<j);
if(x<N&&k>d[x])
i=x,k-=d[x];
}return i+1;
}
// void wt(){
// F(i,1,10)dbg("%d ",qry(i));
// dbg("\n");
// }
void upd(int i,int x){
// dbg("BIT.upd(%d,%d)\n",i,x);
for(;i<N;i+=(i&-i))d[i]+=x;
// wt();
}
}sol;
int n,q,a[N],pre[N],nxt[N],ans[N],top,st[N];
vector<int>idx[N];
struct Pnt{int r,x;};vector<Pnt>pnt[N];
struct Qry{int r,i;};vector<Qry>qr[N];
int main(){
#ifdef LOCAL
freopen("QOJ7771.in","r",stdin);
// freopen(".out","w",stdout);
#endif
scanf("%d%d",&n,&q);
F(i,1,n)scanf("%d",a+i),idx[a[i]].pb(i);
a[0]=a[n+1]=0,st[top=1]=0;
F(i,1,n){
while(a[st[top]]>=a[i])--top;
pre[i]=st[top],st[++top]=i;
}st[top=1]=n+1;
G(i,n,1){
while(a[st[top]]>=a[i])--top;
nxt[i]=st[top],st[++top]=i;
}sol.init();
// CUT;
// F(i,1,n)dbg("%d ",pre[i]);
// dbg("\n");
// F(i,1,n)dbg("%d ",nxt[i]);
// dbg("\n");
// CUT;
G(x,n,1){
F(pos,0,(int)idx[x].size()-1){
int i=idx[x][pos],l=pre[i],r=nxt[i];
pnt[i].pb(Pnt{i,1});
// dbg("x=%d,Pnt=%d %d %d\n",x,i,i,1);
pnt[l].pb(Pnt{i,-1});
// dbg("x=%d,Pnt=%d %d %d\n",x,l,i,-1);
int cnt=lower_bound(idx[x].begin(),idx[x].end(),r)-idx[x].begin()-pos;
int j=sol.kth(sol.qry(r)+cnt);
pnt[i].pb(Pnt{j,-1});
// dbg("x=%d,Pnt=%d %d %d\n",x,i,j,-1);
}
for(int i:idx[x])
sol.upd(i,1);
}
F(i,1,q){
int l,r;scanf("%d%d",&l,&r);
qr[l].pb(Qry{r,i}),ans[i]=r-l+1;
}sol.init();
G(l,n,1){
for(Pnt x:pnt[l])
sol.upd(x.r,x.x);
for(Qry x:qr[l])
ans[x.i]-=sol.qry(x.r);
}
F(i,1,q)printf("%d\n",ans[i]);
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 12ms
memory: 89560kb
input:
100 100 57 39 73 88 98 3 54 10 63 31 96 22 94 53 99 66 7 90 29 27 91 37 74 4 64 43 86 100 12 58 78 97 75 87 36 51 40 20 48 92 26 72 89 85 46 13 55 80 6 47 41 17 30 25 60 35 93 28 69 16 83 23 1 34 56 45 18 21 38 11 68 71 8 2 84 76 15 33 44 81 77 82 70 24 67 95 61 9 32 49 50 65 19 59 5 42 14 62 52 79 ...
output:
117 169 25 8 15 1 100 35 0 17 85 12 4 18 6 61 15 161 2 98 63 0 80 120 77 34 3 50 72 41 90 94 55 28 60 64 64 10 98 66 25 2 16 3 70 160 79 8 1 55 26 143 24 104 32 106 79 13 124 69 23 146 81 98 14 47 148 8 4 119 66 31 4 58 50 67 69 2 10 29 19 27 63 106 118 85 56 13 9 26 36 117 90 0 70 81 1 40 7 0
result:
wrong answer 1st numbers differ - expected: '65', found: '117'
Test #2:
score: 0
Wrong Answer
time: 4ms
memory: 89488kb
input:
100 100 2 3 1 3 3 8 1 1 1 3 2 3 2 75 1 44 78 3 3 65 2 1 3 3 90 2 1 1 1 2 2 2 1 2 9 3 24 1 2 1 89 2 2 42 2 66 1 1 19 25 3 2 3 2 3 51 1 1 3 1 3 29 21 2 2 2 1 2 1 3 3 2 84 2 1 11 2 2 3 2 9 1 1 1 1 99 48 1 77 3 9 78 69 1 2 1 1 2 1 2 21 68 41 76 9 76 7 43 30 81 45 84 81 83 23 45 57 91 17 65 72 81 39 91 3...
output:
58 48 97 48 72 51 0 25 44 61 10 73 61 10 90 48 85 49 59 100 14 3 63 19 99 39 90 111 16 110 95 48 5 48 44 4 49 94 24 23 105 50 39 94 92 6 6 91 12 47 11 16 45 42 49 23 48 97 45 29 7 80 74 2 77 61 106 94 51 35 80 21 32 47 26 5 16 1 2 64 2 23 123 78 33 11 19 23 114 13 19 46 88 75 52 84 88 42 12 103
result:
wrong answer 1st numbers differ - expected: '35', found: '58'
Test #3:
score: 0
Wrong Answer
time: 7ms
memory: 83732kb
input:
3000 3000 82 1139 2770 344 363 880 427 2001 207 2969 1309 2063 2349 1817 1869 2724 2380 1887 1377 1422 1732 449 2105 1706 1155 2417 963 308 1996 2788 737 1963 1973 1163 2899 2438 760 1995 1435 1750 1947 2863 1606 1078 493 2922 1478 607 1871 2191 2978 2587 1699 332 1581 2048 68 350 2220 1306 1633 187...
output:
2905 1791 2183 491 5120 15 2332 642 3400 4431 1238 79 2682 2883 1259 5471 2022 1640 1253 1192 1961 2190 2238 2353 287 4492 1933 1958 1258 2189 1355 4612 3762 310 2292 2208 3337 1551 1444 4061 937 642 1947 1754 4151 5 2500 1943 1212 2074 2734 2990 3617 2297 2316 1184 1296 578 36 326 5184 3296 3936 33...
result:
wrong answer 1st numbers differ - expected: '1464', found: '2905'
Test #4:
score: 0
Wrong Answer
time: 11ms
memory: 85768kb
input:
3000 3000 2120 271 658 684 1092 795 2522 2924 2204 382 709 1351 2977 1639 1190 2472 458 1337 1034 566 2644 664 1224 1410 1820 625 2203 2045 1979 2297 2926 1238 2014 1492 1372 2594 1324 1854 1968 1074 919 2345 1544 1880 626 2505 1742 1427 2892 99 447 1732 2273 2490 1166 2419 2717 1248 2493 1048 2291 ...
output:
2141 1749 3645 97 650 191 4820 1141 2388 3157 945 2219 5461 3073 2472 104 2781 2073 1638 519 899 1713 487 2579 3623 547 434 2074 4868 2333 4902 828 1578 140 720 1679 1732 1996 820 1957 1430 878 673 5036 740 2304 5362 499 42 406 3380 1588 78 2143 657 2 3 221 3279 3726 1361 1462 126 796 4834 1545 913 ...
result:
wrong answer 1st numbers differ - expected: '1079', found: '2141'
Test #5:
score: 0
Wrong Answer
time: 13ms
memory: 89840kb
input:
3000 3000 2637 1681 2145 1131 33 618 2714 914 2587 2182 1823 1044 1320 2020 568 2 411 902 523 2075 910 459 124 669 1546 2593 1314 312 2736 1408 1578 28 291 1017 421 798 2202 978 597 2246 1349 1486 2756 2464 1912 636 1130 201 648 882 2737 2066 2007 1758 91 2923 49 1288 2254 776 2814 1315 1665 2306 25...
output:
1398 939 1999 3662 375 2949 2542 4584 162 3463 4457 591 501 1692 2853 4954 3376 1721 3257 652 2124 1445 728 46 1708 3002 2937 455 726 2946 170 1537 338 325 1894 3048 1604 2419 260 2918 1128 1085 872 201 46 4192 2900 2499 2516 516 14 438 1155 2859 3578 3776 335 1897 2816 2580 1131 996 3202 1950 860 3...
result:
wrong answer 1st numbers differ - expected: '708', found: '1398'
Test #6:
score: 0
Wrong Answer
time: 23ms
memory: 87720kb
input:
3000 3000 15 64 32 83 23 22 48 7 68 36 43 75 29 17 37 97 92 42 50 87 73 43 12 48 83 44 1 13 23 96 48 60 99 26 2 104 73 73 64 61 64 49 67 94 89 9 96 102 66 19 95 2 29 78 102 61 77 84 34 92 36 31 44 25 68 47 137 131 75 37 21 173 62 44 36 53 19 165 98 100 95 57 85 32 87 69 118 85 24 35 36 98 47 44 92 2...
output:
927 1425 835 882 2326 3588 1154 1530 1241 1325 2141 1745 5625 1022 2346 577 4027 750 3828 2926 1007 4236 927 2585 799 2341 695 975 801 1831 2494 36 63 3364 570 3447 1662 1108 5041 423 1704 1959 1397 1416 6 4535 514 108 322 1311 1758 49 2080 4382 1296 2413 853 3656 1115 4363 1773 2828 226 3788 3373 1...
result:
wrong answer 1st numbers differ - expected: '467', found: '927'
Test #7:
score: 0
Wrong Answer
time: 8ms
memory: 89692kb
input:
3000 3000 96 48 34 1 27 93 76 3 38 26 79 74 25 95 34 37 5 26 54 37 62 22 17 3 53 34 10 132 64 91 53 34 74 92 64 3 103 38 74 40 31 38 63 12 84 84 80 5 88 22 51 66 28 158 16 31 26 53 47 22 66 89 7 65 91 49 62 73 26 54 13 33 28 45 48 90 91 46 37 34 53 69 70 52 62 71 56 190 154 72 25 6 17 196 66 39 80 5...
output:
2961 1565 703 236 584 2006 1542 668 1297 737 3719 1041 596 2948 4590 408 2187 2114 2722 1777 2456 3642 3354 118 1250 356 1818 3418 1471 1437 589 680 3254 86 118 202 3353 2514 3904 1799 2675 699 346 302 224 3693 3549 2443 259 719 1521 2980 3252 656 428 104 2237 3263 1687 2650 916 519 1833 494 1820 44...
result:
wrong answer 1st numbers differ - expected: '1486', found: '2961'
Test #8:
score: 0
Wrong Answer
time: 4ms
memory: 87652kb
input:
3000 3000 24 75 55 19 9 74 4 22 81 77 75 46 60 50 19 50 1 41 8 63 4 47 93 24 105 16 28 76 18 96 1 68 46 80 41 83 78 36 88 45 83 54 67 46 94 99 44 61 14 50 143 97 95 78 8 92 36 59 95 26 67 23 26 95 77 92 98 13 63 149 129 61 74 39 38 55 15 90 48 3 37 39 100 77 18 10 19 10 20 77 71 46 65 84 46 7 175 81...
output:
3149 199 55 2836 2266 2264 10 319 366 3741 962 2281 2822 3031 1 2880 574 1236 1469 1307 4635 1051 1003 94 670 30 1936 542 2075 20 90 2185 1248 666 1056 4189 1249 460 199 156 1438 1440 2440 978 3256 2815 3551 1167 398 298 210 4017 1346 4761 2932 3934 1435 1088 3018 518 118 1640 1486 5177 1644 2502 66...
result:
wrong answer 1st numbers differ - expected: '1585', found: '3149'
Test #9:
score: 0
Wrong Answer
time: 11ms
memory: 88284kb
input:
10000 10000 1225 3839 1022 812 2195 8154 9848 3399 6401 5375 4192 5933 7758 9460 5569 6817 1504 104 7537 509 3830 3790 686 416 5452 4214 2651 2825 5881 4373 2118 8244 8803 5866 1737 5206 3037 4862 5976 2871 9541 6867 2024 8451 7815 1083 5523 8874 1745 828 8022 5706 3404 651 4212 8126 2555 6660 5481 ...
output:
4607 7174 6168 17049 375 1901 1581 6094 4050 4027 3055 4367 5643 1523 11095 8836 2584 4110 497 6928 13482 4431 6867 154 17957 7294 12000 12461 1171 13142 6907 11951 1552 5328 9207 7615 12984 10795 11241 6752 16944 6780 8188 1499 6736 5093 3257 882 6199 4616 12213 2442 12403 229 632 3775 4141 1507 32...
result:
wrong answer 1st numbers differ - expected: '2317', found: '4607'
Test #10:
score: 0
Wrong Answer
time: 19ms
memory: 90348kb
input:
10000 10000 4293 5943 4058 5440 7413 5250 1171 9947 4399 9939 5300 6419 5446 2275 8834 6841 1566 3814 2298 5294 8131 603 2736 4135 946 7071 3233 6196 6458 5162 8229 3087 227 828 7544 3423 7594 4496 8790 4052 8704 3088 7330 7269 5010 9400 9399 3819 302 4258 2985 3323 6455 5755 7489 321 501 3299 2026 ...
output:
4522 5283 869 14252 6837 165 9662 2958 3743 16849 13690 17115 9255 1566 7360 485 7785 2635 457 10741 11688 15972 1717 1858 6634 18576 7001 10531 5283 9077 484 6431 353 14311 15374 5600 4270 665 13937 4766 8726 10744 6449 7163 10943 9607 2714 2096 4223 5708 2886 2950 2827 5189 2135 11893 4771 7896 67...
result:
wrong answer 1st numbers differ - expected: '2271', found: '4522'
Test #11:
score: 0
Wrong Answer
time: 28ms
memory: 88048kb
input:
10000 10000 7 178 96 109 117 3 170 302 209 84 248 310 97 70 222 255 276 127 233 219 109 282 8 182 20 128 75 158 39 214 102 260 13 80 276 221 271 319 129 110 72 89 254 45 34 322 310 299 305 32 93 224 5 261 126 140 311 81 100 72 328 312 42 16 231 146 72 238 178 178 179 226 314 152 167 202 295 258 15 2...
output:
7060 6965 12750 533 1936 4221 1598 7915 5598 11 491 2841 18112 5654 11560 9423 10258 8359 3623 4050 790 10884 12262 5614 9507 6228 37 4001 179 1646 8316 8890 613 7715 17987 15631 4200 3524 15963 1292 6544 2699 17134 3464 9475 11922 260 10472 6822 1712 12518 1681 3679 16044 3469 3388 2887 7820 8652 1...
result:
wrong answer 1st numbers differ - expected: '3540', found: '7060'
Test #12:
score: 0
Wrong Answer
time: 11ms
memory: 82084kb
input:
10000 10000 3 31 195 326 322 174 300 177 87 56 74 14 39 240 134 249 176 187 87 118 177 304 269 44 128 328 112 121 96 93 140 163 209 271 29 296 232 309 228 183 238 100 66 118 204 90 156 45 204 126 232 68 318 327 5 3 153 331 180 62 308 172 175 142 88 318 236 75 276 251 67 218 28 118 141 257 65 151 183...
output:
2177 3159 7006 2045 12403 16631 5710 11458 2182 4674 1271 4953 926 2234 7625 12165 1232 5931 7498 772 7358 7483 9389 12808 9038 16254 12222 818 2978 2500 2318 10168 781 8830 3186 12670 8903 7940 9225 10641 7663 2178 358 8676 18298 3785 18330 405 1012 4805 4555 18601 4922 6391 3781 4500 11171 2485 30...
result:
wrong answer 1st numbers differ - expected: '1097', found: '2177'
Test #13:
score: 0
Wrong Answer
time: 207ms
memory: 101224kb
input:
200000 200000 120536 165588 195015 67563 60504 93355 188680 98879 30412 35909 162690 193085 79065 58869 51576 146413 166618 182838 56146 110147 142857 111033 186246 180779 63081 24777 52683 191278 98735 11504 115999 116939 157422 109468 175004 10755 112531 71163 35398 71262 141229 231 123311 168965 ...
output:
150145 185114 115222 57252 97813 113087 165916 133349 56610 332826 948 77864 236910 244107 100424 6094 158431 158370 27123 145941 91387 288377 60968 116664 325536 151123 148025 21630 8668 19414 281650 41782 105876 176760 126205 38657 237297 330700 224471 179605 114862 176740 245610 110434 204839 256...
result:
wrong answer 1st numbers differ - expected: '75089', found: '150145'
Test #14:
score: 0
Wrong Answer
time: 216ms
memory: 108328kb
input:
200000 200000 5203 2776 2051 83 5255 4479 6328 3395 5764 3079 4020 4235 31 62 2282 1983 4052 5141 6514 108 45 84 2874 2225 5833 2277 5069 777 3458 4312 6577 1083 18 6003 4773 1935 2908 91 843 5317 6643 103 5581 113 6234 3738 144 3953 1234 396 4543 3518 5508 1833 1674 1446 1134 6455 4343 558 658 3664...
output:
137170 84019 63273 188238 28741 118840 249982 345058 85287 193180 35088 281789 2311 348222 12213 19776 236842 170530 105759 40294 40283 18885 226815 375382 47574 164073 76317 169892 232659 45538 113153 110266 118429 68768 202277 88452 98190 69373 36869 7334 94730 27703 251977 120041 112360 14318 234...
result:
wrong answer 1st numbers differ - expected: '68599', found: '137170'
Test #15:
score: 0
Wrong Answer
time: 183ms
memory: 102256kb
input:
200000 200000 5102 3159 748 5427 621 5896 499 5528 1847 6008 961 3084 1541 3370 3477 6551 3122 34 60 5045 1000 2091 119 35 345 92 47 6200 2305 611 27 20 4462 37 1192 108 5020 6490 5834 2997 6615 4662 102 4466 3073 634 2393 278 6122 6451 4679 4161 2316 2074 4859 782 3340 3997 6350 6659 4747 2199 5225...
output:
80570 1556 34612 8670 179947 40337 151563 269297 117363 43376 167824 96779 109606 239737 81102 300493 249477 29566 321591 195893 95771 215978 143154 33624 95994 20414 115870 358775 23694 5739 88780 99109 124297 51816 203954 1058 47413 15788 27693 133413 138244 261801 8139 50450 15912 115225 291226 1...
result:
wrong answer 1st numbers differ - expected: '40298', found: '80570'
Test #16:
score: 0
Wrong Answer
time: 169ms
memory: 102252kb
input:
200000 200000 5620 4596 1787 1569 11 3679 57 5561 1635 5384 5280 71 127 4084 4074 4 3533 4939 5115 96 336 75 3997 951 133 6410 4574 3466 3102 534 6321 107 2300 2531 5426 73 20 12 101 607 10 4424 5847 134 6212 862 855 5070 77 91 2010 4014 4678 4050 3695 3451 2790 4235 2235 5998 6354 5149 4794 4789 40...
output:
20208 25573 77438 32318 396019 61927 51617 117513 54441 137179 14338 39805 152697 232031 160270 358353 203545 15611 15730 10339 175236 200938 119285 136305 315942 67832 55769 340425 71010 54430 103120 144629 123167 46818 188055 190675 106075 79841 329349 11760 104403 181315 250323 3782 148277 18618 ...
result:
wrong answer 1st numbers differ - expected: '10114', found: '20208'
Test #17:
score: 0
Wrong Answer
time: 1279ms
memory: 192232kb
input:
1000000 1000000 87382 651796 951220 648926 497665 375383 228684 303780 166986 89826 91242 258504 374341 653338 160191 648153 603954 860894 376629 474180 967487 270337 3022 832849 628198 269953 992793 314447 701562 440916 559722 134912 67124 636002 748016 771119 200861 655997 618755 558 882633 709234...
output:
802748 230147 1387859 811816 1483059 185230 400944 165481 302751 455974 603092 1020872 68461 257170 630003 1007987 1432153 92187 290080 1089690 237792 291091 826052 1193473 201681 101755 1767575 360360 623642 834389 1302936 377144 140851 244459 552284 208448 300101 1466341 670628 1218354 103736 1814...
result:
wrong answer 1st numbers differ - expected: '401390', found: '802748'
Test #18:
score: 0
Wrong Answer
time: 1219ms
memory: 169980kb
input:
1000000 1000000 3228 19 1838 21 15231 54 27226 18805 16744 57 25133 23568 27304 24323 9187 89 14287 13412 20542 21860 23602 65 1 32705 27 20439 19966 70 7865 13967 127 30379 34 95 12820 8224 14188 32692 93 29481 28113 14591 119 7443 2802 6678 51 6838 88 74 7855 95 775 11917 104 18776 34 22985 32134 ...
output:
1203510 175929 1087233 296392 244478 171615 16296 362740 27795 388443 426632 278843 346277 997208 536748 1191594 814140 295257 214033 28260 691040 321909 151528 1222044 217662 527183 22119 1034238 1090985 1415573 575886 53186 1279640 8903 494014 853952 278287 43690 715495 594403 1391498 187440 11433...
result:
wrong answer 1st numbers differ - expected: '601769', found: '1203510'
Test #19:
score: 0
Wrong Answer
time: 1245ms
memory: 169904kb
input:
1000000 1000000 13910 7760 24228 1793 79 14626 44 10663 25005 56 4240 15833 3609 19816 13269 28175 8807 67 1480 27123 69 12868 11829 3 18390 5510 58 28157 26708 17269 10176 14025 41 7746 12814 9220 24534 115 12446 51 6256 21293 28779 6845 31048 19928 19877 13972 13317 7203 9974 13131 133 13 5348 166...
output:
299789 1252081 1184526 209293 360058 1331428 264982 1581136 636637 222854 54434 354864 637773 404202 1045811 500131 532091 612305 1739362 680547 86837 1380110 981015 297065 1117439 656798 881024 1335524 1348303 654796 241871 502765 953454 633162 1596106 510045 614888 1618355 318354 292995 1385234 90...
result:
wrong answer 1st numbers differ - expected: '149909', found: '299789'
Test #20:
score: 0
Wrong Answer
time: 1212ms
memory: 169824kb
input:
1000000 1000000 15899 2139 32955 19636 21943 29782 28207 9095 20266 68 15471 14533 17782 21804 31540 21751 19168 15466 19302 34 24617 3544 66 31466 31516 3341 30147 6947 26716 135 11544 50 30167 5 11 7820 149 5146 32617 20175 23019 23260 8830 16538 88 2357 22200 21845 2144 12436 104 31 24930 10455 1...
output:
254709 1244794 177912 700195 124099 441607 937607 738667 1393235 454047 388987 1541072 1397084 655686 116047 344087 38514 162980 22388 897227 1243439 1148046 597922 1711924 42223 1064711 1865092 480513 513587 1310482 193308 560108 1280719 383799 656721 700469 845256 492036 1563235 305675 223674 1065...
result:
wrong answer 1st numbers differ - expected: '127368', found: '254709'