QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#568946#9220. Bus Analysisucup-team3519WA 68ms56740kbC++203.2kb2024-09-16 19:27:232024-09-16 19:27:24

Judging History

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

  • [2024-09-16 19:27:24]
  • 评测
  • 测评结果:WA
  • 用时:68ms
  • 内存:56740kb
  • [2024-09-16 19:27:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define V vector
#define all0(x) (x).begin(),(x).end()
#define all1(x) (x).begin()+1,(x).end()
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define cin std::cin
#define cout std::cout
typedef long long LL;
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;

//const int MN = 2e5 + 20;
const int INF = 2e9 + 1000;//INF
const LL INFLL = 8e18 + 1000;//INF long long 
mt19937 mrand(chrono::steady_clock().now().time_since_epoch().count());
const int mod = 1e9 + 7;
LL MOD(LL x) {
    if(x >= mod) return x - mod;
    if(x < 0) return x + mod;
    return x;
}
LL mul(int a, int b) {
    return 1LL * a * b % mod;
}
//模板区域~~~~~~~

//模板结束~~~~~~~

void solve() {
    int n; cin >> n;
    V<int> a(n + 2);
    V<LL> pow2(n + 1);
    pow2[0] = 1;
    for(int i = 1; i <= n; i++) pow2[i] = MOD(pow2[i - 1] + pow2[i - 1]);
    for(int i = 1; i <= n;i++) cin >> a[i];
    a[n + 1] = INF;
    V<V<V<LL>>> dp(n + 2, V<V<LL>>(56, V<LL>(56)));
    V<V<V<LL>>> cnt(n + 2, V<V<LL>>(56, V<LL>(56)));
    cnt[1][0][0] = 1;

    for(int i = 1; i <= n; i++) {
        for(int p = 0; p <= 55; p++) {
            for(int p2 = 0; p2 <= 55; p2++) {
                //0
                int n_p = p ? p + a[i + 1] - a[i] : 0, n_p2 = p2 ? p2 + a[i + 1] - a[i] : 0;
                if(i == n || n_p >= 56) n_p = 0;
                if(i == n || n_p2 >= 56) n_p2 = 0;
                // if(dp[i][p][p2] && i == n) cout << "HI" << " " << n_p << " " << n_p2 << endl;
                dp[i + 1][n_p][n_p2] = MOD(dp[i + 1][n_p][n_p2] + dp[i][p][p2]);
                cnt[i + 1][n_p][n_p2] = MOD(cnt[i + 1][n_p][n_p2] + cnt[i][p][p2]);
                //1
                dp[i][p][p2] = MOD(dp[i][p][p2] + mul(cnt[i][p][p2], 2));
                if(p2) {
                    int to = a[i] - p2 + 75;
                    to = lb(all1(a), to) - a.begin();
                    dp[to][0][0] = MOD(dp[to][0][0] + mul(dp[i][p][p2], pow2[to - i - 1]));
                    cnt[to][0][0] = MOD(cnt[to][0][0] + mul(cnt[i][p][p2], pow2[to - i - 1]));
                    
                } else {
                    int to = a[i] + 20;
                    to = lb(all1(a), to) - a.begin();
                    int n_p = p ? p + a[to] - a[i] : 0, n_p2 = p2 ? p2 + a[to] - a[i] : 0;
                    n_p2 = n_p, n_p = a[to] - a[i];
                    if(to == n + 1 || n_p >= 56) n_p = 0;
                    if(to == n + 1 || n_p2 >= 56) n_p2 = 0;

                    // if(dp[i][p][p2]) cout << "at : " << i << "to : " << to << " " << n_p << " " << n_p2 << endl
                    //     , cout << dp[i][p][p2] * pow2[to - i] << endl;
                    dp[to][n_p][n_p2] = MOD(dp[to][n_p][n_p2] + mul(dp[i][p][p2], pow2[to - i - 1]));
                    cnt[to][n_p][n_p2] = MOD(cnt[to][n_p][n_p2] + mul(cnt[i][p][p2], pow2[to - i - 1]));
                }
            }
        }
    }

    cout << dp[n + 1][0][0] << endl;
}

int32_t main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int t=1;
    //cin >> t;
    while (t--) 
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3996kb

input:

3
1 8 20

output:

14

result:

ok 1 number(s): "14"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3984kb

input:

5
25 45 65 85 1000000000

output:

156

result:

ok 1 number(s): "156"

Test #3:

score: -100
Wrong Answer
time: 68ms
memory: 56740kb

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:

208687381

result:

wrong answer 1st numbers differ - expected: '932594593', found: '208687381'