Submission #479570

# Submission time Handle Problem Language Result Execution time Memory
479570 2021-10-12T08:17:29 Z Ronin13 Red-blue table (IZhO19_stones) C++14
0 / 100
18 ms 972 KB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define epb emplace_back
#define pb push_back
#define inf 1e9+1
#define linf 1e18+1
using namespace std;

void solve(){
    int n,m;cin>>n>>m;
    int mx,mxi,mxj;
    int mxx;
    if(m>n){
        mx=m,mxi=0,mxj=m;
        mxx=0;
    }
    else{
        mx=n,mxi=n,mxj=0;
        mxx=m;
    }
    int cx,cy;
    cx=m/2+1,cy=n/2+1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int y=n-cy,x=max(cx-m+j,0);
            if(x*i<=y*j){
                if(mx<=i+j){
                    mx=i+j;
                    mxi=i;
                    mxj=j;
                    mxx=x;
                }
            }
        }
   }
   cout<<mx<<"\n";
   char ans[n+1][m+1];
   for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)ans[i][j]='-';
   }
   int cur=0;
   for(int i=1;i<=mxi;i++){
        for(int j=1;j<=mxx;j++){
            int p=cur%mxj;p++;
            ans[i][p]='+';
            cur++;
        }
   }
   for(int i=1;i<=mxi;i++){
        for(int j=mxj+1;j<=m;j++)ans[i][j]='+';
   }
   for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cout<<ans[i][j];
        }
        cout<<"\n";
   }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    //freopen("in.in","r",stdin);freopen("out.out","w",stdout);
    int test=1;cin>>test;
    while(test--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 8
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 444 KB Execution killed with signal 8
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 8
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 460 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 18 ms 972 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Runtime error 1 ms 332 KB Execution killed with signal 8