Submission #503300

# Submission time Handle Problem Language Result Execution time Memory
503300 2022-01-07T15:49:17 Z Pety Red-blue table (IZhO19_stones) C++14
100 / 100
32 ms 2236 KB
#include <bits/stdc++.h>

#define ll long long
#define ld long double

using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const int N = 1e5 + 2;

int t, n, m;
char a[1002][1002];


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    int ans = 0, lin = 0, col = 0;
    for (int i = 0; i <= n; i++)
      for (int j =0; j <= m; j++) {
        if (m / 2 + 1 <= m - j || n / 2 + 1 <= n - i) {
          if (ans < i + j) {
            ans = i + j;
            lin = i;
            col = j;
          }
        }
        else {
          int l = m / 2 + 1 - (m - j);
          int c = n / 2 + 1 - (n - i);
          int nr = (j + l * i - 1) / j;
          if (c <= i - nr && ans < i + j) {
            ans = i + j;
            lin = i;
            col = j;
          }
        }
      } 
    cout << ans <<  "\n";
    for (int i = 0; i < lin; i++)
      for (int j = m - 1; j >= col; j--)
        a[i][j] = '+';
    for (int j = 0; j < col; j++)
      for (int i = n - 1; i >= 0; i--)
        a[i][j] = '-';
    if (m / 2 + 1 > m - col) {
      int c = m / 2 + 1 - (m - col);
      int k = 0;
      for (int i = 0; i < lin; i++) {
        for (int j = 0; j < c; j++) {
          a[i][k] = '+';
          k = (k + 1) % col;
        }
      }
    }
    for (int i = lin; i < n; i++)
      for (int j = col; j < m; j++)
        a[i][j] = '-';
    for (int i = 0; i < n; i++, cout << "\n")
      for (int j = 0; j < m; j++)
        cout << a[i][j];
    
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1432 KB Output is correct
2 Correct 23 ms 1860 KB Output is correct
3 Correct 23 ms 1988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1456 KB Output is correct
2 Correct 24 ms 1852 KB Output is correct
3 Correct 21 ms 1612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 32 ms 1432 KB Output is correct
6 Correct 23 ms 1860 KB Output is correct
7 Correct 23 ms 1988 KB Output is correct
8 Correct 26 ms 1456 KB Output is correct
9 Correct 24 ms 1852 KB Output is correct
10 Correct 21 ms 1612 KB Output is correct
11 Correct 7 ms 556 KB Output is correct
12 Correct 20 ms 1824 KB Output is correct
13 Correct 26 ms 1968 KB Output is correct
14 Correct 16 ms 1600 KB Output is correct
15 Correct 25 ms 2236 KB Output is correct
16 Correct 19 ms 1824 KB Output is correct
17 Correct 12 ms 1228 KB Output is correct