답안 #171032

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171032 2019-12-27T06:19:13 Z antimirage Red-blue table (IZhO19_stones) C++14
11 / 100
42 ms 4856 KB
#include <bits/stdc++.h>
    
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
    
using namespace std;

const int N = 1005;

int tests, n, m, a[N][N], cn[N], ans;

void Fill (int x) {
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			a[i][j] = x;
		}
	}
}
int Nxt(int x, int o) {
	x++;
	if (x > o) x = 1;
	return x;
}

main() {
	cin >> tests;
	while (tests--) {
		memset(cn, 0, sizeof(cn) );
		scanf("%d%d", &n, &m);
		int l = 1;
		if (n >= m) {
			ans = n;
			Fill(0);
			for (int i = 1; i <= m; i++) {
				bool ok = 0;
				for (int j = 0; j < n / 2 + 1; j++) {
					if (cn[l] + 1 >= m / 2 + 1) {
						ok = 1;
						break;
					}
					a[l][i] = 1; cn[l]++;
					l = Nxt(l, n);
				}
				if (ok) break;
				ans++;
			}
		} else {
			ans = m;
			Fill(1);
			for (int i = 1; i <= n; i++) {
				bool ok = 0;
				for (int j = 0; j < m / 2 + 1; j++) {
					if (cn[l] + 1 >= n / 2 + 1) {
						ok = 1;
						break;
					}
					a[i][l] = 0; cn[l]++;
					l = Nxt(l, m);
				}
				if (ok) break;
				ans++;
			}
		}
		printf("%d\n", ans);
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				printf(a[i][j] == 0 ? "+" : "-");
			}
			printf("\n");
		}
	}
}

Compilation message

stones.cpp:28:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
stones.cpp: In function 'int main()':
stones.cpp:32:8: 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 Incorrect 2 ms 376 KB in the table A+B is not equal to 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 508 KB in the table A+B is not equal to 21
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 5
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 1784 KB Output is correct
2 Correct 40 ms 4216 KB Output is correct
3 Correct 41 ms 4856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 1964 KB in the table A+B is not equal to 46
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 5