QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#169015#6625. BinariaAlphaban0 2ms3580kbC++142.3kb2023-09-09 10:47:072023-09-09 10:47:07

Judging History

你现在查看的是最新测评结果

  • [2023-09-09 10:47:07]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:3580kb
  • [2023-09-09 10:47:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 2e5;

int n, m, p[N + 5], q[N + 5];char s[N + 5], t[5];

void read(int &x) {
    x = 0; int w = 1; char c = getchar(); for(; c < '0' || c > '9'; c = getchar()) if (c == '-') w = -1;
    for(; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + c - '0'; x *= w;
}

int main() {
	// freopen("sample6.in", "r", stdin);
	scanf("%s %s", s + 1, t + 1);
	n = strlen(s + 1); m = strlen(t + 1);
	if (m == 1) {
		for(int i = 1; i <= n; ++i)
			if (s[i] == t[1]) {
				puts("-1");
				return 0;
			}
		puts("0");
		return 0;
	}
	if (m == 2) {
		if (t[1] == '1' && t[2] == '0') {
			t[1] = '0'; t[2] = '1';
			for(int i = 1; i <= n; ++i)
				if (s[i] == '0') s[i] = '1';
				else s[i] = '0';
		}
		if (t[1] == '0' && t[2] == '1') {
			int ans = 0;
			for(int i = 1; i < n; ++i)
				if (s[i] == '0' && s[i + 1] == '1') ++ans;
			printf("%d\n", ans);
			return 0;
		}
		if (t[1] == '1' && t[2] == '1') {
			t[1] = '0'; t[2] = '0';
			for(int i = 1; i <= n; ++i)
				if (s[i] == '0') s[i] = '1';
				else s[i] = '0';
		}
		int s0 = 0, s1 = 0;
		for(int i = 1; i <= n; ++i)
			if (s[i] =='0') ++s0;else ++s1;
		if (s1 < s0 - 1) {
			puts("-1");
			return 0;
		}
		int ans = 0;
		for(int i = 2; i <= n; ++i)
			if (s[i] == '0' && s[i - 1] == '0') ++ans;
		printf("%d\n", ans);
		return 0;
	}
	if (m == 3) {
		// cout << "dd"<< endl;
		if (t[1] != t[3]) {
			if (t[1] == '1') {
				t[1] = '0'; t[3] = '1'; 
				if (t[2] == '0') t[2] = '1'; t[2] = '0';
				for(int i = 1; i <= n; ++i)
					if (s[i] == '0') s[i] = '1'; else s[2] = '0';
			}
			int ans = 0;
			for(int i = 1; i < n; ++i)
				if (s[i] == '1' && s[i + 1] == '0') ++ans;
			printf("%d\n", ans);
			return 0;
		}
		if (t[1] != t[2]) {
			if (t[1] == '1') {
				t[1] = '0'; t[3] = '0'; t[2] = '1';
				for(int i = 1; i <= n; ++i)
					if (s[i] == '0') s[i] = '1'; else s[i] = '0';
			}
			int ans = 0;
			for(int i = 2; i < n; ++i)
				if (s[i - 1] == '0' && s[i] == '1' && s[i + 1] == '0') ++ans;
			printf("%d\n", (ans + 1) / 2);
			return 0;
		}
		if (t[1] == '1') {
			t[1] = '0'; t[2] = '0'; t[3] = '0';
			for(int i = 1; i <= n; ++i)
				if (s[i] == '0') s[i] = '1'; else s[i] = '0';

		}
		return 0;
	}
	return 0;
}
/*
010

010

0000011111
//2


00001111110000

*/

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3580kb

input:

1 1
0

output:

-1

result:

wrong answer 1st numbers differ - expected: '1', found: '-1'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%