#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ll long long
using namespace std;
ll n,m,tt,t,cl[1005][1005],p[500005],q,d[2000005];
vector <ll > v,edg[500005],v1,v2;
long long y,x,w,e,u,z,l,r,k,typ,sum,mx;
ll Mod = 1e9 + 7;
int main(){
cin >> t;
while(t--){
cin >> n >> m;
mx = 0;
e = 0;
for(int i = 0; i <= n; i++){
x = n / 2 + 1 - (n - i);
y = i;
if(x <= i){
if(x <= 0) y += m;
else
y += min(i * ((m + 1) / 2 - 1) / x, m);
} else y += (m + 1) / 2 - 1;
mx = max(mx,y);
if(y == mx){
e = i;
}
}
cout << mx << endl;
for(int i = 1; i <= e; i++){
for(int j = 1; j <= m / 2 + 1; j++){
cl[i][j] = 1;
}
for(int j = m / 2 + 2; j <= m; j++){
cl[i][j] = -1;
}
}
for(int i = e + 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cl[i][j] = -1;
}
}
x = n / 2 + 1 - (n - e);
if(x > e) y = 0;
else if(x <= 0) y = 0;
else y = e * ((m + 1) / 2 - 1) / x;
l = 1;
r = 1;
ll curR = m / 2 + 2;
ll curL = 1;
//cout << x << " " << y << endl;
for(int i = 1; i <= y; i++){
for(int j = 1; j <= x; j++){
swap(cl[curL][r],cl[curL][curR]);
curL++;
if(curL == e + 1){
curL = 1;
curR++;
}
}
r++;
if(r == m + 1) break;
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(cl[i][j] == -1){
cout << "-";
} else cout << "+";
}
cout << endl;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |