# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238849 | arnold518 | Red-blue table (IZhO19_stones) | C++14 | 63 ms | 2272 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1000;
int TC, N, M;
char S[MAXN+10][MAXN+10];
int main()
{
int i, j, k;
scanf("%d", &TC);
while(TC--)
{
scanf("%d%d", &N, &M);
int ans=0; pii t;
for(i=0; i<=N; i++)
{
for(j=0; j<=M; j++)
{
int x=min((M-1)/2, j);
int y=max(0, i-(N-1)/2);
if(x*i>=y*j) { if(ans<=i+j) ans=i+j, t={i, j}; }
}
}
for(i=0; i<N; i++) for(j=0; j<M; j++) S[i][j]='+';
int a=t.first, b=t.second;
int x=min((M-1)/2, b);
int y=max(0, a-(N-1)/2);
for(j=0, i=0; j<b; j++)
{
for(k=0; k<y; k++, i=(i+1)%a)
{
S[i][j]='-';
}
}
for(i=a; i<N; i++) for(j=0; j<b; j++) S[i][j]='-';
printf("%d\n", ans);
for(i=0; i<N; i++) { for(j=0; j<M; j++) printf("%c", S[i][j]); printf("\n"); }
}
}
Compilation message (stderr)
# | 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... |