求助11分
查看原帖
求助11分
222865
迟暮天复明心華楼主2021/2/9 20:08
#include<stdio.h>
#include<string.h>
#define reg register
#define ri reg int
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define nrep(i, x, y) for(ri i = x; i >= y; --i)
#define DEBUG 1
#define ll long long
#define max(i, j) (i) > (j) ? (i) : (j)
#define min(i, j) (i) < (j) ? (i) : (j)
#define read(i) io.READ(i)
#define print(i) io.WRITE(i)
#define push(i) io.PUSH(i)
struct IO {
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
	char buf[MAXSIZE], *p1, *p2;
	char pbuf[MAXSIZE], *pp;
	#if DEBUG
	#else
		IO() : p1(buf), p2(buf), pp(pbuf) {}
		~IO() {
			fwrite(pbuf, 1, pp - pbuf, stdout);
		}
	#endif
	inline char gc() {
		#if DEBUG
    		return getchar();
		#endif
    	if(p1 == p2)
			p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    	return p1 == p2 ? ' ' : *p1++;
	}
	inline bool blank(char ch) {
    	return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
	}
	template <class T>
	inline void READ(T &x) {
    	register double tmp = 1;
    	register bool sign = 0;
    	x = 0;
    	register char ch = gc();
    	for(; !isdigit(ch); ch = gc())
    		if(ch == '-') sign = 1;
    	for(; isdigit(ch); ch = gc())
			x = x * 10 + (ch - '0');
    	if(ch == '.')
			for(ch = gc(); isdigit(ch); ch = gc())
        		tmp /= 10.0, x += tmp * (ch - '0');
    	if(sign) x = -x;
	}
	inline void READ(char *s) {
		register char ch = gc();
		for(; blank(ch); ch = gc());
		for(; !blank(ch); ch = gc())
			*s++ = ch;
    	*s = 0;
	}
	inline void READ(char &c) {
    	for(c = gc(); blank(c); c = gc());
	}
	inline void PUSH(const char &c) {
		#if DEBUG
    		putchar(c);
		#else
    		if(pp - pbuf == MAXSIZE) {
				fwrite(pbuf, 1, MAXSIZE, stdout);
				pp = pbuf;
			}
    		*pp++ = c;
		#endif
	}
	template <class T>
	inline void WRITE(T x) {
    	if(x < 0) {
			x = -x;
			PUSH('-');
		}
    	static T sta[35];
    	T top = 0;
    	do {
			sta[top++] = x % 10;
			x /= 10;
    	}while(x);
    	while(top)
			PUSH(sta[--top] + '0');
	}
	template <class T>
	inline void WRITE(T x, char lastChar) {
    	WRITE(x);
		PUSH(lastChar);
	}
} io;
char a[1000010];
int main() {
	ri l = 0, len;
	char a_1[1000010], a_2[1000010];
	scanf("%s", a);
	len = strlen(a);
	nrep(i, len - 1, 0) 
		if(a[i] != 'Z') l = 1;
		else if(l && a[i] == 'Z') { l = 2; break; }
	if(l == 2) {
		print(-1);
		return 0;
	}
	nrep(i, len - 1, 0) {
		if(a[i] == 'Z') a_1[i] = a_2[i] = '1';
		else if(a[i] == 'X') a_1[i] = '1', a_2[i] = '0';
		else a_1[i] = '0', a_2[i] = '1';
	}
	puts(a_1), puts(a_2);
	return 0;
}
2021/2/9 20:08
加载中...