Submission #168735

# Submission time Handle Problem Language Result Execution time Memory
168735 2019-12-15T16:08:06 Z RafaelSus Red-blue table (IZhO19_stones) C++14
0 / 100
28 ms 1392 KB
#include <bits/stdc++.h>

using namespace std;
const long long mod = 1e9 + 7;

int main(){

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

  int t;
  cin >> t;
  while (t-- > 0){
    int n, m;
    cin >> n >> m;
    
    
    
    ///////////////////OK
    if (n == 1){
      cout << m << '\n';
      for (int i = 0; i < m; i++){
        cout << "-";
      }
      cout << '\n';
      continue;
    }else if (m == 1){
      cout << n << '\n';
      for (int i = 0; i < n; i++){
        cout << "+\n";
      }
      continue;
    }//////////////////OK
    
    
    
    
    if (n % 2 == 1 && n <= m){
      if (m % 2 == 1){
        cout << m + n / 2 << '\n';
        for (int i = 0; i < n; i++){
          for (int j = 0; j < m; j++){
            if (i % 2 == 0){
              cout << "-";
            }else{
              cout << "+";
            }
          }
          cout << '\n';
        }
      }else{
        cout << m + (n - 1) / 2 << '\n';
        for (int i = 0; i < n - 1; i++){
          for (int j = 0; j < m; j++){
            if (i % 2 == 0)cout << "-";
            else cout << "+";
          }
          cout << "\n";
        }
      }
      //cout << '\n';
      continue;
    }////////////////////////////OK
    
    
    
    if (m % 2 == 1 && m <= n){
      if (n % 2 == 1){
        cout << n + m / 2 << '\n';
        for (int i = 0; i < n; i++){
          for (int j = 0; j < m; j++){
            if (j % 2 == 0)cout << "+";
            else cout << "-";
          }
          cout << '\n';
        }
      }else{
        cout << n + (m - 1) / 2 << '\n';
        for (int i = 0; i < n; i++){
          for (int j = 0; j < m - 1; j++){
            if (j % 2 == 0) cout << "+";
            else cout << "-";
          }
          cout << "+";
          cout << '\n';
        }
      }
      //cout << '\n';
      continue;
    }
    
    
    
    if (n % 2 == 1 && n > m){
      if (m % 2 == 0){
        cout << n + (m - 1) / 2 << '\n';
        for (int i = 0; i < n; i++){
          for (int j = 0; j < m - 1; j++){
            if (j % 2 == 0) cout << "+";
            else cout << "-";
          }
          cout << "+\n";
        }
      }else{
        cout << n + m / 2 << '\n';
        for (int i = 0; i < n; i++){
          for (int j = 0; j < m; j++){
            if (j % 2 == 0)cout << "+";
            else cout << "-";
          }
          cout << '\n';
        }
      }
      //cout << '\n';
      continue;
    }
    if (m % 2 == 1 && m > n){
      if (n % 2 == 0){
        cout << m + (n - 1) / 2 << '\n';
        for (int i  = 0; i < n - 1; i++){
          for (int j = 0; j < m; j++){
            if (i % 2 == 0)cout << "-";
            else cout << "+";
          }
          cout << '\n';
        }
        for (int i = 0; i < m; i++)
          cout << "-";
        cout << '\n';
      }else{
        cout << m + n / 2 << '\n';
        for (int i = 0; i < n; i++){
          for (int j = 0; j < m; j++){
            if (i % 2 == 0)cout << "-";
            else cout << "+";
          }
          cout << '\n';
        }
      }
      continue;
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 256 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 256 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1392 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 888 KB Wrong answer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 256 KB Wrong answer