QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#242824 | #7109. Traveling on the Axis | xuxubaobao | WA | 1ms | 6532kb | C++17 | 748b | 2023-11-07 17:38:12 | 2023-11-07 17:38:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using PII = pair<int,int>;
using ll = long long;
constexpr int N = 2e6 + 10;
ll dp1[N];
ll dp2[N];
void solve() {
string k;
cin >> k;
k = " " + k;
for(int i = k.size() - 2; i >= 0; i --) {
if(k[i + 1] == '1') {
dp1[i] = dp2[i + 1] + 1 * (k.size() - i - 1);
dp2[i] = dp2[i + 1] + 2 * (k.size() - i - 1);
}
else {
dp1[i] = dp1[i + 1] + 2 * (k.size() - i - 1);
dp2[i] = dp1[i + 1] + 1 * (k.size() - i - 1);
}
}
ll ans = 0;
for(int i = 0; i <= k.size() - 2; i ++) {
ans += dp1[i];
}
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
t = 1;
cin >> t;
while(t --){
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5632kb
input:
3 101 011 11010
output:
12 15 43
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 6532kb
input:
6107 1010101 010110100110101 1010 1010101010010101010 101011 0101101011010101010 0101101011 11011010101 010 1011010 10110101010101010100 010101010110101 10101010101011 0101010101010101011 00101010011000 1010101010010110110 01010101001010101010 101010101010101 100100101010101010 01 011 0101010100101 ...
output:
96 889 336 1515 747 1567 729 829 275 512 1702 1106 943 1466 1072 1653 1755 961 1387 310 468 776 334 1689 1534 836 998 705 804 300 1640 1072 822 318 809 251 1143 1500 810 803 432 351 794 1098 921 1041 240 120 607 417 906 846 431 889 361 411 540 344 697 96 359 672 460 396 386 60 386 1109 604 992 585 9...
result:
wrong answer 3rd lines differ - expected: '24', found: '336'