Submission #158890

# Submission time Handle Problem Language Result Execution time Memory
158890 2019-10-19T10:55:18 Z elizavetaa Red-blue table (IZhO19_stones) C++14
0 / 100
90 ms 1440 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

#define pb push_back
#define F first
#define S second
#define ll long long
#define lld long double
#define pii pair < int, int >

using namespace std;

//template <typename T>
//using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int N = 3e5 + 229;
const int M = 1e9 + 7;
const ll M2 = 1e9 + 9;
const int mod = 998244353;
const int Sx[8] = {1, 1, -1, -1, -2, 2, 2, -2};
const int Sy[8] = {-2, 2, 2, -2, 1, 1, -1, -1};
const lld eps = 1e-7;
const double pi = acos(-1.0);

//mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
#endif
    int t;
    cin >> t;
    while(t--) {
        int n, m;
        cin >> n >> m;
        if(n <= m) {
        int ans = m;
        char a[n][m];
        pair <int, int> k[m];
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                a[i][j] = '-';
                k[j].F = 0;k[j].S = j;
            }
        }
        int pos = m / 2 + 1;
        for(int z = 0; z < n; ++z) {
         if(k[pos - 1].F >= n / 2)break;
         ans++;
            for(int i = 0; i < pos; ++i) {
                a[z][k[i].S] = '+';
                k[i].F++;
            }
            sort(k, k + n);

        }
        cout << ans << endl;
            for(int i = 0; i < n; ++i) {
                for(int j = 0; j < m; ++j)
                cout << a[i][j];
            cout << endl;
            }
        }
        else {
        int ans = n;
        char a[n][m];
        pair <int, int> k[n];
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                a[i][j] = '+';
            }
            k[i].F = 0;k[i].S = i;
        }
        int pos = n / 2 + 1;
        for(int z = 0; z < m; ++z) {
         if(k[pos - 1].F >= m / 2)break;
         ans++;
            for(int i = 0; i < pos; ++i) {
                a[k[i].S][z] = '-';
                k[i].F++;
            }
            sort(k, k + m);

        }
        cout << ans << endl;
            for(int i = 0; i < n; ++i) {
                for(int j = 0; j < m; ++j)
                cout << a[i][j];
            cout << endl;
            }
        }

}}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 376 KB in the table A+B is not equal to 21
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 5
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 1440 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 1344 KB in the table A+B is not equal to 46
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB in the table A+B is not equal to 5