#include <bits/stdc++.h>
//#define FILENAME ""
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define F first
#define S second
using namespace std;
//#define int long long
const int N = 1e5 + 5;
const int INF = 1e9 + 5;
const double PI = acos(-1);
typedef long long ll;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
const int mod = 1e9 + 7;
int T, n, m;
map<int,int> cnt;
int main() {
#ifdef FILENAME
freopen(FILENAME".in", "r", stdin);
freopen(FILENAME ".out", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> T;
while(T--) {
cin >> n >> m;
bool f = 0;
if (n > m) {
f = 1;
swap(n, m);
}
char a[n + 5][m + 5];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
a[i][j] = '-';
int ans = m;
for (int i = 1; i <= n; i++) {
int res = (m + 2) / 2, mn = INF;
for (int j = 1; j <= m; j++) {
mn = min(mn, cnt[j]);
}
int ct = 0;
for (int j = 1; j <= m; j++) {
ct += (cnt[j] + 1 < (n + 1) / 2 ? 1 : 0);
}
if (ct < res) break;
ans++;
for (int j = 1; j <= m && res; j++) {
if (cnt[j] == mn) {
a[i][j] = '+';
cnt[j]++;
res--;
}
}
for (int j = 1; j <= m && res; j++) {
if (a[i][j] != '+') {
a[i][j] = '+';
cnt[j]++;
res--;
}
}
}
cout << ans << "\n";
if (!f) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++)
cout << a[i][j];
cout << "\n";
}
} else {
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++)
cout << a[i][j];
cout << "\n";
}
}
cnt.clear();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
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 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
in the table A+B is not equal to 2 |
# |
Verdict |
Execution time |
Memory |
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 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
80 ms |
1384 KB |
in the table A+B is not equal to 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
1412 KB |
Output is correct |
2 |
Correct |
181 ms |
1784 KB |
Output is correct |
3 |
Correct |
160 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 2 |