Submission #793732

# Submission time Handle Problem Language Result Execution time Memory
793732 2023-07-26T06:03:09 Z 곰(#10095) Flip it and Stick it (CCO23_day2problem1) C++17
8 / 25
2 ms 1372 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
using ll=long long;
using pll=array<ll,2>;
const ll inf=1e18;
const int N=2e5+5;
string s,t;
int n,m,a[N],b[N];
ll ans=inf;
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>s>>t;
	n=s.size();
	m=t.size();
	if(n<m){
		cout<<0;
		return 0;
	}
	for(int i=1;i<=n;i++) a[i]=s[i-1]-'0';
	for(int i=1;i<=m;i++) b[i]=t[i-1]-'0';
	if(b[1]==1){
		for(int i=1;i<=n;i++) a[i]^=1;
		for(int i=1;i<=m;i++) b[i]^=1;
	}
	if(m==1){
		ans=0;
		for(int i=1;i<=n;i++) if(a[i]==b[1]) ans=-1;
	} else if(m==2){
		if(b[1]==b[2]){
			int cnt0=0;
			ans=0;
			for(int i=1;i<=n;i++){
				if(!a[i]) cnt0++;
				if(i<n&&!a[i]&&!a[i+1]) ans++;
			}
			if(cnt0>(n+1)/2) ans=-1;
		} else{
			ans=0;
			for(int i=1;i<=n;i++){
				int j=i;
				while(j+1<=n&&a[i]==a[j+1]) j++;
				if(i!=1&&a[i]==1) ans++;
				i=j;
			}
		}
	}
	cout<<ans;
	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 1372 KB Output is correct
4 Correct 1 ms 1372 KB Output is correct
5 Correct 1 ms 1372 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1372 KB Output is correct
9 Correct 2 ms 1324 KB Output is correct
10 Correct 2 ms 1372 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 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 1 ms 1372 KB Output is correct
8 Correct 1 ms 1372 KB Output is correct
9 Correct 2 ms 1324 KB Output is correct
10 Correct 2 ms 1372 KB Output is correct
11 Correct 0 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 1 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 0 ms 212 KB Output is correct
20 Correct 1 ms 1372 KB Output is correct
21 Correct 1 ms 1372 KB Output is correct
22 Correct 1 ms 1372 KB Output is correct
23 Correct 2 ms 1372 KB Output is correct
24 Correct 2 ms 1372 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 1372 KB Output is correct
27 Correct 2 ms 1372 KB Output is correct
28 Correct 2 ms 1372 KB Output is correct
29 Correct 1 ms 1372 KB Output is correct
30 Correct 1 ms 1372 KB Output is correct
31 Correct 2 ms 1372 KB Output is correct
32 Correct 2 ms 1372 KB Output is correct
33 Correct 0 ms 340 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 1 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 -