#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
typedef int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;
char arr[1000][1000];
int main()
{
int test;
cin>>test;
for(;test>0;--test)
{
int n,m;
cin>>n>>m;
int nr=(m)/2+1;
int nc=(n)/2+1;
iii ans=mp(m,mp(0,m));
for(int i=0;i<=m;++i)
{
for(int j=0;j<=n;++j)
{
int c=nr-(m-i);
if(c>0)
{
c=int((c*j)/i)+min((c*j)%i,1);
if(c<=n-nc)
ans=max(ans,mp(i+j,mp(j,i)));
}
else
ans=max(ans,mp(i+j,mp(j,i)));
}
}
for(int i=0;i<n;++i)
{
for(int j=0;j<m;++j)
{
if(j<ans.S.S)
arr[i][j]='-';
else
arr[i][j]='+';
}
}
for(int i=0;i<ans.S.F;++i)
{
int co=0,t=nr-(m-ans.S.S),c=0;
while(co!=t)
{
arr[i][c]='+';
c=(c+1)%ans.S.S;
co++;
}
}
cout<<ans.F<<endl;
for(int i=0;i<n;++i)
{
for(int j=0;j<m;++j)
cout<<arr[i][j];
cout<<endl;
}
}
return(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
384 KB |
in the table A+B is not equal to 46 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
10 ms |
384 KB |
in the table A+B is not equal to 46 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
90 ms |
1508 KB |
in the table A+B is not equal to 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
72 ms |
1528 KB |
in the table A+B is not equal to 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
10 ms |
384 KB |
in the table A+B is not equal to 46 |