답안 #1092548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092548 2024-09-24T10:57:10 Z juicy Red-blue table (IZhO19_stones) C++17
100 / 100
27 ms 2396 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
 
  int t; cin >> t;
  while (t--) {
    int n, m; cin >> n >> m;
    bool flip = 0;
    if (n > m) {
      swap(n, m);
      flip = 1;
    }
    vector<int> cnt(m), ord(m); iota(ord.begin(), ord.end(), 0);
    int cut = (n - 1) / 2, need = m / 2 + 1;
    int x = m * cut / need;
    cout << m + x << "\n";
    vector a(n, vector<char>(m, '-'));
    for (int i = 0; i < x; ++i) {
      sort(ord.begin(), ord.end(), [&](int a, int b) {
        return cnt[a] < cnt[b];
      });
      for (int j = 0; j < need; ++j) {
        a[i][ord[j]] = '+';
        ++cnt[ord[j]];
      }
    }
    if (flip) {
      for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
          cout << char(a[j][i] ^ '+' ^ '-');
        }
        cout << "\n";
      }
    } else {
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
          cout << a[i][j];
        }
        cout << "\n";
      }
    }
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 1 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 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1372 KB Output is correct
2 Correct 23 ms 1628 KB Output is correct
3 Correct 21 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1360 KB Output is correct
2 Correct 19 ms 1496 KB Output is correct
3 Correct 21 ms 1224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 2 ms 348 KB Output is correct
5 Correct 22 ms 1372 KB Output is correct
6 Correct 23 ms 1628 KB Output is correct
7 Correct 21 ms 1884 KB Output is correct
8 Correct 23 ms 1360 KB Output is correct
9 Correct 19 ms 1496 KB Output is correct
10 Correct 21 ms 1224 KB Output is correct
11 Correct 5 ms 604 KB Output is correct
12 Correct 19 ms 1600 KB Output is correct
13 Correct 20 ms 1368 KB Output is correct
14 Correct 15 ms 1128 KB Output is correct
15 Correct 27 ms 2396 KB Output is correct
16 Correct 20 ms 1884 KB Output is correct
17 Correct 8 ms 1112 KB Output is correct