답안 #151330

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151330 2019-09-02T13:13:40 Z hentai_lover Red-blue table (IZhO19_stones) C++14
21 / 100
119 ms 16212 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define y1 yy
#define tm hui_pizda
#define ft first
#define sd second
#define pb push_back
#define pf push_front
#define sz size()
#define cnt continue
#define m_p make_pair
#define fr(i, l, r) for(int i = l; i <= r; ++ i)
#define rf(i, r, l) for(int i = r; i >= l; -- i)
#pragma GCC optimize(-O3)
#pragma GCC optimize(Ofast)
#pragma GCC optimize("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

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

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <pii> vpi;
typedef vector <pll> vpl;

mt19937_64 rnd(time(NULL));

const ll N = 1010;
const ll oo = 1e18 + 10;
const ll mod = 1000003;

ll a[N][N], ans[N][N], kx[N], ky[N], kans, n, m, T, w;

void calc(ll n, ll m){
    bool ft = 1;
    fr(i, 1, n)fr(j, 1, m){
        if(a[i][j])kx[i] ++;
        else ky[j] ++;
    }

    ll now = 0;
    fr(i, 1, n)if(kx[i] * 2 > m)now ++;
    fr(i, 1, m)if(ky[i] * 2 > n)now ++;

//    cout << "    " << now << endl;
//    fr(i, 1, n){
//        fr(j, 1, m)cout << a[i][j] << ' ';
//        cout << endl;
//    }
    if(now > kans){
        kans = now;
        fr(i, 1, n)fr(j, 1, m)ans[i][j] = a[i][j];
    }
    fr(i, 1, n)kx[i] = 0;
    fr(i, 1, m)ky[i] = 0;
    //fr(i, 1, n)fr(j, 1, m)a[i][j] = -1;
}

void _fill(ll i, ll j, ll w, ll n, ll m){
    fr(x, i + 1, n){
        fr(y, j + 1, m){
            if((x + y - i - j - 2) % 2 == 0)a[x][y] = w;
            else a[x][y] = 1 - w;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> T;
    while(T --){
        cin >> n >> m;
        fr(i, 1, n)fr(j, 1, m)a[i][j] = ans[i][j] = -1;
        kans = -1;

        if(n < m)w = 0;
        else w = 1;

        //0..2
        fr(i, 0, 2){
            //0..2
            fr(j, 0, 2){
                fr(y, 1, j)fr(x, 1, n)a[x][y] = 1;
                fr(x, 1, i)fr(y, 1, m)a[x][y] = 0;
                _fill(i, j, 0, n, m);
                calc(n, m);
                _fill(i, j, 1, n, m);
                calc(n, m);
                fr(x, 1, i)fr(y, 1, m)a[x][y] = 0;
                fr(y, 1, j)fr(x, 1, n)a[x][y] = 1;
                _fill(i, j, 0, n, m);
                calc(n, m);
                _fill(i, j, 1, n, m);
                calc(n, m);
            }
        }

        cout << kans << endl;
        fr(i, 1, n){
            fr(j, 1, m){
                if(ans[i][j] == 0)cout << '-';
                else cout << '+';
            }
            cout << "\n";
        }
        cout << endl;
    }
    return 0;
}
/*
*/

Compilation message

stones.cpp:15:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(-O3)
                      ^
stones.cpp:16:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(Ofast)
                      ^~~~~
stones.cpp: In function 'void calc(ll, ll)':
stones.cpp:6:12: warning: unused variable 'first' [-Wunused-variable]
 #define ft first
            ^
stones.cpp:43:10: note: in expansion of macro 'ft'
     bool ft = 1;
          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 4: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 4: 4 < 5
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 2288 KB Output is correct
2 Correct 118 ms 13156 KB Output is correct
3 Correct 108 ms 16212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 108 ms 2872 KB Wrong answer in test 4 4: 4 < 5
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 4 4: 4 < 5