Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstring>
- using namespace std;
- const int N = 50 + 5;
- int a[N][N];
- char r[N], c[N];
- bool rr[N], cc[N];
- int main() {
- scanf("%s%s", r, c);
- int nr = strlen(r);
- int nc = strlen(c);
- for (int i = 0; i < nr; i++) {
- rr[i] = r[i] - '0' != nc % 2;
- }
- for (int i = 0; i < nc; i++) {
- cc[i] = c[i] - '0' != nr % 2;
- }
- for (int i = 0; i < nr; i++) {
- for (int j = 0; j < nc; j++) {
- a[i][j] = 1;
- }
- }
- for (int i = 0; i < nr; i++) {
- if (rr[i]) {
- //printf("need fix -- %d\n", i);
- bool flag = false;
- for (int j = 0; j < nc; j++) {
- if (cc[j]) {
- rr[i] = false;
- cc[j] = false;
- a[i][j] ^= 1;
- flag = true;
- break;
- }
- }
- if (!flag) {
- //puts("oops");
- rr[i] = false;
- cc[0] = true;
- a[i][0] ^= 1;
- }
- }
- }
- /*
- puts("---");
- for (int i = 0; i < nr; i++) {
- for (int j = 0; j < nc; j++) {
- printf("%d", a[i][j]);
- }
- puts("");
- }
- puts("---");
- */
- for (int i = 0; i < nc; i++) {
- if (cc[i]) {
- bool flag = false;
- for (int j = 0; j < nr; j++) {
- if (rr[j]) {
- cc[i] = false;
- rr[j] = false;
- a[j][i] ^= 1;
- flag = true;
- break;
- }
- }
- if (!flag) {
- cc[i] = false;
- rr[0] = true;
- a[0][i] ^= 1;
- }
- }
- }
- for (int i = 0; i < nr; i++) {
- if (rr[i]) {
- puts("-1");
- return 0;
- }
- }
- for (int i = 0; i < nc; i++) {
- if (cc[i]) {
- puts("-1");
- return 0;
- }
- }
- for (int i = 0; i < nr; i++) {
- int cnt = 0;
- for (int j = 0; j < nc; j++) {
- cnt += a[i][j];
- }
- }
- for (int i = 0; i < nr; i++) {
- for (int j = 0; j < nc; j++) {
- printf("%d", a[i][j]);
- }
- puts("");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement