Submission #532501

# Submission time Handle Problem Language Result Execution time Memory
532501 2022-03-03T03:28:57 Z dannyboy20031204 Red-blue table (IZhO19_stones) C++17
38 / 100
26 ms 1740 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void db() {cout << '\n';}
template <typename T, typename ...U> void db(T a, U ...b){
    cout << a << ' ', db(b...);
}
void solve(){
    int n, m;
    cin >> n >> m;
    if (min(n, m) <= 4 or (n == m and n % 2 == 0 and n <= 10)){
        cout << max(n + (m - 1) / 2, m + (n - 1) / 2) << '\n';
        if (n + (m - 1) / 2 > m + (n - 1) / 2){
            for (int i = 0; i < n; i++){
                for (int j = 0; j < m; j++){
                    if (j % 2 == 0 or (m % 2 == 0 and j == m - 1)) cout << '+';
                    else cout << '-';
                }
                cout << '\n';
            }
        }
        else{
            for (int i = 0; i < n; i++){
                for (int j = 0; j < m; j++){
                    if (i % 2 == 0 or (n % 2 == 0 and i == n - 1)) cout << '-';
                    else cout << '+';
                }
                cout << '\n';
            }
        }
        return;
    }
    if (n == m and n % 2 == 0){
        char ans[n][m];
        for (int i = 0; i < n - 2; i++) for (int j = 0; j < m - 2; j++) ans[i][j] = (i + j) % 2 ? '+' : '-';
        for (int i = 0; i < n; i++) ans[i][m - 1] = '+';
        for (int i = 0; i < n; i++) ans[i][m - 2] = '+';
        for (int j = 0; j < m; j++) ans[n - 1][j] = '-';
        for (int j = 0; j < m; j++) ans[n - 2][j] = '-';
        cout << n + m - 4 << '\n';
        for (auto &i : ans){
            for (char j : i) cout << j;
            cout << '\n';
        }
        return;
    }
    char ans[n][m];
    for (int i = 0; i < n - 1; i++) for (int j = 0; j < m - 1; j++) ans[i][j] = (i + j) % 2 ? '+' : '-';
    for (int i = 0; i < n; i++) ans[i][m - 1] = '+';
    for (int j = 0; j < m; j++) ans[n - 1][j] = '-';
    cout << n - 1 + m - 1 << '\n';
    for (auto &i : ans){
        for (char j : i) cout << j;
        cout << '\n';
    }
}
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int t;
    cin >> t;
    while (t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 2 ms 332 KB in the table A+B is not equal to 41
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1228 KB Output is correct
2 Correct 19 ms 1740 KB Output is correct
3 Correct 18 ms 1724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1260 KB Wrong answer in test 10 10: 14 < 16
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 2 ms 332 KB in the table A+B is not equal to 41
5 Halted 0 ms 0 KB -