QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#709381#7109. Traveling on the AxisProaesWA 0ms3548kbC++201.1kb2024-11-04 14:29:172024-11-04 14:29:18

Judging History

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

  • [2024-11-04 14:29:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3548kb
  • [2024-11-04 14:29:17]
  • 提交

answer

/**
 *    title:  h.cpp
 *    author:  Proaes Meluam
 *    created:  2024-10-21 19:00:47
**/
#include <bits/stdc++.h>
#ifdef LOCAL
#include "algo/debug.h" 
#else
#define debug(...) 42
#endif
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double pi = acos(-1);
const double E = exp(1);
constexpr ll mod = 1e9 + 7;
// constexpr int inf = 0x3f3f3f3f;
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int tt = 1;
    cin >> tt;
    while (tt--) {
        string s;
        cin >> s;
        ll n = s.size();
        s = " " + s;
        ll ans = 0;
        for (ll i = 1; i <= n; ++ i) {
            ans += i * ((ll)n - i + 1ll);
        }
        vector<vector<ll>> dp(2, vector<ll>(n + 2)); // 0 正 ;1 反
        for (int i = n; i >= 1; -- i) {
            dp[s[i] - '0'][i]++;
            dp[1][i] += dp[0][i + 1];
            dp[0][i] += dp[1][i + 1];
        }
        for (int i = 1; i <= n; ++ i) {
            ans += dp[0][i];
            // cout << dp[i] << " \n"[i == n];
        }
        cout << ans << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3548kb

input:

3
101
011
11010

output:

12
13
43

result:

wrong answer 2nd lines differ - expected: '15', found: '13'