QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#563457#9220. Bus Analysisarnold518#AC ✓105ms7432kbC++172.4kb2024-09-14 12:16:452024-09-14 12:16:45

Judging History

你现在查看的是最新测评结果

  • [2024-09-14 12:16:45]
  • 评测
  • 测评结果:AC
  • 用时:105ms
  • 内存:7432kb
  • [2024-09-14 12:16:45]
  • 提交

answer

#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MOD = 1e9 + 7;
struct mint{
    int x;
    mint() : x(0) {}
    mint(int x) : x(x) {}
    mint operator+ (int ot) const { return x >= MOD - ot ? x - MOD + ot : x + ot; }
    mint operator- (int ot) const { return x >= ot ? x - ot : x - ot + MOD; }
    mint operator* (int ot) const { return 1ll * x * ot % MOD; }
    mint operator+= (int ot) { return *this = *this + ot; }
    mint operator-= (int ot) { return *this = *this - ot; }
    mint operator*= (int ot) { return *this = *this * ot; }
    operator int () const { return x; }
};

typedef tuple<int, int, int> tiii;

mint dp[2][76][76][76];
int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int t[n];
    for (int i = 0; i < n; i++) cin >> t[i];
    
    vector<tiii> V;
    for (int z = 1; z <= 75; z++) {
        for (int y = 1; y <= (z == 75 ? 75 : z - 19); y++) {
            for (int x = 1; x <= (y == 75 ? 75 : y - 19); x++) {
                V.push_back({x, y, z});
            }
        }
    }

    mint pw[n + 1]{};
    pw[0] = 1;
    for (int i = 1; i <= n; i++) pw[i] = pw[i - 1] * 2;

    dp[0][75][75][75] = 1;
    int prv = 0;
    mint ans = 0;
    for (int i = 0; i < n; i++) {
        int k = t[i] - prv - 1;
        for (auto [x, y, z] : V) dp[1][x][y][z] = 0;
        for (auto [x, y, z] : V) dp[1][min(x + k, 75)][min(y + k, 75)][min(z + k, 75)] += dp[0][x][y][z];

        for (auto [x, y, z] : V) dp[0][x][y][z] = 0;
        for (auto [x, y, z] : V) {
            dp[0][min(x + 1, 75)][min(y + 1, 75)][min(z + 1, 75)] += dp[1][x][y][z];
            if (x <= 19 || z <= 74) {
                dp[0][min(x + 1, 75)][min(y + 1, 75)][min(z + 1, 75)] += dp[1][x][y][z];
            }
            else {
                dp[0][1][min(x + 1, 75)][min(y + 1, 75)] += dp[1][x][y][z];
            }
        }
        for (auto [x, y, z] : V) if (x == 1) ans += dp[0][x][y][z] * 2 * pw[n - 1 - i];
        // cout << "Round " << i << '\n';
        // for (auto [x, y, z] : V) {
        //     if (dp[0][x][y][z] != 0) {
        //         cout << x << ' ' << y << ' '<< z << " -> " << dp[0][x][y][z] << '\n';
        //     }
        // }
        prv = t[i];
    }
    cout << ans << '\n';
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 7184kb

input:

3
1 8 20

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: 0
Accepted
time: 2ms
memory: 7168kb

input:

5
25 45 65 85 1000000000

output:

156

result:

ok 1 number(s): "156"

Test #3:

score: 0
Accepted
time: 104ms
memory: 7380kb

input:

1000
2 7 9 12 14 17 18 21 22 28 29 33 34 35 37 38 44 45 46 50 58 59 63 66 71 72 75 76 77 78 80 81 83 84 87 92 100 101 107 108 109 112 114 116 118 123 124 131 142 143 144 145 148 150 151 152 153 155 157 158 165 167 168 169 171 176 182 185 190 192 198 202 204 205 212 213 223 224 225 226 229 231 240 24...

output:

932594593

result:

ok 1 number(s): "932594593"

Test #4:

score: 0
Accepted
time: 22ms
memory: 7132kb

input:

200
1 2 4 9 10 11 12 15 16 17 18 19 22 24 27 28 33 36 37 39 43 44 45 47 48 49 50 51 52 56 60 61 62 63 68 70 71 72 73 74 78 80 81 84 86 92 93 98 99 100 102 105 107 108 110 111 114 115 116 122 123 125 129 132 133 135 137 138 139 141 142 143 144 149 150 151 152 153 154 155 159 160 165 171 172 174 176 1...

output:

422301620

result:

ok 1 number(s): "422301620"

Test #5:

score: 0
Accepted
time: 99ms
memory: 7148kb

input:

1000
999975020 999975030 999975050 999975056 999975085 999975118 999975207 999975213 999975240 999975307 999975332 999975344 999975356 999975384 999975405 999975468 999975499 999975558 999975559 999975571 999975631 999975664 999975680 999975689 999975731 999975738 999975765 999975831 999975838 99997...

output:

335758758

result:

ok 1 number(s): "335758758"

Test #6:

score: 0
Accepted
time: 2ms
memory: 7192kb

input:

3
1 8 20

output:

14

result:

ok 1 number(s): "14"

Test #7:

score: 0
Accepted
time: 98ms
memory: 7144kb

input:

