Submission #167852

# Submission time Handle Problem Language Result Execution time Memory
167852 2019-12-10T14:54:29 Z YottaByte Red-blue table (IZhO19_stones) C++14
0 / 100
48 ms 1400 KB
#include <iostream>

using namespace std;

#define ll long long
#define sz(x) (int)x.size()
#define pii pair < int, int >
#define endl "\n"
#define METH ios::sync_with_stdio(0); cin.tie(0);
#define BEGIN cout << "BEGIN" << endl;
#define END cout << "END" << endl;

const int mod = 1e9 + 7;										/// ANOTHER HASH MOD: 228228227
const int prime = 29;											/// ANOTHER HASH PRIME: 997
const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8);

int n, m;

inline void purify() {
}

inline void precalc() {
}

inline void read() {
	scanf("%d %d", &n, &m);
}

inline void solve() {
	char a, b;

	if (n < 3 || m < 3) {
		cout << max(n, m) << endl;
		if (m <= n) {
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= m; j++) {
					cout << '+';
				}

				cout << endl;
			}
		} else {
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= m; j++) {
					cout << '-';
				}

				cout << endl;
			}
		}

		return;
	}

	a = '+', b = '-';
	cout << max((n / 2 + m), (m / 2 + n)) << endl;
	if (n / 2 + m < m / 2 + n) {
		swap(a, b);
		for (int i = 1; i <= m; i++) {
			cout << b;
		}
		cout << endl;

		for (int i = 1; i <= n - 2; i++) {
			for (int j = 1; j <= m; j++) {
				if (j <= m / 2) {
					cout << b;
				} else {
					cout << a;
				}
			}

			cout << endl;
		}
		for (int i = 1; i <= m; i++) {
			cout << b;
		}
		cout << endl;
		return;
	}

	for (int i = 1; i <= n; i++) {
		cout << a;
		for (int j = 1; j <= m - 2; j++) {
			if (i <= n / 2) {
				cout << a;
			} else {
				cout << b;
			}
		}

		cout << a << endl;
	}
}

int main() {
	int t;
	scanf("%d", &t);

	//precalc();
	while (t--) {
		//purify();
		read();
		solve();
	}
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:98:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &t);
  ~~~~~^~~~~~~~~~
stones.cpp: In function 'void read()':
stones.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB in the table A+B is not equal to 6
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB in the table A+B is not equal to 46
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB in the table A+B is not equal to 6
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 1272 KB in the table A+B is not equal to 107
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 1400 KB in the table A+B is not equal to 36
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 256 KB in the table A+B is not equal to 6