Submission #800554

# Submission time Handle Problem Language Result Execution time Memory
800554 2023-08-01T16:06:51 Z Johann L-triominoes (CEOI21_ltriominoes) C++14
17 / 100
2277 ms 67104 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> vbs;
typedef vector<vbs> vvbs;
bs dp[2];
bs mat[1 << maxW];
vvbs lift;
vvbs mod;

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(4, vbs(1 << W));
    for (int i = 0; i < 1 << W; ++i)
        dfs(0, i, 0, lift[0][i]);

    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]);

    assert(W < 13);

    mod.assign(1 << W, vbs(3));
    for (int i = 0; i < (1 << W); ++i)
    {
        mul(lift[3][i], 2, mod[i][0]);
        mul(mod[i][0], 0, mod[i][1]);
        mul(mod[i][1], 0, mod[i][2]);
    }

    assert(W < 13);

    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)
        {
            int delta = p.first - h;
            if (delta >= 11)
            {
                tmp = 0;
                for (int i = 0; i < (1 << W); ++i)
                    if (start[i])
                        tmp |= mod[i][delta % 3];
                swap(tmp, start);
                h = p.first;
            }
            else
            {
                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);
                    }
                }
                assert(p.first == h);
            }
            mul(start, 0, tmp, p.second);
            swap(start, tmp);
            ++h;
        }

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

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1232 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 2230 ms 29228 KB Output is correct
6 Correct 550 ms 14788 KB Output is correct
7 Correct 145 ms 7496 KB Output is correct
8 Correct 10 ms 2128 KB Output is correct
9 Incorrect 0 ms 340 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 0 ms 340 KB Output is correct
7 Incorrect 0 ms 340 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 1 ms 500 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 2 ms 724 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 2 ms 724 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 552 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 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 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 2 ms 724 KB Output is correct
35 Correct 2 ms 724 KB Output is correct
36 Correct 1 ms 480 KB Output is correct
37 Correct 2 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1232 KB Output is correct
2 Correct 3 ms 1232 KB Output is correct
3 Correct 10 ms 2176 KB Output is correct
4 Correct 2277 ms 29244 KB Output is correct
5 Correct 589 ms 14788 KB Output is correct
6 Correct 571 ms 14844 KB Output is correct
7 Correct 142 ms 7536 KB Output is correct
8 Correct 150 ms 7492 KB Output is correct
9 Correct 144 ms 7520 KB Output is correct
10 Correct 141 ms 7528 KB Output is correct
11 Correct 2241 ms 29304 KB Output is correct
12 Correct 563 ms 14788 KB Output is correct
13 Correct 37 ms 3944 KB Output is correct
14 Correct 2267 ms 29228 KB Output is correct
15 Correct 4 ms 1232 KB Output is correct
16 Correct 3 ms 1232 KB Output is correct
17 Correct 155 ms 7568 KB Output is correct
18 Correct 12 ms 2128 KB Output is correct
19 Correct 37 ms 3960 KB Output is correct
20 Correct 2264 ms 29312 KB Output is correct
21 Correct 581 ms 14916 KB Output is correct
22 Correct 4 ms 1232 KB Output is correct
23 Correct 41 ms 3960 KB Output is correct
24 Runtime error 2204 ms 67104 KB Execution killed with signal 6
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -