QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740696 | #5173. 染色 | posvii | 0 | 504ms | 106060kb | C++14 | 681b | 2024-11-13 11:09:46 | 2024-11-13 11:09:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=1e6+5;
int n,q,a[MAXN],las[MAXN],f[MAXN][25];
signed main() {
#ifndef ONLINE_JUDGE
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
ios::sync_with_stdio(0),cin.tie(0);
cin>>n>>q;
for(int i=1;i<=n;++i) {
cin>>a[i];
f[i][0]=max(las[a[i]],f[i-1][0]),las[a[i]]=i;
}
for(int j=1;j<=19;++j) {
for(int i=n;f[i][j-1];--i) {
f[i][j]=f[f[i][j-1]][j-1];
}
}
while(q--) {
int l,r;
cin>>l>>r;
if(l>r) swap(l,r);
int ans=(r-l)*2;
for(int j=19;j>=0;--j) {
if(f[r][j]>=l) r=f[r][j]-1,ans-=1<<j;
}
printf("%d\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 6860kb
input:
10000 100 84 85 52 2 78 53 20 21 23 76 37 44 18 5 37 8 81 65 46 58 69 1 69 37 53 46 37 35 35 89 1 77 35 6 46 59 89 46 25 55 50 38 61 67 44 23 29 24 46 4 42 15 34 77 20 34 83 79 12 50 69 26 38 14 9 66 80 72 22 26 9 68 35 38 19 84 92 30 83 62 100 71 81 60 7 37 64 50 33 60 86 75 45 78 32 53 3 48 87 60 ...
output:
3669 4575 5976 8382 729 7013 183 7320 492 1140 253 2250 13226 6255 456 7507 2162 10481 1791 2675 4801 293 5997 627 6654 6179 11414 2712 3157 7837 17782 511 5486 17836 9565 6147 4996 14577 670 463 15614 12670 8873 7833 10988 6604 6399 5023 9103 8529 2173 10300 2695 12538 4958 2144 8811 1907 6476 2828...
result:
wrong answer 1st words differ - expected: '3668', found: '3669'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 45ms
memory: 16160kb
input:
100000 100000 3 2 3 3 3 3 2 3 2 1 3 1 1 1 3 2 1 3 1 2 2 1 3 1 2 2 1 1 1 3 2 1 3 3 3 3 1 1 1 2 3 3 2 1 1 1 3 1 3 1 3 2 1 3 2 3 3 2 3 3 2 3 3 3 3 3 2 3 2 3 1 3 3 3 3 3 3 3 1 2 3 3 1 3 1 1 2 2 3 1 1 2 3 2 3 1 3 2 1 3 2 3 2 1 1 3 3 1 3 1 2 2 2 3 2 3 2 3 2 1 1 3 1 3 2 2 3 3 3 1 2 2 3 3 2 1 3 1 2 2 2 3 2 ...
output:
113196 133100 54924 6486 9202 78293 93923 29193 38943 111592 66620 7228 66024 42780 44646 49278 11105 107726 71680 10712 4737 87168 46861 75810 27275 10955 12240 59516 18642 55108 11628 7853 5523 38730 67281 58329 16945 70133 70342 53675 51866 553 18485 119890 4021 43299 62518 33974 9874 24984 33224...
result:
wrong answer 1st words differ - expected: '113194', found: '113196'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 2ms
memory: 7968kb
input:
5000 5000 256 63 197 36 75 66 33 72 27 75 66 248 29 166 209 252 141 95 84 226 147 249 116 94 192 256 199 273 182 166 116 274 27 211 154 144 283 23 53 110 215 11 164 284 161 221 251 96 43 47 18 115 12 51 156 61 116 209 93 98 47 165 174 106 83 67 184 75 12 290 183 197 112 240 67 56 215 148 104 5 141 2...
output:
1322 2696 1743 2611 4759 4995 2950 1327 880 5076 7811 4860 935 925 808 7270 7663 5325 3813 3225 4479 1577 2540 40 901 301 4351 3882 3813 5739 4610 1658 438 1416 3623 5257 565 119 2044 7615 9112 2047 3121 3683 2883 420 727 4006 179 3231 1443 1603 7127 3008 5955 8083 1539 3807 363 4476 3300 1741 818 2...
result:
wrong answer 21st words differ - expected: '4478', found: '4479'
Subtask #4:
score: 0
Wrong Answer
Test #23:
score: 0
Wrong Answer
time: 504ms
memory: 106060kb
input:
1000000 1000000 1105 3246 1880 3554 818 2331 2576 4140 149 4562 3498 3536 3400 4788 4363 4742 1216 4218 4032 1701 1489 4889 1761 3022 3145 4945 3067 4304 5016 4624 1612 13 1335 3613 1086 2210 386 3464 1156 3352 4341 5006 3465 3900 622 654 1826 2983 1250 4164 3335 4308 2995 1982 1347 4335 2535 5054 4...
output:
1263815 308608 760115 79452 160351 576908 988222 1716103 1345118 215185 615960 546263 1385912 320711 1094276 52291 276158 227555 2476 147750 144806 667128 25418 223778 184324 1445226 1666310 547639 146406 969316 1106498 237554 817297 112491 84810 1188701 316694 717959 169528 559867 767793 412202 732...
result:
wrong answer 5th words differ - expected: '160350', found: '160351'