답안 #479571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
479571 2021-10-12T08:18:19 Z Ronin13 Red-blue table (IZhO19_stones) C++14
0 / 100
21 ms 1232 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;
char ans[1001][1001];
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";
   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();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 8
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 8
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 8
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 716 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 21 ms 1232 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 8