답안 #168087

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168087 2019-12-11T10:30:07 Z YottaByte Red-blue table (IZhO19_stones) C++14
27 / 100
51 ms 1916 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 N = 1e3;
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, ans[N + 1][N + 1];

inline void purify() {
}

inline void precalc() {
}

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

void out() {
	char a = '+', b = '-';
	if ((n - 1) / 2 + m >= (m - 1) / 2 + n) {
		swap(a, b);
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			ans[i][j] = a;
		}
	}

	if ((n - 1) / 2 + m >= (m - 1) / 2 + n) {
		cout << (n - 1) / 2 + m << endl;

		int cntp = 0;
		int ii = 0, jj = 1;
		int perline = m / 2 + 1;

		while (cntp < ((n - 1) / 2) * perline) {
			if (cntp % perline == 0) {
				ii++;
			}

			jj--;
			jj %= m;
			jj++;

			ans[ii][jj++] = b;
			cntp++;
		}
	} else {
		cout << (m - 1) / 2 + n << endl;

		int cntm = 0;
		int ii = 1, jj = 0;
		int percol = n / 2 + 1;

		while (cntm < ((m - 1) / 2) * percol) {
			if (cntm % percol == 0) {
				jj++;
			}

			ii--;
			ii %= n;
			ii++;

			ans[ii++][jj] = b;
			cntm++;
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cout << (char) ans[i][j];
		}
		cout << endl;
	}
}

inline void solve() {
	out();
	return;
	if ((n - 1) / 2 + m >= (m - 1) / 2 + n) {
		cout << (n - 1) / 2 + m << endl;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (i <= (n - 1) / 2) {
					if (j <= m / 2 + 1) {
						cout << '+';
						continue;
					}
				}
				cout << '-';
			}
			cout << endl;
		}
	} else {
		cout << (m - 1) / 2 + n << endl;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (i <= n / 2 + 1) {
					if (j <= (m - 1) / 2) {
						cout << '-';
						continue;
					}
				}
				cout << '+';
			}
			cout << endl;
		}
	}
}

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

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

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:126: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:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Incorrect 4 ms 632 KB Wrong answer in test 5 29: 31 < 32
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 1704 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 1916 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Incorrect 4 ms 632 KB Wrong answer in test 5 29: 31 < 32