답안 #753922

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753922 2023-06-06T10:21:55 Z lohacho L-triominoes (CEOI21_ltriominoes) C++14
52 / 100
717 ms 97832 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define mi(x, y) (x = min(x, y))
#define ma(x, y) (x = max(x, y))
using namespace std;
 
const int NS = 13;
int way[(1 << NS) + 4][(1 << NS) + 4];
vector<int> vway[(1 << NS) + 4];
int dist[(1 << NS) + 4];
 
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int w, h, k;
    cin >> w >> h >> k;
    vector<pair<int, int>> a(k);
    for(int i = 0; i < k; ++i){
        cin >> a[i].first >> a[i].second;
        swap(a[i].first, a[i].second);
        --a[i].first, --a[i].second;
    }
    sort(a.begin(), a.end());
 
    for(int i = 0; i < (1 << w); ++i){
        auto dfs = [&](auto&&self, int x, int bt)->void{
            int now = (i >> x & 1);
            if(now){
                self(self, x + 1, bt);
                return;
            }
            if(x == w){
                way[i][bt] = 1;
                return;
            }
            int nxt = (i >> (x + 1) & 1);
            int btnow = (bt >> x & 1);
 
            if(x + 1 < w && !nxt && !btnow){
                self(self, x + 2, bt | 1 << x);
            }
            if(x + 1 < w && !nxt){
                self(self, x + 2, bt | 1 << (x + 1));
            }
            if(x + 1 < w && !btnow){
                self(self, x + 1, bt | 1 << x | 1 << (x + 1));
            }
            if(!btnow && x && !(bt >> (x - 1) & 1)){
                self(self, x + 1, bt | 1 << x | 1 << (x - 1));
            }
        };
        dfs(dfs, 0, 0);
        for(int j = 0; j < (1 << w); ++j){
            if(way[i][j]){
                vway[i].push_back(j);
            }
        }
    }
 
    vector<int> dp(1 << w);
    int p = 0, bt = 0;
    while(p < k && a[p].first == 0){
        bt |= (1 << a[p].second);
        ++p;
    }
    dp[bt] = 1;
    for(int i = 1; i < h; ++i){
        int nxt = h - 1;
        if(p < k) nxt = a[p].first;
        int add = (nxt - 9 - i) / 3;
        if(add > 0) i += add * 3;
        bt = 0;
        while(p < k && a[p].first == i){
            bt |= (1 << a[p].second);
            ++p;
        }
        vector<int> ndp(1 << w);
        for(int j = 0; j < (1 << w); ++j){
            if(!dp[j]) continue;
            for(auto&nxt:vway[j]){
                //cout << i << ' ' << j << ' ' << nxt << ' ' << bt << endl;
                if(!(nxt & bt)){
                    ndp[nxt | bt] = 1;
                }
            }
        }
        swap(dp, ndp);
    }
 
    if(dp[(1 << w) - 1]){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 45 ms 37660 KB Output is correct
6 Correct 14 ms 14292 KB Output is correct
7 Correct 6 ms 6356 KB Output is correct
8 Correct 2 ms 1620 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 724 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Incorrect 0 ms 468 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 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 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Incorrect 1 ms 468 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 0 ms 596 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 2 ms 724 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 1 ms 596 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 1 ms 724 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 724 KB Output is correct
35 Correct 1 ms 724 KB Output is correct
36 Correct 1 ms 596 KB Output is correct
37 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 2 ms 1620 KB Output is correct
4 Correct 153 ms 37636 KB Output is correct
5 Correct 47 ms 14300 KB Output is correct
6 Correct 51 ms 14308 KB Output is correct
7 Correct 14 ms 6356 KB Output is correct
8 Correct 19 ms 6404 KB Output is correct
9 Correct 8 ms 6356 KB Output is correct
10 Correct 10 ms 6356 KB Output is correct
11 Correct 43 ms 37704 KB Output is correct
12 Correct 15 ms 14240 KB Output is correct
13 Correct 2 ms 3284 KB Output is correct
14 Correct 46 ms 37672 KB Output is correct
15 Correct 3 ms 980 KB Output is correct
16 Correct 2 ms 980 KB Output is correct
17 Correct 7 ms 6356 KB Output is correct
18 Correct 5 ms 1620 KB Output is correct
19 Correct 5 ms 3336 KB Output is correct
20 Correct 195 ms 37728 KB Output is correct
21 Correct 76 ms 14300 KB Output is correct
22 Correct 3 ms 980 KB Output is correct
23 Correct 16 ms 3340 KB Output is correct
24 Correct 707 ms 97760 KB Output is correct
25 Correct 261 ms 37724 KB Output is correct
26 Correct 717 ms 97712 KB Output is correct
27 Correct 690 ms 97644 KB Output is correct
28 Correct 169 ms 97832 KB Output is correct
29 Correct 348 ms 97800 KB Output is correct
30 Correct 404 ms 97612 KB Output is correct
31 Correct 192 ms 97800 KB Output is correct
32 Correct 297 ms 97748 KB Output is correct
33 Correct 203 ms 37724 KB Output is correct
34 Correct 524 ms 97708 KB Output is correct
35 Correct 679 ms 97736 KB Output is correct
36 Correct 655 ms 97740 KB Output is correct
37 Correct 74 ms 37708 KB Output is correct
38 Correct 134 ms 37720 KB Output is correct
39 Correct 73 ms 14300 KB Output is correct
40 Correct 550 ms 97740 KB Output is correct
41 Correct 79 ms 14304 KB Output is correct
42 Correct 552 ms 97712 KB Output is correct
43 Correct 532 ms 97756 KB Output is correct
44 Correct 515 ms 97712 KB Output is correct
45 Correct 531 ms 97708 KB Output is correct
46 Correct 47 ms 37608 KB Output is correct
47 Correct 653 ms 97712 KB Output is correct
48 Correct 539 ms 97600 KB Output is correct
49 Correct 260 ms 97708 KB Output is correct
50 Correct 48 ms 14292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 1 ms 468 KB Output isn't correct
3 Halted 0 ms 0 KB -