QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#339681 | #7771. 不是这一道据数构结题 | do_while_true | 0 | 602ms | 29124kb | C++20 | 3.0kb | 2024-02-27 19:52:29 | 2024-02-27 19:52:29 |
Judging History
answer
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<random>
#include<array>
#include<assert.h>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n'
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n'
#define DE(fmt,...) fprintf(stderr, "Line %d : " fmt "\n",__LINE__,##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef pair<int,ll>pil;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
r=0;bool w=0;char ch=getchar();
while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x,T2& ...y){read(x);read(y...);}
const int mod=998244353;
inline void cadd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
inline void cdel(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
inline int del(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
int qpow(int x,int y){
int s=1;
while(y){
if(y&1)s=1ll*s*x%mod;
x=1ll*x*x%mod;
y>>=1;
}
return s;
}
const int N=1000010;
int n,q;
int a[N],c[N],pos[N],pre[N];
ll ans[N];
vpii vecq[N];
signed main(){
#ifdef do_while_true
// assert(freopen("data.in","r",stdin));
// assert(freopen("data.out","w",stdout));
#endif
read(n,q);
for(int i=1;i<=n;i++)read(a[i]);
for(int i=1;i<=q;i++){
int l,r;read(l,r);
vecq[l].pb(mp(r,i));
}
for(int l=n;l>=1;l--){
pre[l]=a[l];
if(pre[l+1]<a[l]){
int p=n+1;
for(int i=l+1;i<=n;i++)
if(a[i]>a[l]){
p=i;
break;
}
pos[l]=p;
c[p]++;
}
else{
if(pre[l+1]==a[l]){
int o=pos[l+1]+1;
int p=n+1;
for(int i=o;i<=n;i++)
if(a[i]>a[l]){
p=i;
break;
}
pos[l]=p;
c[p]++;
}
else{
int R=n+1;
for(int i=l+1;i<=n;i++)
if(pre[i]<=a[l]){
R=i;
break;
}
for(int i=l+1;i<R;i++)
--c[pos[i]];
for(int i=l+1;i<R;i++)
++c[pos[i]=i];
if(pre[R]==a[l]){
int o=pos[R]+1;
int p=n+1;
for(int i=o;i<=n;i++)
if(a[i]>a[l]){
p=i;
break;
}
c[pos[l]=p]++;
}
else{
pos[R-1]=n+1;
pos[l]=R-1;
}
}
}
for(auto o:vecq[l]){
int r=o.fi,id=o.se,s=0;
for(int i=l;i<=r;i++)s+=c[i];
ans[id]=s;
}
}
for(int i=1;i<=q;i++)cout<<ans[i]<<'\n';
#ifdef do_while_true
// cerr<<'\n'<<"Time:"<<1.0*clock()/CLOCKS_PER_SEC*1000<<" ms"<<'\n';
#endif
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 13904kb
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:
62 88 16 7 9 1 52 20 0 9 46 8 3 12 6 32 10 84 2 51 34 0 43 63 43 19 3 28 39 23 49 49 30 17 31 36 33 7 52 38 15 2 9 3 38 83 43 7 1 34 16 77 13 57 17 56 45 8 65 37 15 75 47 50 10 29 77 6 4 63 33 18 4 33 27 35 40 2 7 17 12 15 33 56 60 47 27 9 7 16 22 60 47 0 35 44 1 22 5 0
result:
wrong answer 1st numbers differ - expected: '65', found: '62'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 13964kb
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:
35 26 51 26 41 28 0 16 24 36 9 39 34 7 47 26 48 26 33 53 10 2 34 11 52 21 49 57 10 58 49 26 5 27 24 3 27 49 14 15 56 27 23 50 49 4 4 51 8 27 9 11 26 23 26 15 27 52 28 18 6 44 41 2 43 31 57 51 27 22 45 15 19 27 16 4 12 1 2 35 2 15 65 42 21 7 14 14 59 9 14 26 46 41 31 44 48 24 10 54
result:
wrong answer 2nd numbers differ - expected: '27', found: '26'
Test #3:
score: 0
Wrong Answer
time: 0ms
memory: 14100kb
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:
1455 903 1094 249 2568 10 1174 323 1707 2217 621 46 1346 1447 633 2739 1016 824 629 601 984 1100 1126 1182 148 2253 972 980 631 1096 683 2312 1881 157 1150 1106 1671 780 726 2037 472 330 979 878 2080 5 1254 975 611 1044 1372 1498 1812 1154 1167 595 651 293 20 170 2600 1650 1970 1656 1035 1128 154 47...
result:
wrong answer 1st numbers differ - expected: '1464', found: '1455'
Test #4:
score: 0
Wrong Answer
time: 0ms
memory: 14096kb
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:
1075 879 1828 55 329 99 2417 574 1202 1583 477 1116 2740 1540 1245 56 1396 1040 821 265 456 861 243 1297 1818 276 222 1042 2441 1173 2454 420 796 75 364 845 872 1005 416 985 718 444 340 2525 379 1157 2685 252 23 206 1694 797 42 1076 333 2 3 113 1644 1870 684 734 69 401 2422 775 463 1286 2052 750 108...
result:
wrong answer 1st numbers differ - expected: '1079', found: '1075'
Test #5:
score: 0
Wrong Answer
time: 4ms
memory: 14036kb
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:
704 472 1002 1838 192 1481 1274 2301 82 1733 2235 298 256 852 1434 2480 1692 864 1634 332 1066 727 371 25 857 1507 1473 233 366 1477 89 774 172 164 951 1529 807 1214 135 1464 571 548 439 103 24 2104 1456 1251 1264 260 9 224 583 1434 1792 1895 172 954 1411 1292 570 501 1603 978 435 1561 648 2447 113 ...
result:
wrong answer 1st numbers differ - expected: '708', found: '704'
Test #6:
score: 0
Wrong Answer
time: 3ms
memory: 14096kb
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:
464 715 423 445 1167 1797 582 769 623 664 1072 877 2817 516 1179 291 2016 378 1917 1470 506 2126 466 1294 401 1175 350 488 404 922 1251 22 33 1684 289 1726 835 556 2521 215 857 984 702 713 3 2271 260 58 165 657 884 27 1046 2195 654 1211 428 1833 562 2185 890 1418 118 1899 1693 534 13 2136 2548 1376 ...
result:
wrong answer 1st numbers differ - expected: '467', found: '464'
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 14028kb
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:
1484 785 354 121 295 1004 778 338 651 371 1865 530 301 1479 2301 208 1098 1060 1364 893 1231 1827 1684 62 629 179 913 1712 738 724 298 344 1631 45 62 101 1679 1262 1954 904 1340 352 177 157 119 1851 1776 1224 132 363 763 1494 1631 330 218 56 1120 1635 846 1328 461 263 923 252 915 2225 1762 220 96 10...
result:
wrong answer 1st numbers differ - expected: '1486', found: '1484'
Test #8:
score: 0
Wrong Answer
time: 3ms
memory: 14024kb
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:
1578 102 34 1422 1136 1135 6 161 186 1874 488 1144 1416 1520 1 1445 291 621 740 657 2320 526 505 51 337 16 972 275 1041 13 48 1095 629 339 532 2096 628 234 104 81 719 724 1223 492 1631 1413 1780 590 210 155 109 2011 676 2385 1468 1975 721 548 1514 262 64 827 747 2591 826 1255 336 1952 2109 311 2142 ...
result:
wrong answer 1st numbers differ - expected: '1585', found: '1578'
Test #9:
score: 0
Wrong Answer
time: 6ms
memory: 14264kb
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:
2312 3596 3090 8530 190 956 792 3050 2030 2017 1535 2187 2824 763 5555 4424 1296 2060 252 3474 6749 2224 3439 80 8988 3653 6006 6240 592 6580 3461 5985 782 2669 4612 3813 6496 5402 5630 3381 8477 3396 4100 757 3375 2553 1634 448 3100 2311 6116 1225 6208 120 320 1888 2076 760 1640 952 6463 4071 538 2...
result:
wrong answer 1st numbers differ - expected: '2317', found: '2312'
Test #10:
score: 0
Wrong Answer
time: 0ms
memory: 14336kb
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:
2265 2646 436 7134 3423 86 4842 1482 1879 8432 6847 8564 4631 786 3688 245 3897 1322 236 5379 5852 7992 863 931 3319 9294 3505 5276 2642 4541 248 3219 179 7164 7697 2804 2139 338 6980 2386 4366 5377 3228 3580 5478 4811 1356 1051 2116 2859 1451 1480 1419 2597 1071 5958 2390 3952 3389 36 208 860 2759 ...
result:
wrong answer 1st numbers differ - expected: '2271', found: '2265'
Test #11:
score: 0
Wrong Answer
time: 6ms
memory: 14348kb
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:
3535 3486 6379 272 972 2113 803 3966 2802 8 248 1424 9057 2831 5786 4719 5135 4188 1817 2031 399 5447 6136 2811 4758 3123 23 2008 94 827 4162 4451 308 3863 8997 7821 2106 1765 7985 649 3277 1354 8569 1736 4743 5964 131 5240 3416 859 6262 842 1846 8025 1738 1698 1448 3914 4332 971 1339 3138 4964 4546...
result:
wrong answer 1st numbers differ - expected: '3540', found: '3535'
Test #12:
score: 0
Wrong Answer
time: 6ms
memory: 14276kb
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:
1089 1587 3513 1026 6203 8317 2858 5733 1093 2341 637 2482 467 1123 3818 6085 619 2972 3752 391 3681 3746 4697 6414 4522 8129 6118 411 1495 1251 1164 5089 393 4417 1595 6343 4453 3974 4616 5327 3839 1088 183 4341 9152 1897 9167 206 511 2404 2281 9304 2464 3196 1895 2253 5592 1244 1523 555 7391 2492 ...
result:
wrong answer 1st numbers differ - expected: '1097', found: '1089'
Test #13:
score: 0
Wrong Answer
time: 602ms
memory: 28680kb
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:
75079 92561 57618 28635 48914 56550 82962 66681 28313 166421 477 38940 118465 122064 50216 3055 79225 79198 13569 72980 45699 144199 30486 58336 162774 75571 74020 10823 4336 9715 140837 20894 52943 88384 63111 19333 118664 165361 112244 89808 57438 88378 122807 55224 102423 128208 134643 2805 13352...
result:
wrong answer 1st numbers differ - expected: '75089', found: '75079'
Test #14:
score: 0
Wrong Answer
time: 588ms
memory: 28692kb
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:
68592 42013 31637 94119 14374 59431 125002 172531 42648 96591 17550 140897 1159 174115 6108 9891 118425 85269 52884 20151 20148 9451 113413 187695 23792 82042 38162 84952 116336 22769 56579 55136 59216 34390 101143 44228 49096 34683 18436 3675 47373 13856 125993 60024 56185 7163 117291 132367 53655 ...
result:
wrong answer 1st numbers differ - expected: '68599', found: '68592'
Test #15:
score: 0
Wrong Answer
time: 588ms
memory: 26628kb
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:
40290 781 17308 4337 89976 20170 75786 134654 58687 21690 83914 48391 54806 119871 40553 150247 124746 14789 160800 97953 47889 107994 71579 16818 48002 10211 57937 179393 11848 2873 44394 49558 62152 25911 101982 531 23711 7900 13850 66710 69130 130904 4071 25229 7962 57616 145618 93851 82017 24645...
result:
wrong answer 1st numbers differ - expected: '40298', found: '40290'
Test #16:
score: 0
Wrong Answer
time: 588ms
memory: 29124kb
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:
10105 12789 38727 16166 198015 30966 25810 58758 27222 68595 7174 19903 76352 116019 80138 179181 101777 7810 7870 5175 87624 100472 59649 68155 157971 33922 27883 170215 35508 27222 51565 72317 61587 23412 94030 95343 53038 39923 164680 5885 52204 90661 125165 1894 74147 9311 139074 32561 51263 830...
result:
wrong answer 1st numbers differ - expected: '10114', found: '10105'
Test #17:
score: 0
Time Limit Exceeded
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:
result:
Test #18:
score: 0
Time Limit Exceeded
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:
result:
Test #19:
score: 0
Time Limit Exceeded
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:
result:
Test #20:
score: 0
Time Limit Exceeded
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...