QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#822978 | #9220. Bus Analysis | HildaHu | WA | 19ms | 40736kb | C++14 | 1.2kb | 2024-12-20 17:56:18 | 2024-12-20 17:56:19 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1010, M = 80, mod = 1e9 + 7;
int n, ans, a[N], pw[N], f[N][M][M];
void add(int &x, int y) {x = (x + y) % mod; }
int work(int x, int y) {
return (!x || x + y > 75) ? 0 : x + y;
}
signed main() {
cin >> n;
pw[0] = 1;
for (int i=1; i<=n; ++i) pw[i] = pw[i - 1] * 2 % mod;
for (int i=1; i<=n; ++i) cin >> a[i];
a[0] = a[1] - 1;
f[0][0][0] = 1;
for (int i=0; i<n; ++i)
for (int j=0; j<=75; ++j) {
int nxt = a[i + 1] + 19;
if (j && nxt < a[i] - j + 75) nxt = a[i] - j + 75;
nxt = upper_bound(a + 1, a + n + 1, nxt) - a - 1;
for (int k=0; k<=75; ++k) if (f[i][k][j]) {
//printf("%d %d %d %d nxt %d\n", i, k, j, f[i][k][j], nxt);
add(f[i + 1][work(k, a[i + 1] - a[i])][work(j, a[i + 1] - a[i])], f[i][k][j]);
add(f[nxt][a[nxt] - a[i] > 75 ? 0 : a[nxt] - a[i]][work(k, a[nxt] - a[i])], f[i][k][j] * pw[nxt - i - 1]);
add(ans, f[i][k][j] * pw[n - i - 1]);
/*add(f[nxt][work(k, nxt - i)][work(j, nxt - i)], f[i][k][j]);
add(f[nxt][nxt - i][work(k, nxt - i)], f[i][k][j] * (pw[nxt - i] - 1));
add(ans, f[i][k][j] * (pw[nxt - i] - 1) % mod * pw[n - nxt]);*/
}
}
cout << ans * 2 % mod << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3676kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: -100
Wrong Answer
time: 19ms
memory: 40736kb
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:
515020455
result:
wrong answer 1st numbers differ - expected: '932594593', found: '515020455'