# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
201987 | guangxuan | Red-blue table (IZhO19_stones) | C++14 | 13 ms | 2296 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 ans[1002][1002];
int main(){
int T;
scanf("%d",&T);
while(T--){
int n,m;
scanf("%d%d",&n,&m);
int ans1 = n + (m-1)/2, ans2 = m + (n-1)/2;
for(int x=1;x<m;x++){
if((n*x + (m-1)/2 + x - 1)/((m-1)/2 + x) <= (n-1)/2)ans1++;
else break;
}
for(int x=1;x<n;x++){
if((m*x + (n-1)/2 + x - 1)/((n-1)/2 + x) <= (m-1)/2)ans2++;
else break;
}
printf("%d\n",max(ans1,ans2));
if(ans1>ans2){
int x = ans1 - (n+(m-1)/2);
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(j<x+(m-1)/2)ans[i][j]='-';
else ans[i][j]='+';
}
for (int j = i * x; j< (i+1) * x; j++){
ans[i][j%(x+(m-1)/2)] = '+';
}
ans[i][m] = '\0';
}
}
else{
int x = ans2 - (m+(n-1)/2);
for(int j=0;j<m;j++){
for(int i=0;i<n;i++){
if(i<x+(n-1)/2)ans[i][j]='+';
else ans[i][j]='-';
}
for (int i = j * x; i< (j+1) * x; i++){
ans[i%(x+(n-1)/2)][j] = '-';
}
}
for(int i=0;i<n;i++)ans[i][m]='\0';
}
for(int i=0;i<n;i++)printf("%s\n",ans[i]);
}
}
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... |