제출 #769980

#제출 시각아이디문제언어결과실행 시간메모리
769980rainboyRed-blue table (IZhO19_stones)C11
100 / 100
11 ms2208 KiB
#include <stdio.h>

#define N	1000
#define M	1000

int min(int a, int b) { return a < b ? a : b; }

int main() {
	int t;

	scanf("%d", &t);
	while (t--) {
		static char cc[N][M + 1];
		int n, m, i, j, a, b, a_, b_;

		scanf("%d%d", &n, &m);
		a_ = b_ = 0;
		for (a = 0; a <= n; a++) {
			b = a <= (n - 1) / 2 ? m : min(a * ((m - 1) / 2) / (a - (n - 1) / 2), m);
			if (a_ + b_ < a + b)
				a_ = a, b_ = b;
		}
		for (i = 0; i < n; i++) {
			for (j = 0; j < m; j++)
				if (j >= b_)
					cc[i][j] = '+';
				else if (i >= a_)
					cc[i][j] = '-';
				else
					cc[i][j] = (j - (b_ - (m - 1) / 2) * i % b_ + b_) % b_ < b_ - (m - 1) / 2 ? '+' : '-';
			cc[i][m] = 0;
		}
		printf("%d\n", a_ + b_);
		for (i = 0; i < n; i++)
			printf("%s\n", cc[i]);
	}
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

stones.c: In function 'main':
stones.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &t);
      |  ^~~~~~~~~~~~~~~
stones.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d%d", &n, &m);
      |   ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...