Submission #532507

# Submission time Handle Problem Language Result Execution time Memory
532507 2022-03-03T03:38:09 Z syl123456 Red-blue table (IZhO19_stones) C++17
11 / 100
10 ms 1868 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;
        vector<string> s(n, string(m, '+'));
        for (int i = 0; i < n + 2 >> 1; ++i)
            for (int j = m + 2 >> 1; j < m; ++j)
                s[i][j] = s[n - 1 - i][m - 1 - j] = '-';
        for (int i = 0; i < n; ++i)
            if (s[i][0] == '-' && s[i][m - 1] == '-')
                s[i] = string(m, '-');
        for (int j = 0; j < m; ++j)
            if (s[0][j] == '+' && s[n - 1][j] == '+')
                for (int i = 0; i < n; ++i)
                    s[i][j] = '+';
        int ans = 0;
        for (int i = 0; i < n; ++i)
            if (count(all(s[i]), '+') > count(all(s[i]), '-'))
                ++ans;
        for (int j = 0; j < m; ++j) {
            int tmp = 0;
            for (int i = 0; i < n; ++i)
                tmp += s[i][j] == '+' ? -1 : 1;
            if (tmp > 0)
                ++ans;
        }
        cout << ans << '\n';
        for (string i : s)
            cout << i << '\n';
    }
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:31:31: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |         for (int i = 0; i < n + 2 >> 1; ++i)
      |                             ~~^~~
stones.cpp:32:28: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |             for (int j = m + 2 >> 1; j < m; ++j)
      |                          ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Wrong answer in test 4 4: 4 < 5
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Wrong answer in test 4 3: 4 < 5
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Wrong answer in test 4 4: 4 < 5
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1268 KB Output is correct
2 Correct 7 ms 1612 KB Output is correct
3 Correct 5 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 1356 KB Wrong answer in test 4 4: 4 < 5
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Wrong answer in test 4 4: 4 < 5
3 Halted 0 ms 0 KB -