Submission #157926

# Submission time Handle Problem Language Result Execution time Memory
157926 2019-10-13T19:45:43 Z mrboorger Red-blue table (IZhO19_stones) C++14
0 / 100
33 ms 1564 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double
#define sqr(x) (x) * (x)
//#define all(a) a.begin(), a.end()

using namespace std;
using namespace __gnu_pbds;

//typedef tree<
//pair <int, int>,
//null_type,
//greater<pair <int, int>>,
//rb_tree_tag,
//tree_order_statistics_node_update>
//ordered_set;

const int maxn = 1002;
char a[maxn][maxn], b[maxn][maxn];

int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    for(int ii = 0; ii < t; ++ii)
    {
        int n, m;
        cin >> n >> m;
        bool f = false;
        if (n > m)
        {
            swap(n, m);
            f = true;
        }
        if (n <= 2)
        {
            for(int i = 0; i < n; ++i)
                for(int j = 0; j < m; ++j)
                    a[i][j] = '-';
        }
        else
//        if (m % 2 == 1)
        {
            int c = m / 2 + (m % 2 == 1);
            int lol = 0;
            for(int i = 0; i < n / 2; ++i)
            {
                for(int j = 0; j < m; ++j)
                    a[i][j] = '+';
                for(int j = 0; j < m - c; ++j)
                    a[i][min(m - 1, lol + j)] = '-';
                lol += m - c;
            }
            for(int i = n / 2; i < n; ++i)
                for(int j = 0; j < m; ++j)
                    a[i][j] = '-';
        }
//        else
//        {
//            for(int i = 0; i < n / 2; ++i)
//                for(int j = 0; j < m; ++j)
//                    a[i][j] = '-';
//            for(int i = n / 2; i < n; ++i)
//                for(int j = 0; j < m; ++j)
//                    a[i][j] = '+';
//        }
        if (f)
        {
            for(int i = 0; i < n; ++i)
                for(int j = 0; j < m; ++j)
                    b[i][j] = a[i][j];
            swap(n, m);
            for(int i = 0; i < n; ++i)
                for(int j = 0; j < m; ++j)
            {
                if (b[j][i] == '-') a[i][j] = '+';
                    else            a[i][j] = '-';
            }
        }
        int ans = 0;
        for(int i = 0; i < n; ++i)
        {
            int k = 0;
            for(int j = 0; j < m; ++j)
                if (a[i][j] == '+') ++k;
            if (k * 2 > m) ++ans;
        }
        for(int j = 0; j < m; ++j)
        {
            int k = 0;
            for(int i = 0; i < n; ++i)
                if (a[i][j] == '-') ++k;
            if (k * 2 > n) ++ans;
        }
        cout << ans << '\n';
        for(int i = 0; i < n; ++i)
        {
            for(int j = 0; j < m; ++j)
                cout << a[i][j];
            cout << '\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 4: 4 < 5
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Wrong answer in test 4 3: 4 < 5
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 4: 4 < 5
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 1556 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1564 KB Wrong answer in test 24 24: 34 < 44
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 4: 4 < 5