답안 #158891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
158891 2019-10-19T10:59:50 Z elizavetaa Red-blue table (IZhO19_stones) C++17
0 / 100
90 ms 1380 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;
            }
        }

}}

# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 376 KB in the table A+B is not equal to 21
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 90 ms 1344 KB Wrong answer in test 97 21: 107 < 116
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 1380 KB in the table A+B is not equal to 46
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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