QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#536138 | #9220. Bus Analysis | Max_s_xaM | AC ✓ | 124ms | 12016kb | C++17 | 3.5kb | 2024-08-28 19:00:56 | 2024-08-28 19:00:57 |
Judging History
answer
#include <iostream>
typedef long long ll;
typedef double lf;
// #define DEBUG 1
struct IO
{
#define MAXSIZE (1 << 20)
#define isdigit(x) (x >= '0' && x <= '9')
char buf[MAXSIZE], *p1, *p2;
char pbuf[MAXSIZE], *pp;
#if DEBUG
#else
IO() : p1(buf), p2(buf), pp(pbuf) {}
~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
#endif
#define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++)
#define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')
template <typename T>
void Read(T &x)
{
#if DEBUG
std::cin >> x;
#else
bool sign = 0; char ch = gc(); x = 0;
for (; !isdigit(ch); ch = gc())
if (ch == '-') sign = 1;
for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
if (sign) x = -x;
#endif
}
void Read(char *s)
{
#if DEBUG
std::cin >> s;
#else
char ch = gc();
for (; blank(ch); ch = gc());
for (; !blank(ch); ch = gc()) *s++ = ch;
*s = 0;
#endif
}
void Read(char &c) {for (c = gc(); blank(c); c = gc());}
void Push(const char &c)
{
#if DEBUG
putchar(c);
#else
if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
*pp++ = c;
#endif
}
template <typename T>
void Write(T x)
{
if (x < 0) x = -x, Push('-');
static T sta[35];
int top = 0;
do sta[top++] = x % 10, x /= 10; while (x);
while (top) Push(sta[--top] ^ 48);
}
template <typename T>
void Write(T x, char lst) {Write(x), Push(lst);}
} IO;
#define Read(x) IO.Read(x)
#define Write(x, y) IO.Write(x, y)
#define Put(x) IO.Push(x)
using namespace std;
const int MAXN = 1010, mod = 1e9 + 7;
inline int adu(int x, int y) { return (x += y) >= mod ? x - mod : x; }
inline void add(int &x, int y) { (x += y) >= mod && (x -= mod); }
int n;
int a[MAXN];
struct value
{
int x, y;
void operator += (const value &u) { add(x, u.x), add(y, u.y); }
value operator ! () const { return value{adu(x, y), y}; }
}f[2][80][80][80], ans;
inline void Clear(int p)
{
for (int i = 0; i <= 75; i++)
for (int j = i; j <= 75; j++)
for (int k = j; k <= 75; k++)
f[p][i][j][k] = {0, 0};
}
int main()
{
// freopen("A.in", "r", stdin);
// freopen("A.out", "w", stdout);
#if DEBUG
#else
ios::sync_with_stdio(0), cin.tie(0);
#endif
Read(n);
for (int i = 1; i <= n; i++) Read(a[i]);
a[0] = -100;
bool p = 0;
f[p][0][0][0] = {0, 1};
for (int i = 1; i <= n; i++)
{
Clear(!p);
for (int u = 0; u <= 75; u++)
for (int v = u; v <= 75; v++)
for (int w = v; w <= 75; w++)
{
if (!f[p][u][v][w].y) continue;
int x = min(75, u + a[i] - a[i - 1]), y = min(75, v + a[i] - a[i - 1]), z = min(75, w + a[i] - a[i - 1]);
f[!p][x][y][z] += f[p][u][v][w];
if (x >= 20 && z >= 75) f[!p][0][x][y] += !f[p][u][v][w];
else f[!p][x][y][z] += f[p][u][v][w];
}
p = !p;
}
for (int i = 0; i <= 75; i++)
for (int j = i; j <= 75; j++)
for (int k = j; k <= 75; k++)
ans += f[p][i][j][k];
cout << ans.x * 2ll % mod << "\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 9816kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 3ms
memory: 11556kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: 0
Accepted
time: 71ms
memory: 11728kb
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: 18ms
memory: 11900kb
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: 66ms
memory: 11936kb
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: 0ms
memory: 11316kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #7:
score: 0
Accepted
time: 69ms
memory: 11412kb
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: 9780kb
input:
1 963837006
output:
2
result:
ok 1 number(s): "2"
Test #9:
score: 0
Accepted
time: 62ms
memory: 11680kb
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: 114ms
memory: 11932kb
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: 68ms
memory: 11756kb
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: 3ms
memory: 11512kb
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: 70ms
memory: 12008kb
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: 124ms
memory: 11604kb
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: 65ms
memory: 11816kb
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: 12012kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #17:
score: 0
Accepted
time: 104ms
memory: 12016kb
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: 66ms
memory: 11512kb
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: 4ms
memory: 11856kb
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: 100ms
memory: 11680kb
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: 77ms
memory: 11932kb
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