#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
996 KB |
Output is correct |
4 |
Correct |
1 ms |
996 KB |
Output is correct |
5 |
Correct |
1 ms |
996 KB |
Output is correct |
6 |
Correct |
1 ms |
996 KB |
Output is correct |
7 |
Correct |
1 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
456 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
1252 KB |
Output is correct |
7 |
Correct |
3 ms |
1252 KB |
Output is correct |
8 |
Correct |
3 ms |
1252 KB |
Output is correct |
9 |
Correct |
3 ms |
1344 KB |
Output is correct |
10 |
Correct |
3 ms |
1252 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
456 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
1252 KB |
Output is correct |
7 |
Correct |
3 ms |
1252 KB |
Output is correct |
8 |
Correct |
3 ms |
1252 KB |
Output is correct |
9 |
Correct |
3 ms |
1344 KB |
Output is correct |
10 |
Correct |
3 ms |
1252 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
1288 KB |
Output is correct |
21 |
Correct |
3 ms |
1252 KB |
Output is correct |
22 |
Correct |
2 ms |
1252 KB |
Output is correct |
23 |
Correct |
3 ms |
1252 KB |
Output is correct |
24 |
Correct |
3 ms |
1112 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
3 ms |
1252 KB |
Output is correct |
27 |
Correct |
3 ms |
1252 KB |
Output is correct |
28 |
Correct |
1 ms |
996 KB |
Output is correct |
29 |
Correct |
3 ms |
1252 KB |
Output is correct |
30 |
Correct |
3 ms |
1252 KB |
Output is correct |
31 |
Correct |
3 ms |
1344 KB |
Output is correct |
32 |
Correct |
3 ms |
1252 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |