#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
using ll=long long;
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vl vector<ll>
#define all(a) begin(a),end(a)
using namespace std;
const int N=300010,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;
int t,n,m;
string re[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>t;
while (t--)
{
cin>>n>>m;
int ma=-1,kak=-1;
for (int ms=0;ms<=n/2;++ms)
{
int re=min(m,((n-ms)*((m-1)/2))/(n/2+1-ms))+n-ms;
if (re>ma)
{
ma=re;
kak=ms;
}
}
if (m+n-(n/2+1)>ma)
{
ma=m+n-(n/2+1);
kak=n/2+1;
}
cout<<ma<<en;
int ms=kak;
for (int i=0;i<ms;++i)
{
re[i]=string(m,'-');
}
for (int i=ms;i<n;++i) re[i]=string(m,'+');
int pc=(m-1)/2;
if (ms!=n/2+1) for (int k=0;k<pc*(n-ms);++k)
{
int i=k%(n-ms)+ms,j=k/(n/2+1-ms);
if (j>=m) break;
re[i][j]='-';
}
for (int i=0;i<n;++i) cout<<re[i]<<en;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
9708 KB |
Output is correct |
2 |
Correct |
6 ms |
9708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
9708 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
9708 KB |
Output is correct |
2 |
Correct |
6 ms |
9708 KB |
Output is correct |
3 |
Correct |
7 ms |
9708 KB |
Output is correct |
4 |
Correct |
7 ms |
9836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
10860 KB |
Output is correct |
2 |
Correct |
15 ms |
11244 KB |
Output is correct |
3 |
Correct |
15 ms |
11372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
10860 KB |
Output is correct |
2 |
Correct |
14 ms |
11116 KB |
Output is correct |
3 |
Correct |
14 ms |
10860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
9708 KB |
Output is correct |
2 |
Correct |
6 ms |
9708 KB |
Output is correct |
3 |
Correct |
7 ms |
9708 KB |
Output is correct |
4 |
Correct |
7 ms |
9836 KB |
Output is correct |
5 |
Correct |
16 ms |
10860 KB |
Output is correct |
6 |
Correct |
15 ms |
11244 KB |
Output is correct |
7 |
Correct |
15 ms |
11372 KB |
Output is correct |
8 |
Correct |
16 ms |
10860 KB |
Output is correct |
9 |
Correct |
14 ms |
11116 KB |
Output is correct |
10 |
Correct |
14 ms |
10860 KB |
Output is correct |
11 |
Correct |
10 ms |
9964 KB |
Output is correct |
12 |
Correct |
14 ms |
10988 KB |
Output is correct |
13 |
Correct |
14 ms |
10988 KB |
Output is correct |
14 |
Correct |
12 ms |
10604 KB |
Output is correct |
15 |
Correct |
16 ms |
11756 KB |
Output is correct |
16 |
Correct |
15 ms |
11244 KB |
Output is correct |
17 |
Correct |
10 ms |
10348 KB |
Output is correct |