답안 #961032

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
961032 2024-04-11T12:25:22 Z LucaIlie L-triominoes (CEOI21_ltriominoes) C++17
28 / 100
8000 ms 22128 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_W = 13;
const int MAX_N = (1 << MAX_W);
map<int, int> conf;
bitset<MAX_N> adj[30][MAX_N], adjR[30][MAX_N];

bool hasBit( int mask, int i ) {
    return ((mask >> i) & 1);
}

int main() {
    int w, h, k;

    cin >> w >> h >> k;
    conf[0] = conf[h - 1] = 0;
    for ( int i = 0; i < k; i++ ) {
        int l, c;
        cin >> l >> c;
        l--;
        c--;
        conf[c] += (1 << l);
    }

    int n = (1 << w);
    for ( int mask = 0; mask < n; mask++ ) {
        vector<int> prvVec1 = { 0 }, prvVec2 = { 0 };
        for ( int i = 0; i < w; i++ ) {
            vector<int> vec;

            if ( hasBit( mask, i )) {
                for ( int m: prvVec1 )
                    vec.push_back( m );
            } else {
                for ( int m: prvVec1 ) {
                    if ( i >= 1 && !hasBit( m, i - 1 ) && !hasBit( m, i ))
                        vec.push_back( m + (1 << (i - 1)) + (1 << i));
                    if ( i <= w - 2 && !hasBit( m, i ) && !hasBit( m, i + 1 ))
                        vec.push_back( m + (1 << i) + (1 << (i + 1)));
                }

                if ( i >= 1 && !hasBit( mask, i - 1 )) {
                    for ( int m: prvVec2 ) {
                        if ( !hasBit( m, i - 1 ))
                            vec.push_back( m + (1 << (i - 1)));
                        if ( !hasBit( m, i ))
                            vec.push_back( m + (1 << i));
                    }
                }
            }

            prvVec2 = prvVec1;
            prvVec1 = vec;
        }

        for ( int m: prvVec1 ) {
            adj[0][mask][m] = true;
            adjR[0][m][mask] = true;
        }
    }

    for ( int l = 1; l < 30; l++ ) {
        for ( int i = 0; i < n; i++ ) {
            for ( int j = 0; j < n; j++ ) {
                adj[l][i][j] = ((adj[l - 1][i] & adjR[l - 1][j]).count() > 0);
                adjR[l][j][i] = ((adj[l - 1][i] & adjR[l - 1][j]).count() > 0);
            }
        }
    }

    bitset<MAX_N> pos;
    pos[conf[0]] = true;
    int lst = 0;
    for ( auto p: conf ) {
        if ( p.first == 0 )
            continue;

        int x = p.first - lst;
        lst = p.first;

        for ( int l = 30 - 1; l >= 0; l-- ) {
            if ( x >= (1 << l) ) {
                bitset<MAX_N> newPos;
                for ( int m = 0; m < n; m++ ) {
                    if ( pos[m] )
                        newPos |= adj[l][m];
                }
                pos = newPos;
                x -= (1 << l);
            }
        }

        bitset<MAX_N> newPos = pos;
        pos.reset();
        for ( int m = 0; m < n; m++ ) {
            if ( (p.second & m) == 0 )
                pos[p.second | m] = newPos[m];
        }

    }

    cout << (pos[n - 1] ? "YES\n" : "NO\n");

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Correct 3 ms 3420 KB Output is correct
3 Correct 4 ms 3420 KB Output is correct
4 Correct 7 ms 3672 KB Output is correct
5 Correct 8 ms 3676 KB Output is correct
6 Correct 24 ms 4952 KB Output is correct
7 Correct 363 ms 10268 KB Output is correct
8 Execution timed out 8098 ms 17672 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 353 ms 10568 KB Output is correct
2 Correct 3 ms 3416 KB Output is correct
3 Correct 2 ms 3160 KB Output is correct
4 Correct 4 ms 3420 KB Output is correct
5 Execution timed out 8060 ms 17624 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3164 KB Output is correct
2 Correct 3 ms 3164 KB Output is correct
3 Correct 3 ms 3164 KB Output is correct
4 Correct 2 ms 3164 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 3 ms 3420 KB Output is correct
8 Correct 2 ms 2980 KB Output is correct
9 Correct 3 ms 3160 KB Output is correct
10 Correct 2 ms 3160 KB Output is correct
11 Correct 2 ms 3164 KB Output is correct
12 Correct 2 ms 3164 KB Output is correct
13 Correct 2 ms 3160 KB Output is correct
14 Correct 2 ms 3164 KB Output is correct
15 Correct 2 ms 3164 KB Output is correct
16 Correct 3 ms 3420 KB Output is correct
17 Correct 4 ms 3416 KB Output is correct
18 Correct 3 ms 3388 KB Output is correct
19 Correct 3 ms 3416 KB Output is correct
20 Correct 3 ms 3252 KB Output is correct
21 Correct 3 ms 3420 KB Output is correct
22 Correct 4 ms 3420 KB Output is correct
23 Correct 3 ms 3420 KB Output is correct
24 Correct 3 ms 3420 KB Output is correct
25 Correct 3 ms 3256 KB Output is correct
26 Correct 3 ms 3420 KB Output is correct
27 Correct 4 ms 3420 KB Output is correct
28 Correct 2 ms 3160 KB Output is correct
29 Correct 3 ms 3420 KB Output is correct
30 Correct 2 ms 3164 KB Output is correct
31 Correct 3 ms 3160 KB Output is correct
32 Correct 3 ms 3420 KB Output is correct
33 Correct 4 ms 3420 KB Output is correct
34 Correct 2 ms 3164 KB Output is correct
35 Correct 4 ms 3420 KB Output is correct
36 Correct 5 ms 3420 KB Output is correct
37 Correct 3 ms 3164 KB Output is correct
38 Correct 2 ms 3008 KB Output is correct
39 Correct 2 ms 3164 KB Output is correct
40 Correct 3 ms 3420 KB Output is correct
41 Correct 3 ms 3256 KB Output is correct
42 Correct 3 ms 3164 KB Output is correct
43 Correct 3 ms 3420 KB Output is correct
44 Correct 2 ms 3164 KB Output is correct
45 Correct 4 ms 3416 KB Output is correct
46 Correct 2 ms 2980 KB Output is correct
47 Correct 3 ms 3420 KB Output is correct
48 Correct 4 ms 3420 KB Output is correct
49 Correct 2 ms 3160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3676 KB Output is correct
2 Correct 8 ms 3676 KB Output is correct
3 Correct 27 ms 4764 KB Output is correct
4 Correct 23 ms 4692 KB Output is correct
5 Correct 89 ms 6560 KB Output is correct
6 Correct 23 ms 4696 KB Output is correct
7 Correct 23 ms 4632 KB Output is correct
8 Correct 23 ms 4700 KB Output is correct
9 Correct 23 ms 4700 KB Output is correct
10 Correct 9 ms 3676 KB Output is correct
11 Correct 26 ms 4856 KB Output is correct
12 Correct 95 ms 6484 KB Output is correct
13 Correct 8 ms 3676 KB Output is correct
14 Correct 8 ms 3676 KB Output is correct
15 Correct 25 ms 4652 KB Output is correct
16 Correct 113 ms 6484 KB Output is correct
17 Correct 24 ms 4696 KB Output is correct
18 Correct 25 ms 4692 KB Output is correct
19 Correct 96 ms 6616 KB Output is correct
20 Correct 92 ms 6564 KB Output is correct
21 Correct 25 ms 4692 KB Output is correct
22 Correct 93 ms 6484 KB Output is correct
23 Correct 10 ms 3676 KB Output is correct
24 Correct 26 ms 4648 KB Output is correct
25 Correct 98 ms 6764 KB Output is correct
26 Correct 8 ms 3676 KB Output is correct
27 Correct 29 ms 4716 KB Output is correct
28 Correct 25 ms 4700 KB Output is correct
29 Correct 23 ms 4660 KB Output is correct
30 Correct 31 ms 4788 KB Output is correct
31 Correct 23 ms 4700 KB Output is correct
32 Correct 105 ms 6536 KB Output is correct
33 Correct 94 ms 6732 KB Output is correct
34 Correct 95 ms 6668 KB Output is correct
35 Correct 92 ms 6704 KB Output is correct
36 Correct 25 ms 4624 KB Output is correct
37 Correct 91 ms 6736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 355 ms 10316 KB Output is correct
2 Correct 368 ms 10580 KB Output is correct
3 Correct 1410 ms 22128 KB Output is correct
4 Execution timed out 8029 ms 17648 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Correct 3 ms 3420 KB Output is correct
3 Correct 4 ms 3420 KB Output is correct
4 Correct 7 ms 3672 KB Output is correct
5 Correct 8 ms 3676 KB Output is correct
6 Correct 24 ms 4952 KB Output is correct
7 Correct 363 ms 10268 KB Output is correct
8 Execution timed out 8098 ms 17672 KB Time limit exceeded
9 Halted 0 ms 0 KB -