# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152925 | beso123 | Red-blue table (IZhO19_stones) | C++14 | 96 ms | 2972 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;
char a[1001][1001];
char a1[1001][1001];
pair <int,int> check(int n,int m){
int t=0;
if(n<=m){
t=m-2;
t=t+(n-1);
if(n%2==1)
t++;
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++)
a[k][i]='-';
int n1=0,m1=0;
if(n%2==0)
n1=n/2-1;
else n1=n/2;
if(m%2==0)
m1=m/2+1;
else m1=m/2+1;
for(int k=1;k<n;k+=1){
if(k%2==1){
int f=0;
for(int i=1;i<=m;i+=2)
if(i<=m){
a[k][i]='+';
f++;
}
if(f<m1)
a[k][2]='+';
}
else{
int f=0;
for(int i=2;i<=m;i+=2)
if(i<=m){
a[k][i]='+';
f++;
}
if(f<m1)
a[k][1]='+';
}
}
}
else{
t=n-2;
t=t+(m-1);
if(m%2==1)
t++;
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++)
a[k][i]='+';
int n1=0,m1=0;
if(n%2==0)
n1=n/2+1;
else n1=n/2+1;
if(m%2==0)
m1=m/2-1;
else m1=m/2;
for(int k=1;k<m;k++){
int f=0;
if(k%2==1){
for(int i=1;i<=n;i+=2)
if(i<=n){
f++;
a[i][k]='-';
}
if(f<n1)
a[1][k]='-';
}
else{
for(int i=2;i<=n;i+=2)
if(i<=n){
f++;
a[i][k]='-';
}
if(f<n1)
a[1][k]='-';
}
}
}
int t1=0;
if(n<=m){
t1=m;
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++)
a1[k][i]='-';
int n1=0,m1=0;
if(n%2==0)
n1=n/2-1;
else n1=n/2;
if(m%2==0)
m1=m/2+1;
else m1=m/2+1;
t1+=n1;
int t=0;
if(n%2==0){
if(n/2!=n1)
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a1[k][i]='+';
}
else{
if(m%2==0){
if(m1*2!=m)
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a1[k][i]='+';
}
else{
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a1[k][i]='+';
}
}
}
else{
t1=n;
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++)
a1[k][i]='+';
int n1=0,m1=0;
if(n%2==0)
n1=n/2+1;
else n1=n/2+1;
if(m%2==0)
m1=m/2-1;
else m1=m/2;
t1+=m1;
int t=0;
if(n%2==0){
if(n/2!=n1)
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a1[k][i]='-';
}
else{
if(m%2==0){
int t=0;
if(n<=m){
t=m;
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++)
a[k][i]='-';
int n1=0,m1=0;
if(n%2==0)
n1=n/2-1;
else n1=n/2;
if(m%2==0)
m1=m/2+1;
else m1=m/2+1;
t+=n1;
int t=0;
if(n%2==0){
if(n/2!=n1)
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a[k][i]='+';
}
else{
if(m%2==0){
if(m1*2!=m)
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a[k][i]='+';
}
else{
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a[k][i]='+';
}
}
}
else{
t=n;
for(int k=1;k<=n;k++)
for(int i=1;i<=m;i++)
a[k][i]='+';
int n1=0,m1=0;
if(n%2==0)
n1=n/2+1;
else n1=n/2+1;
if(m%2==0)
m1=m/2-1;
else m1=m/2;
t+=m1;
int t=0;
if(n%2==0){
if(n/2!=n1)
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a[k][i]='-';
}
else{
if(m%2==0){
if(m1*2!=m)
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a[k][i]='-';
}
else{
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a[k][i]='-';
}
}
} if(m1*2!=m)
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a1[k][i]='-';
}
else{
for(int k=1;k<=n1;k++)
for(int i=1;i<=m1;i++)
a1[k][i]='-';
}
}
}
if(t>t1)
return {t,1};
else return {t1,2};
}
int main(){
int T;
cin>>T;
int r=0;
while(r<T){
int n,m;
cin>>n>>m;
r++;
pair <int,int> ans=check(n,m);
cout<<ans.first<<endl;
if(ans.second==1)
for(int k=1;k<=n;k++){
for(int i=1;i<=m;i++)
cout<<a[k][i];
cout<<endl;
}
else
for(int k=1;k<=n;k++){
for(int i=1;i<=m;i++)
cout<<a1[k][i];
cout<<endl;
}
}
return 0;
}
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... |