Submission #532488

# Submission time Handle Problem Language Result Execution time Memory
532488 2022-03-03T03:09:36 Z syl123456 Red-blue table (IZhO19_stones) C++17
53 / 100
24 ms 1272 KB
#include <bits/stdc++.h>
#define all(i) (i).begin(), (i).end()
using namespace std;
void Debug(bool _split) {}
template<typename T1, typename ...T2>
void Debug(bool _split, T1 i, T2 ...j) {
    if (_split)
        cerr << ", ";
    cerr << i;
    Debug(true, j...);
}
#define debug(args...) cerr << "Line(" << __LINE__ << ") : [" << #args << "] is [", Debug(false, args), cerr << "]" << endl
template<typename T1, typename T2>
ostream& operator << (ostream& i, pair<T1, T2> j) {
    return i << '(' << j.first << ", " << j.second << ')';
}

typedef long long ll;
typedef pair<int, int> pi;
const int inf = 0x3f3f3f3f, lg = 20;
const ll mod = 1e9 + 7, INF = 0x3f3f3f3f3f3f3f3f;

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> n >> m;
        pi ans(n, 0);
        if (m > n)
            ans = pi(0, m);
        for (int i = n; i; --i)
            for (int j = m; j; --j) {
                if (i + j <= ans.first + ans.second)
                    break;
                int x = n + 2 >> 1, y = m + 2 >> 1;
                x = max(0, x - n + i), y = max(0, y - m + j);
                if (!x || (y != j && x * ((j - 1) / (j - y) + 1) <= i))
                    ans = pi(i, j);
            }
        cout << ans.first + ans.second << '\n';
        int x = n + 2 >> 1, y = m + 2 >> 1;
        x = max(0, x - n + ans.first);
        int cnt[m]{};
        for (int i = 0; i < n; ++i) {
            if (i >= ans.first) {
                cout << string(m, '-') << '\n';
                continue;
            }
            cout << string(m - ans.second, '+');
            int tmp = m;
            for (int j = m - ans.second; j < m; ++j)
                if (cnt[j] < x && tmp > y)
                    cout << '-', ++cnt[j], --tmp;
                else
                    cout << '+';
            cout << '\n';
        }
    }
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:37:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   37 |                 int x = n + 2 >> 1, y = m + 2 >> 1;
      |                         ~~^~~
stones.cpp:37:43: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   37 |                 int x = n + 2 >> 1, y = m + 2 >> 1;
      |                                         ~~^~~
stones.cpp:43:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   43 |         int x = n + 2 >> 1, y = m + 2 >> 1;
      |                 ~~^~~
stones.cpp:43:35: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   43 |         int x = n + 2 >> 1, y = m + 2 >> 1;
      |                                 ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 304 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 1 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 1 ms 332 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1272 KB Output is correct
2 Correct 21 ms 1156 KB Output is correct
3 Correct 19 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1220 KB Output is correct
2 Correct 19 ms 1108 KB Output is correct
3 Correct 17 ms 964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Incorrect 1 ms 332 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -