QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#560644 | #9220. Bus Analysis | ucup-team3519# | WA | 4ms | 3772kb | C++20 | 3.3kb | 2024-09-12 17:10:29 | 2024-09-12 17:10:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define V vector
#define pb push_back
#define all0(x) (x).begin(), (x).end()
#define all1(x) (x).begin() + 1, (x).end()
#define lb lower_bound
const int INF = 2e9 + 10;
const int mod = 1e9 + 7;
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n; cin >> n;
V<int> a(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i];
V<int> cnt20(n + 1);
V<int> cnt75(n + 1);
V<LL> pow2(n + 1);
pow2[0] = 1;
for(int i = 1; i <= n; i++) pow2[i] = pow2[i - 1] * 2 % mod;
for(int i = 1; i <= n; i++) {
for(int j = i + 1; j <= n && a[j] - a[i] <= 19; j++) {
cnt20[i]++;
}
}
for(int i = 1; i <= n; i++) {
for(int j = i + 1; j <= n && a[j] - a[i] <= 74; j++) {
cnt75[i]++;
}
}
auto nxt = [&](int x) -> int {
return lb(a.begin() + 1, a.end(), x + 1) - a.begin();
};
auto cnter = [&](int i, int lim) -> int {
int ans = 0;
for(int j = i; j <= n && a[j] <= lim; j++) {
ans++;
}
return ans;
};
V<LL> dp(n + 2), cnt(n + 2);
cnt[n + 1] = 1;
for(int i = n; i >= 1; i--) {
cnt[i] = cnt[i + 1] * 2 % mod;
LL time75 = pow2[cnt75[i]];
//3
for(int j = i + 1; j <= n && a[j] - a[i] <= 74; j++) {
if(a[j] - a[i] <= 19) continue;
for(int k = j + 1; k <= n && a[k] - a[i] <= 74; k++) {
if(a[k] - a[j] <= 19) continue;
int time = cnt20[i] + cnt20[j] + cnt20[k];
int tmp = 0;
tmp += cnter(i + 1, min(a[i] + 74, a[i] + 19));
tmp += cnter(j + 1, min(a[i] + 74, a[j] + 19));
tmp += cnter(k + 1, min(a[i] + 74, a[k] + 19));
time75 -= pow2[tmp];
int fr = nxt(max(a[k] + 19, a[i] + 74));
dp[i] += (pow2[time]) * ((6 * cnt[fr] + dp[fr]) % mod) % mod;
if(dp[i] >= mod) dp[i] -= mod;
}
}
//2
for(int j = i + 1; j <= n && a[j] - a[i] <= 74; j++) {
if(a[j] - a[i] <= 19) continue;
int time = cnt20[i] + cnt20[j];
int tmp = 0;
tmp += cnter(i + 1, min(a[i] + 74, a[i] + 19));
tmp += cnter(j + 1, min(a[i] + 74, a[j] + 19));
time75 -= pow2[tmp];
int fr = nxt(max(a[j] + 19, a[i] + 74));
dp[i] += (pow2[time]) * ((4 * cnt[fr] + dp[fr]) % mod) % mod;
if(dp[i] >= mod) dp[i] -= mod;
}
//1
int time = cnt20[i];
int fr = nxt(a[i] + 74);
dp[i] += (pow2[time]) * ((2 * cnt[fr] + dp[fr]) % mod) % mod;
if(dp[i] >= mod) dp[i] -= mod;
int tmp = 0;
tmp += cnter(i + 1, min(a[i] + 74, a[i] + 19));
time75 -= pow2[tmp];
//no
dp[i] += dp[i + 1];
if(dp[i] >= mod) dp[i] -= mod;
//75
time75 %= mod;
if(time75 < 0) time75 += mod;
dp[i] += time75 * (6 * cnt[fr] % mod + dp[fr]) % mod;
if(dp[i] >= mod) dp[i] -= mod;
}
cout << dp[1] << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
3 1 8 20
output:
14
result:
ok 1 number(s): "14"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
5 25 45 65 85 1000000000
output:
156
result:
ok 1 number(s): "156"
Test #3:
score: -100
Wrong Answer
time: 4ms
memory: 3584kb
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:
304121041
result:
wrong answer 1st numbers differ - expected: '932594593', found: '304121041'