Submission
Status:
[PPPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Nay-O
Problemset: A.Six Zero
Language: cpp
Time: 0.022 second
Submitted On: 2026-03-21 11:29:29
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n; cin>>n;
while(n--){
string str; cin>>str;
vector<ll> v;
ll z[str.size()],c = 0;
for(int i = str.size()-1; i >= 0; i--){
if(str[i]=='0'){
c++;
}
else{
z[i] = c;
v.push_back({i});
}
}
ll ans = 0;
for(auto value : v){
ans += z[value]*(z[value]-1)/2;
ans %= MOD;
}
cout << ans << "\n";
}
return 0;
}