Submission #7643270


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll M[1005][1005];

int main()
{
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    if (H * A != W * B)
    {
        cout << "No" << endl;
        return 0;
    }
    memset(M, 0, sizeof(M));
    if (B == 0)
    {
        REP(i, H)
        {
            REP(j, A)
            {
                M[i][j] = 1;
            }
        }
        REP(i, H)
        {
            REP(j, W)
            {
                cout << M[i][j];
            }
            cout << endl;
        }
        return 0;
    }
    REP(i, B)
    {
        REP(j, W)
        {
            M[i][j] = 1;
        }
    }
    if (A == 0)
    {
        REP(i, H)
        {
            REP(j, W)
            {
                cout << M[i][j];
            }
            cout << endl;
        }
        return 0;
    }

    REP(i, B + 1)
    {
        //! i個を分割する
        ll n = (W - A) * i;
        if (n % A != 0)
            continue;

        //! n/A+B-i段プラスできる
        if (n / A + B - i != H - B)
            continue;
        //! できる
        int next = B;
        REP(h, B - i)
        {
            REP(w, A)
            {
                swap(M[next][w], M[h][w]);
            }
            next++;
        }
        int m = 0;
        FOR(h, B, B - i)
        {
            FOR(w, W, A)
            {
                if (m >= A)
                {
                    m = 0;
                    next++;
                }
                if (next >= H)
                {
                    cout << "No" << endl;
                    return 0;
                }
                swap(M[next][w], M[h][w]);
                m++;
            }
        }

        REP(h, H)
        {
            REP(w, W)
            {
                cout << M[h][w];
            }
            cout << endl;
        }
        return 0;
    }

    cout << "No" << endl;

    return 0;
}

Submission Info

Submission Time
Task A - 01 Matrix
User coco18000
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2266 Byte
Status WA
Exec Time 50 ms
Memory 9088 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 1
WA × 1
AC × 3
WA × 11
Set Name Test Cases
Sample sample-01.txt, sample-02.txt
All 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, sample-01.txt, sample-02.txt
Case Name Status Exec Time Memory
01-01.txt AC 4 ms 8192 KB
01-02.txt WA 1 ms 256 KB
01-03.txt WA 1 ms 256 KB
01-04.txt WA 1 ms 256 KB
01-05.txt WA 1 ms 256 KB
01-06.txt WA 1 ms 256 KB
01-07.txt WA 1 ms 256 KB
01-08.txt WA 1 ms 256 KB
01-09.txt WA 1 ms 256 KB
01-10.txt AC 50 ms 9088 KB
01-11.txt WA 1 ms 256 KB
01-12.txt WA 1 ms 256 KB
sample-01.txt AC 4 ms 8192 KB
sample-02.txt WA 1 ms 256 KB