답안 #173905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173905 2020-01-05T19:07:23 Z _Enkognit Red-blue table (IZhO19_stones) C++14
11 / 100
32 ms 8696 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

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

#define ll long long
#define mp make_pair
#define pb push_back
#define ld long double
#define fi first
#define se second
#define pld pair<ld,ld>
#define pll pair<ll,ll>
#define sqr(a) ((a)*(a))
#define pii pair<int,int>
#define y1 Enkognit
#define sqr(a) ((a)*(a))

using namespace std;

mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

const ll md1=1e9+7, md2=998244357, md3=rnd()%(ll)(1e8), p1=31, p2=37, p3=41;

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

ll n, m, k, l, r, i, j, a[1001][1001], b[1001], c[1001];

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll q;
    cin >> q;
    while (q--)
    {
        cin >> n >> m;
        for (int i = 1; i <= max(n,m); i++) b[i]=0,c[i]=0;
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= m; j++) {a[i][j]=(i+j)%2;b[i]+=((i+j)%2==0);c[j]+=(i+j)%2;}
        for (int i = 1; i <= m; i++)
            if (c[i]==n/2 && a[1][i]==0)
            {
                a[1][i]=1;
                b[1]--;
                c[i]++;
            }
        for (int i = 1; i <= n; i++)
            if (b[i]==m/2 && a[i][1]==1)
        {
            a[i][1]=0;
            c[1]--;
            b[i]++;
        }
        ll ans=0;
        for (int i = 1; i <= n; i++) if (b[i]>m/2) {ans++;}
        //cout << "\n";
        for (int i = 1; i <= m; i++) if (c[i]>n/2) {ans++;}
        //cout << "\n";
        cout << ans << "\n";
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
                if (a[i][j]) cout << '-'; else cout << "+";
            cout << "\n";
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 2 4: 2 < 4
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 632 KB Wrong answer in test 20 2: 10 < 20
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer in test 2 4: 2 < 4
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1832 KB Output is correct
2 Correct 32 ms 7220 KB Output is correct
3 Correct 32 ms 8696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 2168 KB Wrong answer in test 24 24: 23 < 44
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 2 4: 2 < 4