QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#162541 | #7109. Traveling on the Axis | notpasscet_6# | WA | 2ms | 5344kb | C++20 | 837b | 2023-09-03 14:08:24 | 2023-09-03 14:08:26 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+5,inf=1e9;
int dp[maxn][2];
void solve()
{
string s;
cin>>s;
int n=s.size();
fill_n(*dp,(n+1)*2,0);
int ans=0;
for(int i=1; i<=n; i++)
{
ans+=(i+1)*i/2;
dp[i][0]++;
if(s[i-1]=='0')
{
ans+=dp[i][0];
dp[i+1][0]=dp[i][0]+dp[i][1];
dp[i+1][1]=dp[i][0];
}
else
{
ans+=dp[i][1];
dp[i+1][1]=dp[i][0]+dp[i][1];
dp[i+1][0]=dp[i][1];
}
}
cout<<ans<<"\n";
}
signed main()
{
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3580kb
input:
3 101 011 11010
output:
12 15 43
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 5344kb
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 1275 24 1650 71 1917 323 352 14 106 1808 891 651 1519 1139 2753 1920 736 1356 6 15 602 44 1857 1650 140 913 497 776 24 1640 902 493 30 465 14 1041 2339 96 504 125 79 602 1088 841 1065 6 1 321 132 786 832 224 756 46 106 272 74 662 2 100 574 275 217 209 2 209 1041 140 1149 217 1 76 2148 41 355 1041...
result:
wrong answer 2nd lines differ - expected: '889', found: '1275'