답안 #171121

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171121 2019-12-27T13:14:11 Z donentseto Red-blue table (IZhO19_stones) C++14
11 / 100
30 ms 1400 KB
#include <bits/stdc++.h>
using namespace std;
int main (){

    ios::sync_with_stdio (false);
    cin.tie (0);

    int t;
    cin >> t;
    while (t --){
        int n, m;
        cin >> n >> m;
        if (n <= 2 && m >= n){
            cout << m << '\n';
            for (int i = 0; i < n; i ++){
                for (int j = 0; j < m; j ++) cout << '-';
                cout << '\n';
            }
        }
        else if (m <= 2){
            cout << n << '\n';
            for (int i = 0; i < n; i ++){
                for (int j = 0; j < m; j ++) cout << '+';
                cout << '\n';
            }
        }
        else if (n == 3 || n == 4){
            cout << m + 1 << '\n';
            for (int i = 0; i < m; i ++) cout << '+';
            cout << '\n';
            for (int i = 1; i < n; i ++){
                for (int i = 0; i < m; i ++) cout << '-';
                cout << '\n';
            }
        }
        else if (m == 3 || m == 4){
            cout << n + 1 << '\n';
            for (int i = 0; i < n; i ++){
                cout << '-';
                for (int j = 1; j < m; j ++) cout << '+';
                cout << '\n';
            }
        }
        else{
            cout << n - 2 + n % 2 + m - 2 + m % 2 << '\n';
            for (int i = 0; i < n; i ++){
                for (int j = 0; j < m; j ++){
                    if (i <= n >> 1 && j < m - 1 >> 1) cout << '-';
                    else if (i >= n - 1 >> 1 && j > m >> 1) cout << '-';
                    else cout << '+';
                }
                cout << '\n';
            }
        }
    }

}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:48:46: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
                     if (i <= n >> 1 && j < m - 1 >> 1) cout << '-';
                                            ~~^~~
stones.cpp:49:37: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
                     else if (i >= n - 1 >> 1 && j > m >> 1) cout << '-';
                                   ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 3: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Wrong answer in test 4 3: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 3: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 1400 KB Output is correct
2 Correct 29 ms 1244 KB Output is correct
3 Correct 24 ms 1244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 1272 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 3: 4 < 5