#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
const int maxn = 1e3+10;
int n, m;
string g[maxn];
void solve() {
cin>>n>>m;
bool flip = false;
if (n<m) {
flip = true;
swap(n,m);
}
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
g[i][j] = '+';
}
}
int col = 0;
int drop = n/2+1;
for (int j=0; j<(m-1)/2; j++) {
for (int i=0; i<n; i++) {
g[i][col] = '-';
if (--drop == 0) {
col++;
drop = n/2+1;
}
}
}
cout<<n+col<<"\n";
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
if (flip) g[i][j]=char('+'+'-'-g[i][j]);
}
}
if (flip) {
swap(n,m);
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
cout<<g[j][i];
}
cout<<"\n";
}
} else {
for (int i=0; i<n; i++) {
for (int j=0; j<m; j++) {
cout<<g[i][j];
}
cout<<"\n";
}
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int t;
cin>>t;
while (t--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Halted |
0 ms |
0 KB |
- |