Submission #147726

# Submission time Handle Problem Language Result Execution time Memory
147726 2019-08-30T13:40:38 Z andrew Red-blue table (IZhO19_stones) C++14
0 / 100
145 ms 1656 KB
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 2e5;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

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

template <typename T> void vout(T s){cout << s << endl;exit(0);}

char a[1001][1001], ma[1001][1001];
ll ans, res;

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    ll q;
    cin >> q;

    while(q--){
        ll n, m;
        cin >> n >> m;
        ans = 0;
        ll cstr = m / 2 + 1, cstl = n / 2 + 1;

        set <pll> st;

        vector <pll> V;

        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                a[i][j] = '+';
            }
            if(cstr != m)st.insert({m - cstr, i});
        }

        res = n;

        for(int j = 1; j <= m; j++){
            if(st.size() >= cstl){
                ll k = cstl;
                while(k--){
                    V.p_b(*--st.end());
                    V.back().fi--;
                    st.erase(--st.end());
                    a[V.back().se][j] = '-';
                }
                for(auto i : V){
                    if(i.fi == 0)continue;
                    st.insert(i);
                }
                res++;
                V.clear();
            }else break;
        }

        ans = res;

        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)ma[i][j] = a[i][j];

        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++){
                a[i][j] = '-';
            }
        }

        st.clear();

        for(int i = 1; i <= m; i++)if(cstl != n)st.insert({n - cstl, i});

        res = m;

        for(int i = 1; i <= n; i++){
            if(st.size() >= cstr){
                ll k = cstr;
                while(k--){
                    V.p_b(*--st.end());
                    V.back().fi--;
                    st.erase(--st.end());
                    a[i][V.back().se] = '+';
                }
                for(auto i : V){
                    if(i.fi == 0)continue;
                    st.insert(i);
                }
                res++;
                V.clear();
            }else break;
        }

        if(res > ans){
            for(int i = 1; i <= n; i++)
            for(int j = 1; j <= m; j++)ma[i][j] = a[i][j];
        }

        cout << res << "\n";

        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= m; j++)cout << ma[i][j];
            cout << "\n";
        }

    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}

Compilation message

stones.cpp: In function 'int main()':
stones.cpp:63:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(st.size() >= cstl){
                ~~~~~~~~~~^~~~~~~
stones.cpp:98:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(st.size() >= cstr){
                ~~~~~~~~~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Extra information in the output file
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 504 KB in the table A+B is not equal to 1
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Extra information in the output file
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 145 ms 1656 KB in the table A+B is not equal to 112
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 1588 KB Extra information in the output file
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Extra information in the output file
2 Halted 0 ms 0 KB -