답안 #341371

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341371 2020-12-29T15:14:45 Z Dilshod_Imomov Red-blue table (IZhO19_stones) C++17
27 / 100
35 ms 1516 KB
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# define int long long
# define fi first
# define se second
 
using namespace std;
 
const int N = 1e3 + 7;
const int mod = 1e9 + 7;

char a[N][N];
int cnt[N];

void solve() {
    int n, m;
    cin >> n >> m;
    if ( n + (m - (m + 2) / 2) >= m + (n - (n + 2) / 2) ) {
        for ( int i = 1; i <= n; i++ ) {
            for ( int j = 1; j <= m; j++ ) {
                if ( j <= (m + 2) / 2 ) {
                    a[i][j] = '+';
                }
                else {
                    a[i][j] = '-';
                }
            }
        }
        int t = n + (m - (m + 2) / 2);
        if ( m == 5 ) {
            for ( int i = 1; i <= (n + 2) / 2; i++ ) {
                a[i][3] = '-';
                a[i][4] = '+';
            }
            for ( int i = 1; i <= (n + 2) / 4; i++ ) {
                a[i][4] = '-';
                a[i][5] = '+';
            }
            t++;
        }
        cout << t << '\n';
    }
    else {
        for ( int i = 1; i <= n; i++ ) {
            for ( int j = 1; j <= m; j++ ) {
                if ( i <= (n + 2) / 2 ) {
                    a[i][j] = '-';
                }
                else {
                    a[i][j] = '+';
                }
            }
        }
        int t = m + (n - (n + 2) / 2);
        if ( n == 5 ) {
            for ( int i = 1; i <= (m + 2) / 2; i++ ) {
                a[4][i] = '-';
                a[3][i] = '+';
            }
            for ( int i = 1; i <= (m + 2) / 4; i++ ) {
                a[5][i] = '-';
                a[4][i] = '+';
            }
            t++;
        }
        cout << t << '\n';
    }
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= m; j++ ) {
            cout << a[i][j];
        }
        cout << '\n';
    }
}

int32_t main() {
    speed; 
    int T = 1;
    cin >> T;
    while ( T-- ) {
        solve();
    }   
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 2 ms 492 KB in the table A+B is not equal to 7
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 1516 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 35 ms 1516 KB Wrong answer in test 24 24: 35 < 44
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 2 ms 492 KB in the table A+B is not equal to 7