QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#743596 | #5173. 染色 | Augenstern | 0 | 613ms | 181460kb | C++14 | 1.3kb | 2024-11-13 19:35:59 | 2024-11-13 19:35:59 |
Judging History
answer
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
//#define int long long
//#define ull unsigned long long
#define lll __int128
//#define double long double
#define fi first
#define se second
using namespace std;
const long long INF=1e9+5;
const long long mod=998244353,orm=3;
//const long long mod=1000000007;
const int MAXN=2000005;
const double eps=1e-6;
bool ST;
int n,Q;
int a[MAXN],b[MAXN],vst[MAXN];
int f[MAXN];
pair<int,int> p[MAXN][21];
void solve() {
cin>>n>>Q;
for(int i=1;i<=n;i++) cin>>a[i];
int l=0;
for(int i=1;i<=n;i++) {
vst[a[i]]++;
while(vst[a[i]]>1) vst[a[l]]--,l++;
b[i]=l;
}
for(int i=1;i<=n;i++) {
p[i][0]={1,i-1};
if(b[i]) p[i][0]={i-b[i],b[i]-1};
}
for(int j=1;(1<<j)<=n;j++) {
for(int i=1;i<=n;i++) {
if(p[i][j-1].se&&p[p[i][j-1].se][j-1].se) p[i][j]={p[i][j-1].fi+p[p[i][j-1].se][j-1].fi,p[p[i][j-1].se][j-1].se};
}
}
while(Q--) {
int l,r,res=0;cin>>l>>r;res+=r-l;
if(l>r) swap(l,r);
for(int i=20;i>=0;i--) {
if(p[r][i].se>=l) res+=p[r][i].fi,r=p[r][i].se;
}
res+=r-l;
cout<<res<<"\n";
}
}
bool ED;
signed main() {
// cout<<(&ST-&ED)/1024.0/1024.0;
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
solve();
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 10364kb
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:
-156 -201 5976 8382 -31 7013 -9 7320 492 -50 253 2249 -566 -270 456 -333 -86 -457 1791 -109 4801 -11 5997 627 -292 6179 -486 2712 3157 7836 -760 511 5486 17835 -416 6147 4996 14577 670 463 15613 -547 8872 7833 -469 6603 6399 5023 -394 8529 2173 -441 -112 12537 -212 2144 8809 1907 6476 2828 -37 -285 ...
result:
wrong answer 1st words differ - expected: '3668', found: '-156'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 54ms
memory: 25244kb
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:
-40970 133099 -19993 6483 9199 -28382 -33980 29192 38941 -40428 66619 7226 -23789 42776 -16272 49274 11102 107722 -25888 -3808 4735 87161 46860 -27357 -9710 -3965 12237 59513 18641 55105 11626 7850 5521 -13947 -24350 -21048 16941 -25500 -25459 53673 -18724 551 -6721 -43361 -1440 43296 62515 -12314 -...
result:
wrong answer 1st words differ - expected: '113194', found: '-40970'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 3ms
memory: 8580kb
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:
-32 -66 1743 -61 -115 -121 2950 -33 880 5076 -189 4860 -23 925 -18 -176 -181 -133 3813 -85 4478 -35 2540 40 901 -10 -109 3882 -85 5739 4610 -36 -9 -34 -83 -121 565 -3 -46 7615 -218 -51 3121 3683 2883 -12 727 4006 179 -77 -31 1602 7127 3008 -142 8083 1539 -85 363 4476 -74 1741 818 2433 -105 964 4720 ...
result:
wrong answer 1st words differ - expected: '1322', found: '-32'
Subtask #4:
score: 0
Wrong Answer
Test #23:
score: 0
Wrong Answer
time: 613ms
memory: 181460kb
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 -1744 760115 -454 -902 576908 988222 1716103 1345118 -1219 -3482 -3047 1385912 320711 -6194 52291 276158 227555 2476 -834 -790 667128 25418 -1258 -1062 1445226 1666310 -3091 146406 969316 1106498 -1324 -4601 -641 84810 1188701 316694 717959 169528 559867 -4324 412202 -418 -1523 -3076 1042723...
result:
wrong answer 2nd words differ - expected: '308608', found: '-1744'