Submission #604477

#TimeUsernameProblemLanguageResultExecution timeMemory
604477tutisL-triominoes (CEOI21_ltriominoes)C++17
0 / 100
8095 ms524288 KiB
/*input 2 3 0 */ #pragma GCC optimize ("O3") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; using ll = long long; using ull = unsigned long long; using ld = long double; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int W, H, K; cin >> W >> H >> K; map<int, int>A; while (K--) { int x, y; cin >> x >> y; if (A.count(y) == 0) A[y] = 0; A[y] |= 1 << (x - 1); } bitset < 1 << 13 > gal; gal[(1 << W) - 1] = true; for (int i = 1; i <= H; i++) { bitset < 1 << 13 > gal_; function<void(int, int, int)>dfs = [&](int i, int m1, int m2) { if (i == W - 1) { if (m1 == (1 << W) - 1) gal_[m2] = true; return; } for (int da : {0, 1}) { for (int db : {0, 1}) { int m[2] = {m1, m2}; bool ok = true; for (int dx : {0, 1}) { for (int dy : {0, 1}) { if (dx == da && dy == db) continue; if ((m[dx] & (1 << (i + dy))) != 0) ok = false; m[dx] |= 1 << (i + dy); } } if (ok) dfs(i + 1, m[0], m[1]); } } dfs(i + 1, m1, m2); }; for (int msk = 0; msk < (1 << W); msk++) if (gal[msk]) dfs(0, msk, A[i]); gal = gal_; } if (gal[(1 << W) - 1]) cout << "YES\n"; else cout << "NO\n"; }
#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...