이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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+1)%y;
}
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+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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |