QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#169014#6625. BinariaAlphabanCompile Error//C++142.5kb2023-09-09 10:46:312023-09-09 10:46:32

Judging History

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

  • [2023-09-09 10:46:32]
  • 评测
  • [2023-09-09 10:46:31]
  • 提交

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';

		}
		int ans = 0, lst = 0;
		for(int i = 3; i <= n; ++i)
			if (s[i] == '0') {
				++lst;
				ans = max(ans, lst);
			}
			else {
				ans += (lst + 1) / 2;
			}
		printf("%d\n", (ans + 1) / 2);
		return 0;
	}
	return 0;
}
/*
010

010

0000011111
//2


00001111110000

*/

详细

answer.code: In function ‘int main()’:
answer.code:99:52: error: unable to find numeric literal operator ‘operator"";’
   99 |                                 ans += (lst + 1) / 2;
      |                                                    ^~~
answer.code:99:52: note: use ‘-fext-numeric-literals’ to enable more built-in suffixes
answer.code:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf("%s %s", s + 1, t + 1);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~