Submission #793587

# Submission time Handle Problem Language Result Execution time Memory
793587 2023-07-26T04:22:35 Z 박영우(#10061) Flip it and Stick it (CCO23_day2problem1) C++17
8 / 25
3 ms 748 KB
#include <bits/stdc++.h>
#include <cassert>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 2023
#define MAXS 500
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	string s, t;
	cin >> s >> t;
	if (s.size() < t.size()) {
		cout << 0 << ln;
		return 0;
	}
	if (t[0] == '1') {
		for (auto& c : s) c ^= 1;
		for (auto& c : t) c ^= 1;
	}
	if (t.size() == 1) {
		for (auto c : s) {
			if (c == t[0]) {
				cout << -1 << ln;
				return 0;
			}
		}
		cout << 0 << ln;
		return 0;
	}
	if (t.size() == 2) {
		if (t[0] == t[1]) {
			int N = s.size();
			int i;
			int cnt = 0;
			for (i = 0; i < N; i++) if (s[i] == '1') cnt++;
			if (cnt < N / 2) {
				cout << -1 << ln;
				return 0;
			}
			int ans = 0;
			for (i = 0; i + 1 < N; i++) if (s[i] == s[i + 1] && s[i] == '0') ans++;
			cout << ans << ln;
			return 0;
		}
		int N, i;
		N = s.size();
		int pv = 1;
		int ans = 0;
		for (i = 0; i < N; i++) {
			if (s[i] == '1') {
				if (!pv) {
					pv = 1;
					ans++;
				}
			}
			else pv = 0;
		}
		cout << ans << ln;
		return 0;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 704 KB Output is correct
21 Correct 1 ms 704 KB Output is correct
22 Correct 1 ms 700 KB Output is correct
23 Correct 3 ms 604 KB Output is correct
24 Correct 3 ms 676 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 3 ms 664 KB Output is correct
27 Correct 3 ms 680 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 3 ms 748 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 3 ms 724 KB Output is correct
32 Correct 3 ms 668 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -