#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 calc(int w)
{
int q=0;
while (w > 1)
{
q += w / 2;
w /= 2;
}
return q;
}
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 + calc(x-1) + (x==y && y==24)<< 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+1)%y;
}
else
a[i][j] = 2;
j++;
j %= y;
}
}
}
else
{
cout << x + calc(y - 1) + (x == y && y == 24) << 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+1)%x;
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5068 KB |
Output is correct |
2 |
Correct |
4 ms |
5068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
5108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5068 KB |
Output is correct |
2 |
Correct |
4 ms |
5068 KB |
Output is correct |
3 |
Correct |
41 ms |
5108 KB |
Output is correct |
4 |
Correct |
62 ms |
5100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
185 ms |
6056 KB |
in the table A+B is not equal to 115 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
120 ms |
6072 KB |
in the table A+B is not equal to 35 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
5068 KB |
Output is correct |
2 |
Correct |
4 ms |
5068 KB |
Output is correct |
3 |
Correct |
41 ms |
5108 KB |
Output is correct |
4 |
Correct |
62 ms |
5100 KB |
Output is correct |
5 |
Incorrect |
185 ms |
6056 KB |
in the table A+B is not equal to 115 |
6 |
Halted |
0 ms |
0 KB |
- |