#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int t,n,m,h;
char a1,a2;
string s[1005];
void resheven()
{
int br=0;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m/2+1; j++)
{
s[i]+=a1;
}
for(int j=m/2+2; j<=m; j++)
{
s[i]+=a2;
}
br++;
}
br+=(m-1)/2;
cout<<br<<endl;
if(h)
{
for(int i=1; i<=m; i++)
{
for(int j=1; j<=n; j++)
{
cout<<s[j][i-1];
}
cout<<endl;
}
return;
}
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
cout<<s[i][j-1];
}
cout<<endl;
}
}
void resh()
{
int br=0;
for(int i=1; i<=(n-1)/2; i++)
{
for(int j=1; j<=m/2+1; j++)
{
s[i]+=a1;
}
for(int j=m/2+2; j<=m; j++)
{
s[i]+=a2;
}
br++;
}
for(int i=(n-1)/2+1; i<=n-1; i++)
{
for(int j=1; j<=(m-1)/2; j++)
{
s[i]+=a2;
}
for(int j=(m-1)/2+1; j<=m; j++)
{
s[i]+=a1;
}
br++;
}
if(m>2)
{
for(int i=1;i<=m;i++)
{
s[n]+=a2;
}
br+=m-1;
}
else
{
for(int i=1;i<=m;i++)
{
s[n]+=a1;
}
br++;
}
cout<<br<<endl;
if(h)
{
for(int i=1; i<=m; i++)
{
for(int j=1; j<=n; j++)
{
cout<<s[j][i-1];
}
cout<<endl;
}
return;
}
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
cout<<s[i][j-1];
}
cout<<endl;
}
}
void read()
{
cin>>t;
for(int z=1; z<=t; z++)
{
cin>>n>>m;
if(n<m)
{
swap(n,m);
a1='-';
a2='+';
h=1;
}
else
{
a1='+';
a2='-';
}
if(n%2==0)resheven();
else resh();
h=0;
for(int i=1;i<=n;i++)s[i].clear();
}
}
int main()
{
speed();
read();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
2 ms |
348 KB |
in the table A+B is not equal to 27 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
1368 KB |
Output is correct |
2 |
Correct |
18 ms |
2140 KB |
Output is correct |
3 |
Correct |
16 ms |
2140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
1372 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Incorrect |
2 ms |
348 KB |
in the table A+B is not equal to 27 |
5 |
Halted |
0 ms |
0 KB |
- |