Submission #173917

# Submission time Handle Problem Language Result Execution time Memory
173917 2020-01-05T19:31:43 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]++;
            }
        if (n%2==0)
        for (int i = 1; i <= m; i++)
            if (c[i]==n/2 && a[n][i]==0)
            {
                a[n][i]=1;
                b[n]--;
                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]++;
        }
        if (m%2==0)
        for (int i = 1; i <= n; i++)
            if (b[i]==m/2 && a[i][m]==1)
        {
            a[i][m]=0;
            c[m]--;
            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";
        if (ans>=(n-1)/2+m && ans>=(m-1)/2+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";
            }
        }else
        if (ans<=(n-1)/2+m && (n-1)/2+m>=(m-1)/2+n)
        {
            cout << (n-1)/2+m << "\n";
            for (int i = 1; i <= (n-1)/2; i++)
            {
                for (int j = 1; j <= m; j++) cout << "+";
                cout << "\n";
            }
            for (int i = (n-1)/2+1; i <= n; i++)
            {
                for (int j = 1; j <= m; j++) cout << "-";
                cout << "\n";
            }
        }else
        if (ans<=(m-1)/2+n && (n-1)/2+m<=(m-1)/2+n)
        {
            cout << (m-1)/2+n << "\n";
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= (m-1)/2; j++) cout << "-";
                for (int j = (m-1)/2+1; j <= n; j++) cout << "+";
                cout << "\n";
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 632 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1844 KB Output is correct
2 Correct 32 ms 7248 KB Output is correct
3 Correct 32 ms 8696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 2172 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Wrong answer