답안 #956444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
956444 2024-04-02T00:44:51 Z Darren0724 Red-blue table (IZhO19_stones) C++17
27 / 100
19 ms 1676 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define int long long
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e18;
void solve(){
    int n,m;cin>>n>>m;
    int flag=(n>m);
    if(flag)swap(n,m);
    vector<vector<int>> v(n,vector<int>(m));
    int ans=0;
    if(n==1){
        for(int i=0;i<m;i++){
            v[0][i]=1;
        }
        ans=m;
    }
    else if(n==2){
        ans=m;
        for(int i=0;i<m;i++){
            v[0][i]=1;
            v[1][i]=1;
        }
    }
    else if(n==3){
        ans=m+1;
        for(int i=0;i<m;i++){
            v[0][i]=1;
            v[1][i]=1;
        }
    }
    else if(n==4){
        ans=m+1;
        for(int i=0;i<m;i++){
            v[0][i]=1;
            v[1][i]=1;
            v[2][i]=1;
        }
    }
    else if(n==5){
        ans=m+2;
        for(int i=0;i<m;i++){
            v[0][i]=1;
            v[1][i]=1;
            v[2][i]=1;
        }
    }
    else{
        ans=m+(n-1)/2;
        for(int j=0;j<(n+2)/2;j++){
            for(int i=0;i<m;i++){
                v[j][i]=1;
            }
        }
    }
    cout<<ans<<endl;
    if(!flag){
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                cout<<(v[i][j]?'-':'+');
            }
            cout<<endl;
        }
    }
    else{
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                cout<<(v[j][i]?'+':'-');
            }
            cout<<endl;
        }
    }
}
int32_t main() {
    LCBorz;
    int t;cin>>t;
    while(t--){
        solve();
    }
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Incorrect 1 ms 348 KB Wrong answer in test 5 29: 31 < 32
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 1676 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 18 ms 1652 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Incorrect 1 ms 348 KB Wrong answer in test 5 29: 31 < 32
5 Halted 0 ms 0 KB -