Submission #348413

#TimeUsernameProblemLanguageResultExecution timeMemory
348413casperwangRed-blue table (IZhO19_stones)C++14
27 / 100
49 ms1644 KiB
#include <bits/stdc++.h>
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }

int t, n, m;
vector<vector<char>> A, B;
vector <int> cnt;
int ansA, ansB;

void init() {
  A.clear(), B.clear();
  A.resize(n), B.resize(n);
  for (int i = 0; i < n; i++)
    A[i].resize(m), B[i].resize(m);
  ansA = n, ansB = m;
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> m;
    init();
    cnt.clear(), cnt.resize(n);
    for (int i = 0; i < m; i++) {
      int c = (n+2)/2;
      for (int j = 0; j < n; j++) {
        if (c > 0 && cnt[j] < (m-1)/2) {
          A[j][i] = '-';
          cnt[j]++, c--;
        } else {
          A[j][i] = '+';
        }
      }
      if (!c) ansA++;
    }
    cnt.clear(), cnt.resize(m);
    for (int i = 0; i < n; i++) {
      int c = (m+2)/2;
      for (int j = 0; j < m; j++) {
        if (c > 0 && cnt[j] < (n-1)/2) {
          B[i][j] = '+';
          cnt[j]++, c--;
        } else {
          B[i][j] = '-';
        }
      }
      if (!c) ansB++;
    }
    if (ansA > ansB) {
      cout << ansA << '\n';
      for (auto v : A) {
        for (char c : v) {
          cout << c;
        }
        cout << '\n';
      }
    } else {
      cout << ansB << '\n';
      for (auto v : B) {
        for (char c : v) {
          cout << c;
        }
        cout << '\n';
      }
    }
  }
}
#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...