제출 #1132051

#제출 시각아이디문제언어결과실행 시간메모리
1132051AgageldiRed-blue table (IZhO19_stones)C++17
0 / 100
15 ms1864 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define N 400005
#define ff first
#define ss second
#define pb push_back
#define sz(s) (int)s.size()
#define rep(c, a, b) for(c = a; c <= b; c++)

ll n, t, b[N], m, T;
char a[5000][5000];

int main () {
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> T;
	while(T--) {
		cin >> n >> m;
		for(int i = 1; i <= m; i++) {
			b[i] = n;
		}
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= m; j++) {
				a[i][j] = '-';
			}
		}
		int cnt = 1, ans = 0;
		for(int i = 1; i <= n; i++) {
			t = cnt;
			for(int j = cnt; j <= m; j++) {
				if(b[j] > (n + 1) / 2) {
					a[i][j] = '+';
					b[j]--;
					if(j == m) j = 1;
					t = j + 1;
				}
			}
			cnt = t + 1;
		}
		for(int i= 1;i<=n;i++) {
			t = 0;
			for(int j = 1; j <= m; j++) {
				if(a[i][j] == '+') t++;
				else t--;
			}
			if(t > 0) ans++;
		}
		cout << ans + m << '\n';
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= m; j++) {
				cout << a[i][j];
			}
			cout << '\n';
		}
	}
}
#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...