답안 #830048

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
830048 2023-08-18T17:58:57 Z vjudge1 Red-blue table (IZhO19_stones) C++17
11 / 100
26 ms 1900 KB
#include <bits/stdc++.h>
using namespace std;

/// 123

int32_t main() {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        int t;
        cin >> t;
        while (t--) {
                int n, m;
                cin >> n >> m;
                int sw = 0;
                if (n < m) swap(n, m), sw = 1;
                vector<vector<char>> a(n, vector<char>(m, '+'));
                vector<int> cnt(n, m);
                int cur = 0;
                int k = n + 1 >> 1;
                int res = n;
                for (int i = 0; i < m; i++) {
                        int ok = 1;
                        for (int j = 0; j < k; j++) {
                                if (cnt[cur] - 1 > m - cnt[cur] + 1) {
                                        cnt[cur]--;
                                        a[cur][i] = '-';
                                } else {
                                        ok = 0;
                                        break;
                                }
                                cur++;
                                cur %= n;
                        }
                        res += ok;
                }
                cout << res << '\n';
                for (int i = 0; i < (sw ? m : n); i++) {
                        for (int j = 0; j < (sw ? n : m); j++) {
                                cout << (char)(sw ? '-' ^ '+' ^ a[j][i] : a[i][j]);
                        }
                        cout << '\n';
                }
        }
}

Compilation message

stones.cpp: In function 'int32_t main()':
stones.cpp:19:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   19 |                 int k = n + 1 >> 1;
      |                         ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB in the table A+B is not equal to 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB in the table A+B is not equal to 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB in the table A+B is not equal to 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 1280 KB Output is correct
2 Correct 20 ms 1672 KB Output is correct
3 Correct 17 ms 1900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 1280 KB in the table A+B is not equal to 46
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB in the table A+B is not equal to 6
3 Halted 0 ms 0 KB -