Submission

Status:

[PPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: anonymous

Problemset: A.Six Zero

Language: cpp

Time: 0.181 second

Submitted On: 2026-11-07 11:02:38

#include <bits/stdc++.h>
using namespace std;

const int Mod = 1e9 + 7;
int main(){
    int n; cin >> n;
    while(n--){
        string s; cin >> s;
        vector<long long> a;

        long long word[s.size()], c=0;
        for(int i = s.size() - 1;i >= 0;i--){
            if(s[i] == '0') c++;
            else{
                word[i] = c;
                a.push_back({i});
            }
        }

        long long ans = 0;
        for(auto i : a){
            ans += word[i] * (word[i] - 1) / 2;
            ans %= Mod;
        }

        cout << ans << '\n';
    }
}