Submission #650124

#TimeUsernameProblemLanguageResultExecution timeMemory
6501241binL-triominoes (CEOI21_ltriominoes)C++14
100 / 100
2956 ms2292 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; const int bmx = 1 << 13; int w, h, k, x, y, a[bmx], b[bmx]; vector<int> adj[bmx]; map<int, int> mp; void dfs(int i, int mask, int t){ if(i == w){ adj[mask].emplace_back(t); return; } if(mask & 1 << i) dfs(i + 1, mask, t); else{ if(i && !(t & 1 << (i - 1)) && !(t & 1 << i)) dfs(i + 1, mask, t | 1 << i | 1 << (i - 1)); if(i + 1 < w && !(mask & 1 << (i + 1)) && !(t & 1 << (i + 1))) dfs(i + 2, mask, t | 1 << (i + 1)); if(i + 1 < w && !(t & 1 << i) && !(mask & 1 << (i + 1))) dfs(i + 2, mask, t | 1 << i); if(i + 1 < w && !(t & 1 << i) && !(t & (1 << (i + 1)))) dfs(i + 1, mask, t | 1 << i | 1 << (i + 1)); } return; } int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> w >> h >> k; for(int mask = 0; mask < 1 << w; mask++) dfs(0, mask, 0); mp[1] = mp[h] = 0; for(int i = 0; i < k; i++){ cin >> x >> y; x--; mp[y] |= 1 << x; } a[0] = 1; for(auto it = mp.begin();;){ auto&[y, t] = *it; for(int i = 0; i < 1 << w; i++) if(!(i & t)) b[i | t] |= a[i]; swap(a, b); memset(b, 0, sizeof(b)); if(++it == mp.end()) break; int u = it->first - y; if(u >= 12) u -= (u - 12) / 6 * 6; while(u--){ for(int i = 0; i < 1 << w; i++) for(auto&j : adj[i]) b[j] |= a[i]; swap(a, b); memset(b, 0, sizeof(b)); } } cout << (a[(1 << w) - 1] ? "YES" : "NO"); return 0; }

Compilation message (stderr)

ltrominoes.cpp: In function 'int main()':
ltrominoes.cpp:39:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   39 |         auto&[y, t] = *it;
      |              ^
#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...