1000
214 216 381 497 539 645 772 927 1211 1238 1239 1298 1403 1426 1437 1504 1515 1648 1800 1816 1946 2008 2038 2066 2144 2173 2236 2253 2291 2574 2632 2643 2658 2671 2689 2886 2910 2948 3002 3033 3039 3057 3077 3188 3240 3322 3331 3449 3467 3578 3730 3796 3897 3973 4152 4160 4199 4331 4386 4429 465...

output:

877690181

result:

ok 1 number(s): "877690181"

Test #8:

score: 0
Accepted
time: 2ms
memory: 7108kb

input:

1
963837006

output:

2

result:

ok 1 number(s): "2"

Test #9:

score: 0
Accepted
time: 101ms
memory: 7140kb

input:

999
17 234 337 379 449 607 646 703 716 878 887 898 901 942 964 1075 1198 1356 1432 1546 1547 1619 1668 1769 1818 1826 1881 1900 1960 2017 2088 2266 2273 2339 2376 2377 2396 2399 2438 2461 2484 2567 2620 2661 2680 2791 2881 3040 3081 3082 3094 3102 3205 3218 3225 3227 3239 3250 3331 3393 3425 3530 35...

output:

651884156

result:

ok 1 number(s): "651884156"

Test #10:

score: 0
Accepted
time: 103ms
memory: 7208kb

input:

1000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

output:

754964156

result:

ok 1 number(s): "754964156"

Test #11:

score: 0
Accepted
time: 105ms
memory: 7432kb

input:

1000
1 2 5 12 13 16 19 21 24 40 42 50 51 54 60 61 63 65 69 72 83 100 106 117 121 122 132 133 135 144 149 154 156 157 158 159 163 172 187 190 194 195 196 200 204 221 224 225 236 237 238 239 242 248 250 251 257 258 264 269 272 279 284 286 288 294 298 301 303 322 324 326 328 347 348 358 363 367 368 376...

output:

736216287

result:

ok 1 number(s): "736216287"

Test #12:

score: 0
Accepted
time: 0ms
memory: 7080kb

input:

10
2 5 8 10 11 15 20 32 34 48

output:

3806

result:

ok 1 number(s): "3806"

Test #13:

score: 0
Accepted
time: 98ms
memory: 7144kb

input:

1000
3092896 4096697 4935574 5665657 6717242 12350017 13784643 14890236 15103239 16083201 16158442 17406219 18377269 19146618 20149007 20444388 20799716 21703919 22502750 26066931 27425220 27610093 30584293 30942406 33020849 33381138 34889813 35505301 35711460 36618608 37636454 42073851 43834284 441...

output:

423205184

result:

ok 1 number(s): "423205184"

Test #14:

score: 0
Accepted
time: 101ms
memory: 7088kb

input:

1000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 100 101 10...

output:

167925937

result:

ok 1 number(s): "167925937"

Test #15:

score: 0
Accepted
time: 102ms
memory: 7140kb

input:

1000
123123123 123123143 123123163 123123183 123123203 123123223 123123243 123123263 123123283 123123303 123123323 123123343 123123363 123123383 123123403 123123423 123123443 123123463 123123483 123123503 123123523 123123543 123123563 123123583 123123603 123123623 123123643 123123663 123123683 12312...

output:

152353232

result:

ok 1 number(s): "152353232"

Test #16:

score: 0
Accepted
time: 0ms
memory: 7128kb

input:

5
25 45 65 85 1000000000

output:

156

result:

ok 1 number(s): "156"

Test #17:

score: 0
Accepted
time: 104ms
memory: 7200kb

input:

1000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 76 77 79 80 81 82 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 103 104 105...

output:

506306982

result:

ok 1 number(s): "506306982"

Test #18:

score: 0
Accepted
time: 101ms
memory: 7204kb

input:

1000
6 15 22 23 29 36 55 56 63 75 84 98 100 107 114 119 124 126 135 150 155 156 158 159 162 168 179 180 193 196 197 202 204 214 215 218 229 242 244 248 251 253 255 265 271 273 286 288 302 306 324 334 368 380 388 409 425 473 476 489 525 526 534 540 554 556 562 566 570 573 574 592 621 636 640 645 653 ...

output:

272405461

result:

ok 1 number(s): "272405461"

Test #19:

score: 0
Accepted
time: 3ms
memory: 7184kb

input:

19
999999810 999999814 999999829 999999838 999999839 999999843 999999849 999999853 999999883 999999889 999999896 999999907 999999911 999999925 999999926 999999946 999999957 999999987 999999993

output:

5337088

result:

ok 1 number(s): "5337088"

Test #20:

score: 0
Accepted
time: 102ms
memory: 7172kb

input:

999
1 2 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 32 33 34 35 38 39 40 41 42 43 45 46 47 49 50 51 52 54 55 56 57 59 60 61 62 64 65 66 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 85 86 88 89 90 91 92 93 94 95 96 97 99 100 101 103 105 106 107 108 109 110 111 112 11...

output:

571215215

result:

ok 1 number(s): "571215215"

Test #21:

score: 0
Accepted
time: 105ms
memory: 7148kb

input:

1000
123121000 123121001 123121002 123121005 123121012 123121013 123121018 123121020 123121021 123121024 123121028 123121029 123121031 123121034 123121035 123121036 123121037 123121038 123121043 123121044 123121045 123121046 123121047 123121048 123121050 123121051 123121052 123121055 123121057 12312...

output:

250442238

result:

ok 1 number(s): "250442238"

Extra Test:

score: 0
Extra Test Passed