QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#232452 | #5173. 染色 | RedreamMer | 0 | 34ms | 13548kb | C++14 | 1.2kb | 2023-10-30 14:43:15 | 2023-10-30 14:43:15 |
Judging History
answer
// #pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define PB emplace_back
// #define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) {rep(i, 0, siz(n) - 1) cerr << n[i] << " \n"[i == siz(n) - 1];}
const int N = 1e6;
int a, b, f[N + 5][21], p[N + 5], s[N + 5];
signed main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> a >> b;
rep(i, 1, a) {
cin >> s[i];
f[i][0] = max(f[i - 1][0], p[s[i]]);
rep(j, 1, 20) f[i][j] = f[f[i][j - 1]][j - 1];
p[s[i]] = i;
}
int x, y;
rep(i, 1, b) {
cin >> x >> y;
if(x > y) swap(x, y);
int ans = (y - x) * 2;
per(j, 20, 0) if(f[y][j] >= x) ans -= 1 << j, y = f[y][i];
cout << ans << '\n';
}
return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 4752kb
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:
3569 4521 5723 8229 744 6820 184 7344 498 1158 256 2280 13280 6268 458 7584 2184 10682 1804 2720 4755 289 5743 626 6435 5935 11390 2772 3170 7914 18030 516 5594 18086 9724 6158 5080 14696 680 468 15774 12193 8745 7655 10945 6381 6163 5000 9040 8574 2210 10484 2742 12570 5042 2176 8924 1922 6494 2828...
result:
wrong answer 1st words differ - expected: '3668', found: '3569'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 34ms
memory: 13548kb
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:
88629 115613 42147 4717 8423 73905 62365 23307 36665 86481 57962 7808 61136 50110 52720 50772 13058 113980 81180 12468 4397 85979 30929 70395 20597 10821 8371 48391 17137 42373 8062 8142 6466 40386 71146 62990 18980 79246 79416 56796 54204 499 17011 97711 3409 42573 52345 29903 9353 17705 28901 6570...
result:
wrong answer 1st words differ - expected: '113194', found: '88629'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 2ms
memory: 6124kb
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:
1291 2635 1720 2612 4754 5020 2964 1328 886 5124 7872 4908 942 928 810 7318 7716 5330 3838 3246 4453 1549 2533 40 902 302 4364 3912 3834 5740 4660 1662 438 1418 3642 5314 572 120 2058 7666 9202 2035 3065 3639 2827 424 734 4010 180 3244 1458 1606 7164 3012 5968 8144 1548 3828 366 4514 3310 1752 805 2...
result:
wrong answer 1st words differ - expected: '1322', found: '1291'
Subtask #4:
score: 0
Runtime Error
Test #23:
score: 0
Runtime Error
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:
1262753 308305 756183 79395 160229 576027 985599 1709373 1344455 215252 616370 547262 1389616 321492 1096374 52324 276656 227836 2476 148072 144573 666767 25313 222989 183339 1445139 1659307 546635 146284 966578 1104582 237854 817546 112620 85034 1191300 317434 719968 169970 560946 768020 410451 731...