QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#709381 | #7109. Traveling on the Axis | Proaes | WA | 0ms | 3548kb | C++20 | 1.1kb | 2024-11-04 14:29:17 | 2024-11-04 14:29:18 |
Judging History
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'