QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#817318 | #1780. Intact Intervals | ucup-team3723# | WA | 1500ms | 141292kb | C++17 | 1.4kb | 2024-12-16 21:41:07 | 2024-12-16 21:41:07 |
Judging History
answer
#include <iostream>
#include <vector>
#include <map>
#include <random>
#include <array>
#include <algorithm>
using namespace std;
int main()
{
const int psiz = 5;
const int mod = 1e9 + 7;
mt19937 rnd;
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = 0; i < n; ++i) cin >> b[i];
auto all = a;
sort(all.begin(), all.end());
all.erase(unique(all.begin(), all.end()), all.end());
int siz = all.size();
for (int i = 0; i < n; ++i)
{
a[i] = lower_bound(all.begin(), all.end(), a[i]) - all.begin();
b[i] = lower_bound(all.begin(), all.end(), b[i]) - all.begin();
}
vector<vector<long long>> val(psiz, vector<long long> (siz));
for (int i = 0; i < psiz; ++i) for (int j = 0; j < siz; ++j) val[i][j] = (long long)rnd();
map<array<long long, psiz>, int> mp;
array<long long, psiz> now;
for (int i = 0; i < psiz; ++i) now[i] = 0;
mp[now] = 1;
for (int i = 0; i < n - 1; ++i)
{
for (int j = 0; j < psiz; ++j) now[j] = now[j] + val[j][a[i]] - val[j][b[i]];
++mp[now];
}
vector<long long> p2(n);
p2[0] = 1;
for (int i = 1; i < n; ++i) p2[i] = (p2[i - 1] * 2LL) % mod;
long long ans = 0;
for (auto [key, cnt] : mp)
{
if (cnt <= 1) continue;
ans = (ans + mod + p2[cnt] - cnt - 1) % mod;
}
cout << ans << endl;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
2 10 9 9 10
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
5 3 6 9 10 6 3 10 6 9 6
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
10 10 10 0 4 0 5 3 8 5 3 3 0 8 5 0 4 3 10 5 10
output:
9
result:
ok single line: '9'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
100 53 74 39 7 86 14 54 63 86 33 1 33 94 28 65 93 79 52 3 22 53 20 69 59 29 8 42 7 18 33 27 72 10 19 65 30 29 1 57 39 41 6 9 5 92 15 99 22 72 18 81 7 51 82 57 28 4 27 65 99 55 8 57 76 61 13 19 89 9 79 76 95 11 68 9 52 79 24 99 52 65 30 34 77 64 99 10 30 41 12 91 90 13 24 76 41 26 84 51 22 99 89 24 5...
output:
1
result:
ok single line: '1'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
100 1 8 7 6 4 6 8 10 9 10 7 8 8 9 7 5 7 8 7 10 10 0 2 5 6 6 5 4 1 8 3 1 8 0 3 2 0 8 0 8 6 0 1 2 2 2 0 10 5 0 6 4 2 8 8 10 5 1 1 5 8 9 9 0 6 7 3 0 3 6 5 8 4 9 2 9 2 8 3 4 5 0 3 10 6 9 7 0 10 9 9 8 5 10 0 1 8 2 2 10 4 0 3 8 2 6 5 6 10 4 10 8 3 8 4 8 6 0 1 0 2 7 0 5 1 6 9 0 7 2 0 1 5 5 7 6 0 9 10 4 0 2...
output:
13
result:
ok single line: '13'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
100 1 2 0 0 2 1 1 1 1 1 0 0 2 0 1 2 1 0 0 2 1 2 0 2 0 0 1 2 2 2 0 0 0 1 1 1 1 0 0 0 2 2 2 2 0 2 1 2 2 1 2 1 1 1 1 2 2 0 1 0 0 0 0 1 0 1 2 0 2 2 2 1 1 2 1 1 0 1 2 2 0 2 2 1 2 1 1 1 1 2 0 1 1 2 0 1 0 2 2 0 0 1 1 1 1 2 2 1 0 0 2 2 0 0 1 0 2 2 1 0 1 2 2 0 1 1 1 2 1 0 0 2 2 0 1 1 1 0 1 1 2 1 2 2 2 1 2 2 ...
output:
1075
result:
ok single line: '1075'
Test #7:
score: 0
Accepted
time: 7ms
memory: 4928kb
input:
10000 2140 5310 9949 84 2706 4404 6310 8451 6995 8883 4817 8214 1668 4724 1674 839 2900 7773 8536 3712 3056 4683 405 1826 9937 5284 9614 8701 4235 8394 4678 6904 3425 2458 2343 6893 5819 5207 370 9231 3018 2552 1381 4495 8465 2312 6937 907 3333 4236 8006 6939 4945 1667 1528 5043 5298 2278 3634 6824 ...
output:
4
result:
ok single line: '4'
Test #8:
score: 0
Accepted
time: 5ms
memory: 4728kb
input:
10000 82 19 42 67 24 91 33 53 56 16 30 88 22 26 13 99 93 98 62 6 18 34 75 91 91 39 16 56 68 67 36 90 86 39 10 20 37 52 56 4 69 18 97 82 48 35 21 7 24 42 95 99 66 47 1 37 42 90 86 47 36 82 67 27 11 58 62 10 29 10 87 12 73 62 64 27 58 39 36 98 43 25 76 37 96 39 65 64 61 45 65 80 23 56 95 49 45 69 70 5...
output:
117
result:
ok single line: '117'
Test #9:
score: 0
Accepted
time: 3ms
memory: 4180kb
input:
10000 0 1 0 1 2 2 2 2 2 0 1 0 0 1 1 2 0 2 1 0 1 2 2 1 1 1 2 0 2 2 0 0 2 2 1 0 2 1 2 2 2 0 2 1 2 1 2 0 2 2 0 1 0 1 0 1 0 0 0 1 1 0 1 2 0 1 0 2 0 1 2 0 1 2 1 0 1 2 2 0 2 1 1 1 0 2 1 0 2 1 2 0 2 0 0 0 1 0 1 1 2 2 2 0 0 1 2 2 0 1 1 0 2 1 2 1 1 0 2 1 2 0 0 2 1 1 2 1 0 2 1 0 2 2 1 2 1 0 0 0 1 2 1 2 0 2 2 ...
output:
661070230
result:
ok single line: '661070230'
Test #10:
score: 0
Accepted
time: 1500ms
memory: 141204kb
input:
1000000 53619079 982512764 860871815 530378910 588856185 454683791 264369639 297818635 824975749 256072724 56501959 644097074 258832116 294895621 430606412 64927560 98316617 241951788 814040050 543600636 502382486 898906645 914890506 424109890 191843578 913062126 513568981 753685691 579339567 739779...
output:
1
result:
ok single line: '1'
Test #11:
score: 0
Accepted
time: 1202ms
memory: 141292kb
input:
1000000 379491 423615 303730 616005 716043 660165 422058 952047 984874 839411 652625 702220 614558 70068 45650 997250 623100 492984 574610 956181 940400 495685 33538 602760 846707 464330 305563 545858 20911 407856 871126 568332 726681 420978 712188 759802 771108 187839 109384 781142 105828 750540 44...
output:
2
result:
ok single line: '2'
Test #12:
score: 0
Accepted
time: 1021ms
memory: 115508kb
input:
1000000 646696897 307550750 352055156 145493783 876454664 99776544 86852880 16750429 214290945 969506283 772309271 753769454 104954710 772309271 467856522 214125155 848614965 930244030 16750429 104954710 245368159 891572304 2439115 750700204 929485372 946025151 428706915 960038923 2439115 784399861 ...
output:
10274
result:
ok single line: '10274'
Test #13:
score: 0
Accepted
time: 1250ms
memory: 141240kb
input:
1000000 67606 412951 730949 182648 124844 759671 310913 632762 622832 812614 102462 66728 706288 593038 496173 902778 732591 99404 414562 361946 977273 513531 206369 484027 547467 881498 597662 330888 912299 900729 287461 113436 169944 166886 694667 655130 91758 393634 419028 830888 219038 945816 44...
output:
1
result:
ok single line: '1'
Test #14:
score: 0
Accepted
time: 897ms
memory: 116812kb
input:
1000000 8299 4940 3492 9449 9679 5280 656 1666 8852 89 9995 1167 1425 8702 2245 1819 8035 2246 9575 9363 3943 3488 937 9164 7637 2919 8724 839 8758 8049 5826 1149 2863 9972 7323 6431 6308 4642 3292 9613 5792 5585 3769 2974 5843 9553 8978 261 6327 8466 1666 8018 9543 7760 4012 8581 4310 4547 3795 802...
output:
92
result:
ok single line: '92'
Test #15:
score: 0
Accepted
time: 671ms
memory: 115476kb
input:
1000000 95 91 68 69 69 98 20 3 84 13 64 82 98 35 44 82 26 30 83 76 61 100 81 22 45 28 96 14 39 33 40 15 3 63 86 3 29 33 99 0 14 57 30 54 85 4 1 82 42 69 66 45 1 25 91 30 47 88 61 96 27 2 46 96 13 22 5 29 50 45 47 93 64 31 19 47 42 97 27 92 10 37 82 88 84 27 57 13 78 54 88 44 18 99 64 78 60 46 38 36 ...
output:
10194
result:
ok single line: '10194'
Test #16:
score: 0
Accepted
time: 625ms
memory: 107068kb
input:
1000000 3 8 3 6 10 2 5 2 7 8 0 1 5 1 8 9 0 2 2 6 8 9 6 3 6 6 6 8 5 2 10 1 2 10 10 1 0 8 2 9 1 2 2 4 1 0 8 4 7 8 5 5 5 7 5 3 6 4 1 0 7 9 10 2 1 6 8 10 3 4 3 5 10 3 5 9 9 0 0 1 1 6 7 2 2 3 0 7 8 4 0 0 4 8 0 1 1 5 7 6 0 0 6 7 10 8 6 1 8 2 3 6 1 7 1 1 4 7 3 1 5 6 1 9 2 7 1 3 7 6 0 10 8 5 6 1 0 9 1 8 6 9...
output:
126874
result:
ok single line: '126874'
Test #17:
score: 0
Accepted
time: 539ms
memory: 96272kb
input:
1000000 1 4 3 0 2 4 5 5 2 2 3 5 5 2 1 2 3 3 4 5 0 2 5 1 1 2 3 0 0 5 1 2 4 1 3 5 4 5 0 1 0 3 3 4 1 5 4 5 3 5 0 0 0 2 1 5 1 3 0 0 2 1 2 5 1 5 3 2 3 5 2 3 2 2 1 3 3 1 3 5 2 4 1 3 1 1 1 2 0 3 5 0 5 1 4 4 1 0 1 4 2 2 1 3 3 5 0 0 0 3 2 0 3 3 2 4 2 3 1 0 5 3 4 2 5 2 3 5 3 2 0 0 5 2 5 3 1 0 0 4 1 4 3 4 4 1 ...
output:
379607
result:
ok single line: '379607'
Test #18:
score: 0
Accepted
time: 296ms
memory: 37616kb
input:
1000000 2 1 1 0 1 2 2 0 0 0 1 2 2 2 0 2 2 1 1 2 0 1 2 1 2 1 1 0 0 1 0 2 2 0 1 1 1 1 0 0 0 0 2 2 0 0 1 1 2 2 1 2 0 1 0 1 0 2 0 1 0 1 2 0 2 2 0 2 2 1 1 2 2 0 2 0 1 0 0 1 2 2 2 1 1 2 1 1 2 0 2 0 1 2 2 0 1 2 0 2 0 0 2 0 0 0 0 1 2 1 1 0 0 2 2 0 2 0 0 2 1 0 1 2 0 0 0 1 1 2 0 0 0 2 2 1 2 0 2 0 0 0 1 1 2 1 ...
output:
681495559
result:
ok single line: '681495559'
Test #19:
score: -100
Wrong Answer
time: 193ms
memory: 22568kb
input:
1000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
999000006
result:
wrong answer 1st lines differ - expected: '234042058', found: '999000006'