답안 #800113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800113 2023-08-01T10:20:32 Z Johann L-triominoes (CEOI21_ltriominoes) C++14
28 / 100
171 ms 258816 KB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

const int maxW = 13;
int W, H, K;
map<int, int> blocked;
typedef bitset<1 << maxW> bs;
typedef vector<bs> matrix;
typedef vector<matrix> vvbs;
bs dp[2];
bs mat[1 << maxW];
vvbs lift;

void dfs(int idx, int base, int next, bs &nextdp)
{
    if (idx == W)
    {
        nextdp[next] = true;
        return;
    }
    if (base & (1 << idx))
        dfs(idx + 1, base, next, nextdp);
    else
    {
        // _X my pos: 1 << idx

        // TT
        // _T
        if (idx < W - 1 && ((3 << idx) & next) == 0)
            dfs(idx + 1, base | (1 << idx), next | (3 << idx), nextdp);

        // _TT
        // _T_
        if (idx > 0 && ((3 << (idx - 1)) & next) == 0)
            dfs(idx + 1, base | (1 << idx), next | (3 << (idx - 1)), nextdp);

        // T_
        // TT
        if (idx < W - 1 && (base & (3 << idx)) == 0 && (next & (2 << idx)) == 0)
            dfs(idx + 2, base | (3 << idx), next | (2 << idx), nextdp);

        // _T
        // TT
        if (idx < W - 1 && (base & (3 << idx)) == 0 && (next & (1 << idx)) == 0)
            dfs(idx + 2, base | (3 << idx), next | (1 << idx), nextdp);
    }
}

void mul(bs &base, int liftidx, bs &re, int block = 0)
{
    re = 0;
    for (int j = 0; j < 1 << W; ++j)
    {
        if (!base[j])
            continue;
        if (j & block)
            continue;

        re |= lift[liftidx][j | block];
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> W >> H >> K;
    for (int k = 0, x, y; k < K; ++k)
    {
        cin >> x >> y;
        --x, --y;
        blocked[y] = blocked[y] | (1 << x);
    }

    lift.assign(ceil(log2(H) + 1), matrix(1 << W));
    for (int i = 0; i < 1 << W; ++i)
        dfs(0, i, 0, lift[0][i]);

    assert(W <= 10);

    for (int j = 1; j < sz(lift); ++j)
        for (int i = 0; i < 1 << W; ++i)
            mul(lift[j - 1][i], j - 1, lift[j][i]);

    if (false)
    {
        dp[0] = 0;
        dp[0][0] = true;
        for (int i = 0; i < H; ++i)
        {
            int ii = i & 1;
            int ni = ii ^ 1;
            dp[ni] = 0;

            mul(dp[ii], 0, dp[ni], blocked[i]);
        }

        if (dp[H & 1][0])
            cout << "YES\n";
        else
            cout << "NO\n";
    }
    else
    {
        bs start = 0, tmp;
        start[0] = 1;
        blocked[H - 1] = blocked[H - 1] | 0;
        int h = 0;
        for (pii p : blocked)
        {
            for (int j = sz(lift) - 1; j >= 0; --j)
            {
                if (p.first - h >= (1 << j))
                {
                    h += (1 << j);
                    mul(start, j, tmp);
                    swap(start, tmp);
                }
            }
            mul(start, 0, tmp, p.second);
            swap(start, tmp);
            ++h;
        }

        if (start[0])
            cout << "YES\n";
        else
            cout << "NO\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 1236 KB Output is correct
8 Runtime error 48 ms 67052 KB Execution killed with signal 6
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 4564 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Runtime error 171 ms 258816 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 0 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 476 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 0 ms 468 KB Output is correct
24 Correct 0 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 0 ms 468 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 0 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 476 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 596 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 1 ms 472 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 1 ms 476 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 1 ms 596 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 476 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 476 KB Output is correct
48 Correct 1 ms 468 KB Output is correct
49 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 4 ms 1364 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 3 ms 1748 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 1 ms 1236 KB Output is correct
10 Correct 2 ms 852 KB Output is correct
11 Correct 4 ms 1236 KB Output is correct
12 Correct 9 ms 2396 KB Output is correct
13 Correct 3 ms 852 KB Output is correct
14 Correct 2 ms 852 KB Output is correct
15 Correct 3 ms 1364 KB Output is correct
16 Correct 7 ms 2396 KB Output is correct
17 Correct 2 ms 1364 KB Output is correct
18 Correct 3 ms 1364 KB Output is correct
19 Correct 6 ms 2260 KB Output is correct
20 Correct 6 ms 2388 KB Output is correct
21 Correct 2 ms 1364 KB Output is correct
22 Correct 5 ms 2388 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 3 ms 1364 KB Output is correct
25 Correct 5 ms 2388 KB Output is correct
26 Correct 2 ms 852 KB Output is correct
27 Correct 2 ms 1236 KB Output is correct
28 Correct 2 ms 1236 KB Output is correct
29 Correct 2 ms 1236 KB Output is correct
30 Correct 2 ms 1236 KB Output is correct
31 Correct 2 ms 1236 KB Output is correct
32 Correct 8 ms 2388 KB Output is correct
33 Correct 7 ms 2260 KB Output is correct
34 Correct 5 ms 2132 KB Output is correct
35 Correct 5 ms 2132 KB Output is correct
36 Correct 2 ms 1236 KB Output is correct
37 Correct 5 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 4564 KB Output is correct
2 Correct 15 ms 4564 KB Output is correct
3 Correct 46 ms 7892 KB Output is correct
4 Runtime error 138 ms 217036 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 2 ms 1236 KB Output is correct
8 Runtime error 48 ms 67052 KB Execution killed with signal 6
9 Halted 0 ms 0 KB -