#include <bits/stdc++.h>
#define ll long long
#define s second
#define pb push_back
#define f first
#define left (h<<1),l,((l+r)>>1)
#define right ((h<<1)|1),((l+r)>>1) + 1,r
#define pii pair<int,int>
// #define int ll // ?
using namespace std;
const int N = 1005,mod = 1000000007; // ?
int a[N][N],y[N],x[N],f[N];
int ans,n,m;
void solve(){
if (m >= n){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
a[i][j] = 0;
//column-ebs ar vapucheb
ans = m; int k = m/2 + 1;
for (int j = 1; j <= m; j++) y[j] = n - n/2 - 1;
for (int i = 1; i <= n; i++){
int cnt = 0;
for (int j = 1; j <= m; j++) f[j] = 0;
for (int j = 1; j <= m; j++){
if (y[j]) {
--y[j];
f[j] = 1;
cnt++;
}
if (cnt == k) {
++ans;
break;
}
}
if (cnt < k) break;
for (int j = 1; j <= m; j++)
if (f[j]) a[i][j] = 1;
}
return;
}
//n > m
//row-ebs ar vapucheb
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
a[i][j] = 1;
ans = n; int k = n/2 + 1;
for (int i = 1; i <= n; i++) x[i] = m - m/2 - 1;
for (int j = 1; j <= m; j++){
int cnt=0;
for (int i = 1; i <= n; i++) f[i] = 0;
for (int i = 1; i <= n; i++){
if (x[i]){
--x[i];
f[i] = 1;
++cnt;
}
if (cnt == k) {
++ans;
break;
}
}
if (cnt < k) break;
for (int i = 1; i <= n; i++){
if (f[i]) a[i][j] = 0;
}
}
}
signed main (){
ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
int T;
cin>>T;
while (T--){
cin>>n>>m;
solve();
cout<<ans<<endl;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= m; j++){
if (a[i][j]) cout<<"+";
else cout<<"-";
}
cout<<"\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Incorrect |
3 ms |
596 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
1660 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
1868 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Incorrect |
3 ms |
596 KB |
Wrong answer in test 5 29: 31 < 32 |
5 |
Halted |
0 ms |
0 KB |
- |