-
Notifications
You must be signed in to change notification settings - Fork 62
/
ROWSOLD.cpp
64 lines (58 loc) · 1.44 KB
/
ROWSOLD.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~© Aashutosh Rathi~~~~~~
// ~~~~~~~~aashutosh001~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <bits/stdc++.h>
#include <stdio.h>
#include <string>
using namespace std;
#define mod(x) x%1000000007;
#define MIN(n1, n2 ) ((n1) > (n2) ? (n2) : (n1))
#define MAX(n1, n2 ) ((n1) > (n2) ? (n1) : (n2))
#define MID(s, e) (s+(e-s)/2)
#define FOR(i, a, b) int i; for(i=(a);i<(b);i++)
#define FORD(i, a, b) int i; for(i=(a);i>(b);i--)
#define show(a) for(i=0;i<sizeof(a);i++) cout<<a[i]<<" ";
#define get(a) for(i=0;i<sizeof(a);i++) cin>>a[i];
#define scanint(a) scanf("%d",&a)
#define scanLLD(a) scanf("%lld",&a)
#define scanstr(s) scanf("%s",s)
#define scanline(l) scanf(" %[^\n]",l);
typedef long int BIG;
typedef long long PAPA;
int main()
{
std::ios_base::sync_with_stdio(false);
PAPA t;
cin >> t;
while(t--) {
string str;
cin >> str;
PAPA one = 0, zero = 1, result = 0, i;
PAPA size = str.size();
for (i = 0; i < size; i++) {
if(str[i] == '1') {
if(i == size - 1) {
zero = 0; // reset the zero counter
}
i++;
one ++; // one counter increment
while(str[i] == '1') {
if(i == size - 1){
zero = 0; // reset the zero counter
}
i++;
one ++; // one counter increment
}
while(str[i] == '0') {
zero++;
i++;
}
--i;
}
result = result + one*zero;
zero = 1; // reset zero count to 1
}
cout<<result<<endl;
}
}