#include <iostream>
using namespace std;
void fastscan(int &x)
{
bool neg=false;
register int c;
x =0;
c=getchar();
if(c=='-')
{
neg = true;
c=getchar();
}
for(;(c>47 && c<58);c=getchar())
x = (x<<1) + (x<<3) +c -48;
if(neg)
x *=-1;
}
void test(int n, int m)
{
int sum = 0;
if(n >= m)
{
sum = n + m / 2 + m % 2 - 1;
}
else
{
sum = m + n / 2 + n % 2 - 1;
}
cout<<sum<<endl;
for(int row = 0;row < n;row++)
{
for(int col = 0;col < m;col++)
{
if(n >= m)
{
if(col < m / 2 + m % 2 - 1)
{
cout<<"-";
}
else
{
cout<<"+";
}
}
else
{
if(row < n / 2 + n % 2 - 1)
{
cout<<"+";
}
else
{
cout<<"-";
}
}
}
cout<<endl;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
fastscan(t);
for(int i = 0;i < t;i++)
{
int n,m;
fastscan(n);
fastscan(m);
//cin>>n>>m;
test(n,m);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
6 ms |
332 KB |
Output is correct |
4 |
Incorrect |
10 ms |
332 KB |
Wrong answer in test 5 29: 31 < 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
42 ms |
1268 KB |
Wrong answer in test 97 21: 107 < 116 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
1220 KB |
Wrong answer in test 24 24: 35 < 44 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
6 ms |
332 KB |
Output is correct |
4 |
Incorrect |
10 ms |
332 KB |
Wrong answer in test 5 29: 31 < 32 |