QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#744243 | #7492. 即便看不到未来 | TheZone | 0 | 2635ms | 158340kb | C++20 | 1.8kb | 2024-11-13 21:18:08 | 2024-11-13 21:18:08 |
Judging History
answer
#include<bits/stdc++.h>
#define N 1000050
using namespace std;
#define lowbit(x) (x & -x)
struct TT {
int t[N];
void update(int x, int y) {
for(; x; x -= lowbit(x)) t[x] += y;
}
int query(int x) {
int ret = 0;
for(; x < N; x += lowbit(x)) ret += t[x];
return ret;
}
} t[13];
struct Q {
int l, id;
} ;
vector<Q> q[N];
int pre[N], a[N], n, m, id[N], vis[N], ans[N][13];
int cmp(int x, int y) {
return pre[x] > pre[y];
}
int main() {
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i ++) scanf("%d", &a[i]);
for(int i = 1; i <= m; i ++) {
int l, r;
scanf("%d%d", &l, &r);
q[r].push_back((Q){l, i});
}
for(int r = 1; r <= n; r ++) {
int ll = max(1, a[r] - 11), rr = a[r] + 11, gs = 0;
for(int i = ll; i <= rr; i ++) if(pre[i] >= pre[a[r]]) id[++ gs] = i;
sort(id + 1, id + 1 + gs, cmp);
t[1].update(r, 1), t[1].update(pre[id[1]], -1);
int L = 0, R = 0;
for(int i = 1; i < gs; i ++) {
vis[id[i]] = 1;
while(vis[a[r] - L - 1]) L ++;
while(vis[a[r] + R + 1]) R ++;
int U = min(L + R + 1, 11);
t[L].update(pre[id[i]], -1), t[L].update(pre[id[i + 1]], 1);
t[R].update(pre[id[i]], -1), t[R].update(pre[id[i + 1]], 1);
t[U].update(pre[id[i]], 1), t[U].update(pre[id[i + 1]], -1);
}
for(int i = ll; i <= rr; i ++) vis[i] = 0;
for(int i = 0; i < q[r].size(); i ++)
for(int j = 1; j <= 10; j ++)
ans[q[r][i].id][j] = t[j].query(q[r][i].l);
pre[a[r]] = r;
}
for(int i = 1; i <= m; i ++) {
for(int j = 1; j <= 10; j ++) printf("%d", ans[i][j] % 10); printf("\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Pretests
Final Tests
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 18432kb
input:
1000 1000 187 934 698 342 646 531 883 803 296 794 297 882 981 92 491 416 273 530 685 53 159 588 606 239 970 803 835 437 976 136 474 788 570 602 648 310 470 796 356 182 141 236 98 517 333 542 353 337 592 63 533 840 955 650 797 785 448 462 982 19 980 318 918 268 362 864 842 756 382 215 841 311 939 953...
output:
0521000000 1442100000 6916310000 1582200000 2742100000 6412000000 0673200000 4400000000 4310000000 5550000000 6283000000 5156140100 4912913121 4111100000 4940000000 9903822111 0236350010 5300000000 9141622111 2100000000 0351341000 8720000000 0710000000 2217100000 5106913200 3000000000 3211000000 940...
result:
FAIL Expected integer, but "0521000000" found (/var/uoj_data/7492/1.out)
Test #2:
score: 0
Wrong Answer
time: 18ms
memory: 19460kb
input:
10000 10000 986 168 918 5602 824 3521 1101 4690 1660 2533 1395 7132 1395 7172 1886 3719 2240 7488 7117 2240 6009 2193 2462 3242 6377 1042 5397 9656 3917 8066 5900 3636 1127 2884 5389 7324 9422 6831 8074 7472 8619 6159 9382 3701 2990 1490 2410 4949 8919 4860 4209 2124 4734 7411 3307 7580 9051 1908 31...
output:
6020000000 3920000000 2561721000 5271830100 6634444232 9015293100 6196130010 5106410000 3451547420 3700000000 9507041200 8026727311 7207410000 1866551000 4441000000 4918810330 0830000000 1504092397 9214100000 6956200000 8630000000 7857100000 7843420402 0430000000 4045100000 4943410000 1934599053 083...
result:
FAIL Expected integer, but "0830000000" found (/var/uoj_data/7492/2.out)
Test #3:
score: 0
Wrong Answer
time: 38ms
memory: 21428kb
input:
30000 30000 7073 5645 1931 1295 24911 27524 29393 21487 26699 29537 28588 23369 21505 11807 9491 29907 29233 12657 29967 22120 24143 20811 11136 6904 29412 19335 26534 14693 26379 21874 3016 18295 23701 14076 12817 27977 24582 76 18030 5386 26997 23545 23233 11597 19040 9713 11361 22041 17126 21318 ...
output:
5116000000 3810000000 3478156300 0221640010 1306891862 3975440792 2220000000 7942182945 2121100000 5211000000 1298810000 9468427040 2483000000 2672000000 9400000000 4396422380 7100000000 4167720000 1696221461 0970384330 8051200000 8123988580 1510600000 7826403430 7074921000 1310621010 2320000000 879...
result:
FAIL Expected integer, but "0221640010" found (/var/uoj_data/7492/3.out)
Test #4:
score: 0
Wrong Answer
time: 151ms
memory: 32088kb
input:
100000 100000 93945 65645 58366 69901 98882 39559 68888 98809 31151 81778 46666 74051 84368 52984 90981 84009 86457 10252 45216 97230 44961 90818 44818 14073 10565 50867 83292 91924 25986 2074 40605 55278 51198 8057 94523 82585 54208 86645 61473 45261 29171 21173 75420 9443 17799 11431 5020 40091 25...
output:
8330820834 4867868300 2916600000 4520000000 6244920010 5307824100 4515491000 7684995683 3953544311 5631904111 6000000000 7510000000 9507817200 4004511833 1877572327 1553661878 1100000000 6349700100 2542774210 4382722811 8254000000 0659092228 5776676657 2004821000 0518408310 8528330000 5430000000 806...
result:
FAIL Expected integer, but "0659092228" found (/var/uoj_data/7492/4.out)
Test #5:
score: 0
Wrong Answer
time: 329ms
memory: 50008kb
input:
200000 200000 105914 65088 118636 62365 48353 20307 181462 136510 114209 32111 5308 34529 79841 140079 100823 141253 110411 129428 173282 199499 179086 130754 19103 60024 70172 14783 118995 14966 140269 144376 21637 133139 161211 136636 71428 182464 194180 120638 199646 20116 6922 139223 73833 5447 ...
output:
3316200000 1111045396 0921200000 8319000000 5396790500 9327239378 6818610000 0258943000 7411783100 0607821100 6598200000 1751345963 4273011000 4064200000 0615200000 7540559941 3554064511 3100000000 8242456650 7751237773 2210000000 3731784120 9474205623 6217259410 4054337301 9097320000 0953280000 844...
result:
FAIL Expected integer, but "0921200000" found (/var/uoj_data/7492/5.out)
Test #6:
score: 0
Wrong Answer
time: 527ms
memory: 56912kb
input:
300000 300000 23658 131165 262645 280095 2422 295214 62536 229220 99152 55876 173549 216784 257232 195420 228558 227714 222611 80472 231034 218687 57306 219197 60195 63630 135306 278454 12096 67930 281674 11663 193581 135571 5384 236091 259654 238189 117524 246127 54992 25407 260995 108740 36721 279...
output:
8400000000 0605122330 1540300000 7411000000 6426525510 6712000000 6243592060 9460433237 0811310000 1090765200 5115611731 8627474000 3130000000 4910000000 8164400000 3503941720 1462808348 4208454000 3950000000 8027679421 7036255441 4585581571 7670070000 9795110000 1266019157 3405145934 5653643300 686...
result:
FAIL Expected integer, but "0605122330" found (/var/uoj_data/7492/6.out)
Test #7:
score: 0
Wrong Answer
time: 2635ms
memory: 158340kb
input:
1000000 1000000 893159 998545 986168 993381 985676 867284 972091 982736 955640 927289 966593 951563 991646 922075 897706 974374 991796 969579 986536 982837 960131 956828 884436 939569 947203 992954 987151 997095 975426 982625 957079 858678 895285 978500 993042 979758 967580 993571 985391 999717 9816...
output:
4139019884 2675921109 8638413805 4644008411 9982098595 1710010782 5760003162 8790967123 9842652364 5705500000 1581223189 8772767453 8900347243 1377829410 5570861392 4274896169 4354575455 3672615820 1986463469 4414781931 6989943384 1832588866 1581995187 7681732181 5259169851 6736175537 3909698763 639...
result:
FAIL Expected integer, but "0079812600" found (/var/uoj_data/7492/7.out)
Test #8:
score: 0
Wrong Answer
time: 2276ms
memory: 154512kb
input:
1000000 1000000 750898 600457 565525 577950 534158 368777 676282 361219 214512 889130 803951 106652 101780 257156 644752 39924 820954 979764 502497 269722 493893 282907 321990 932833 882749 377054 171786 391391 240717 884964 463001 46959 353829 972763 388101 436207 667673 24819 554628 775746 67680 9...
output:
6347408341 4878651000 7400714834 5174882000 3023362100 1474030000 2269230000 3028000000 4272146385 5540000000 3559213814 6510000000 3216601878 2681000000 7054300000 1186160522 2571697263 5736200000 9050462000 0073720000 2867207066 0247641012 8546000000 0379172000 6883210000 2300266951 8052685962 061...
result:
FAIL Expected integer, but "0073720000" found (/var/uoj_data/7492/8.out)