답안 #151305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151305 2019-09-02T12:17:43 Z hentai_lover Red-blue table (IZhO19_stones) C++14
38 / 100
407 ms 16124 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, ll s){
    bool ft = 1;
    fr(i, 1, n)fr(j, 1, m){
        if(a[i][j] < 0 && !ft){
            a[i][j] = s;
            if((i + j) % 2)s = 1 - s;
            ft = 1;
        }   else if(a[i][j] < 0){
            if((i + j) % 2 == 0)a[i][j] = s;
            else a[i][j] = 1 - s;
        }
        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 << endl;
//    fr(i, 1, n){
//        fr(j, 1, m)cout << a[i][j] << ' ';
//        cout << endl;
//    }
//    cout << "now: " << now << 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;
}

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, 9){
            //0..2
            fr(j, 0, 9){
                if(n < m){
                    fr(x, 1, i)fr(y, 1, n)a[y][x] = 1;
                    fr(x, 1, j)fr(y, 1, m)a[x][y] = 0;
                }   else {
                    fr(x, 1, j)fr(y, 1, m)a[x][y] = 0;
                    fr(x, 1, i)fr(y, 1, n)a[y][x] = 1;
                }
                calc(n, m, w);
            }
        }
        fr(i, 1, n)fr(j, 1, m)a[i][j] = 0;
        calc(n, m, w);
        fr(i, 1, n)fr(j, 1, m)a[i][j] = 1;
        calc(n, m, w);

        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)
                      ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 14 ms 868 KB Output is correct
4 Incorrect 24 ms 828 KB Wrong answer in test 38 5: 40 < 41
# 결과 실행 시간 메모리 Grader output
1 Correct 407 ms 2260 KB Output is correct
2 Correct 369 ms 13148 KB Output is correct
3 Correct 338 ms 16124 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 388 ms 2808 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 14 ms 868 KB Output is correct
4 Incorrect 24 ms 828 KB Wrong answer in test 38 5: 40 < 41