Submission #797343

#TimeUsernameProblemLanguageResultExecution timeMemory
797343JohannL-triominoes (CEOI21_ltriominoes)C++14
10 / 100
8048 ms524288 KiB
#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() int W, H, K; map<int, int> blocked; vb dp[2]; void dfs(int idx, int base, int next, vb &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); } } 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); } dp[0] = vb(1 << W, false); dp[0][0] = true; for (int i = 0; i < H; ++i) { int ii = i & 1; int ni = ii ^ 1; dp[ni] = vb(1 << W, false); for (int j = 0; j < sz(dp[ii]); ++j) { if (!dp[ii][j]) continue; if (j & blocked[i]) continue; dfs(0, j | blocked[i], 0, dp[ni]); } } if (dp[H & 1][0]) cout << "YES\n"; else cout << "NO\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...