# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
711171 | onlk97 | Red-blue table (IZhO19_stones) | C++14 | 31 ms | 2232 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;
void solve(){
int n,m;
cin>>n>>m;
int ans1=-1,rr;
for (int r=0; r<=n; r++){
int cnt=r,req=n/2+1-(n-r);
if (req<=0) cnt+=m;
else {
int L=0,R=m;
while (L<R){
int mid=(L+R+1)/2;
if (r*min(mid,m-m/2-1)>=mid*req) L=mid;
else R=mid-1;
}
cnt+=L;
}
if (cnt>ans1){
ans1=cnt;
rr=r;
}
}
cout<<ans1<<'\n';
int tt=ans1-rr;
char op[n+1][m+1];
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++) op[i][j]=(i<=rr?'+':'-');
}
if (n-rr<n/2+1){
int ut=min(ans1-rr,m-m/2-1);
for (int j=1; j<=rr; j++){
for (int k=(j-1)*ut; k<j*ut; k++) op[j][k%(ans1-rr)+1]='-';
}
}
for (int i=1; i<=n; i++){
for (int j=1; j<=m; j++) cout<<op[i][j];
cout<<'\n';
}
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int t;
cin>>t;
while (t--) solve();
}
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... |