제출 #1131941

#제출 시각아이디문제언어결과실행 시간메모리
1131941JelalTkmRed-blue table (IZhO19_stones)C++20
27 / 100
16 ms1804 KiB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define int long long int

const int N = 3e5 + 10;
const int md = 1e9 + 7;
const int INF = 1e9;

int32_t main(int32_t argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int T = 1;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    bool ok = 0;
    if (n < m)
      swap(n, m), ok = 1;
    vector<vector<int>> a(n + 1, vector<int> (m + 1));
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        a[i][j] = 1;

    vector<int> st(m + 1);

    int ans = n;

    for (int j = 1; j <= ((m - 1) >> 1); j++) {
      int cnt = 0;
      for (int i = 1; i <= n && st[j] <= (n - st[j]); i++) {
        a[i][j] = 0;
        cnt++;
        st[j]++;
        if (st[j] > (n - st[j]))
          ans++;
      }
    }

    cout << ans << '\n';
    if (!ok) {
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++)
          cout << (a[i][j] == 1 ? '+' : '-');
        cout << '\n';
      }
    } else {
      for (int j = 1; j <= m; j++) {
        for (int i = 1; i <= n; i++)
          cout << (a[i][j] == 1 ? '-' : '+');
        cout << '\n';
      }
    }
  }

  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...