제출 #1175366

#제출 시각아이디문제언어결과실행 시간메모리
1175366Hisu은행 (IZhO14_bank)C++20
100 / 100
970 ms70456 KiB
// Chaiyo... #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; #define ed "\n" //#define int long long const int N = 2e6 + 5; int n, m, a[N], b[N]; vector<int> st[N]; struct chash { const uint64_t C = ll(4e18*acos(0))+71; // large odd number const int RANDOM = rand(); ll operator()(ll x) const { return __builtin_bswap64((x^RANDOM)*C); } }; template<class K,class V> using ht = gp_hash_table<K,V,chash>; template<class K,class V> V get(ht<K,V>& u, K x) { auto it = u.find(x); return it == end(u) ? 0 : it->s; } void solve(int iTest){ cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= m; i++) cin >> b[i]; for(int mask = 1; mask < (1 << m); mask++) { int sum = 0; for(int i = 0; i < m; i++) if(mask >> i & 1) sum += b[i + 1]; st[sum].push_back(mask); } gp_hash_table<int, bool> dp; dp[0] = true; for(int i = 1; i <= n; i++) { gp_hash_table<int, bool> new_dp; for(int val : st[a[i]]) { for(auto [mask, x] : dp) if((mask & val) == 0) new_dp[mask ^ val] = true; } dp.swap(new_dp); if(dp.size() == 0) break; } if(dp.size()) cout << "YES"; else cout << "NO"; } #define TASK "main" signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if(fopen(TASK ".inp","r")){ freopen(TASK ".inp","r",stdin); freopen(TASK ".out","w",stdout); } else if(fopen("main.inp","r")){ freopen("main.inp","r",stdin); freopen("main.out","w",stdout); } int T = 1; // cin >> T; for(int iTest = 1; iTest <= T; iTest++){ solve(iTest); } } /** **/

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen(TASK ".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen(TASK ".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |         freopen("main.inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen("main.out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...