This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int Count(string S, string T) {
int ret = 0;
for (int i = 0; i + T.size() <= S.size(); ++i) {
ret += (S.substr(i, T.size()) == T);
}
return ret;
}
int Solve(string S, string T) {
if (T.size() == 1) return (S.find(T) == string::npos ? 0 : -1);
if (T[0] == '1') {
for (char& c : S) c ^= 1;
for (char& c : T) c ^= 1;
}
if (T == "01") return Count(S, T);
if (T == "00") {
int lim = (S.size() + 1) / 2, zero = 0;
for (char c : S) zero += (c == '0');
if (lim < zero) return -1;
return Count(S, T);
}
return 0;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
string S, T;
cin >> S >> T;
cout << Solve(S, T);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |