#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define all(x) x.begin(),x.end()
#define al(a,n) (a,a+n)
#define se second
#define fr first
#define m_p make_pair
using namespace std;
typedef long long ll;
const ll N = 2000004;
const ll mod = 1000 * 1000 * 100 + 7;
const ll inf = 1000000009;
ll n, m, k, z, t, x, y,a[1006][1006], ans;
int main()
{
cin >> t;
while (t--)
{
cin >> x >> y;
for (int i = 1000; i >= 0; --i)
for (int j = 100; j >= 0; --j)
a[i][j] = 0;
if (x < y)
{
map <ll, ll> mp,mpp;
cout << y + (x - 1) / 2 +(x-1)/2/2<< endl;
int j = 0,jj=0;
for (int i = 0; i < x; ++i)
{
j = jj;
while (a[i][j] == 0)
{
if (mp[j] < (x - 1) / 2 && mpp[i] < y / 2 + 1)
{
a[i][j] = 1;
mp[j]++;
mpp[i]++;
jj = j;
}
else
a[i][j] = 2;
j++;
j %= y;
}
}
}
else
{
cout << x + (y - 1) / 2 / 2 +(y - 1) / 2 << endl;
map <ll, ll> mp, mpp;
int i = 0,ii=0;
for (int j = 0; j < y; ++j)
{
i = ii;
while(a[i][j]==0)
{
if (mp[j] < x / 2 + 1 && mpp[i] < (y - 1) / 2)
{
a[i][j] = 2;
mp[j]++;
mpp[i]++;
ii = i;
}
else
a[i][j] = 1;
i++;
i %= x;
}
}
}
for (int i = 0; i < x; ++i)
{
for (int j = 0; j < y; ++j)
if (a[i][j] == 1)
cout << '+';
else
cout << '-';
cout << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5068 KB |
Output is correct |
2 |
Correct |
6 ms |
5068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
5104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5068 KB |
Output is correct |
2 |
Correct |
6 ms |
5068 KB |
Output is correct |
3 |
Correct |
42 ms |
5104 KB |
Output is correct |
4 |
Correct |
65 ms |
5240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
203 ms |
6056 KB |
in the table A+B is not equal to 112 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
120 ms |
6024 KB |
in the table A+B is not equal to 40 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5068 KB |
Output is correct |
2 |
Correct |
6 ms |
5068 KB |
Output is correct |
3 |
Correct |
42 ms |
5104 KB |
Output is correct |
4 |
Correct |
65 ms |
5240 KB |
Output is correct |
5 |
Incorrect |
203 ms |
6056 KB |
in the table A+B is not equal to 112 |
6 |
Halted |
0 ms |
0 KB |
- |