제출 #1117610

#제출 시각아이디문제언어결과실행 시간메모리
1117610NguyenPhucThang은행 (IZhO14_bank)C++14
0 / 100
1080 ms5588 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef vector<pair<int, int>> vii; typedef pair<int, pair<int, int>> piii; #define forr(i, a, b) for (int i = (a); i <= (b); i++) #define ford(i, a, b) for (int i = (a); i >= (b); i--) #define forf(i, a, b) for (int i = (a); i < (b); i++) #define fi first #define se second #define pb push_back #define all(v) v.begin(), v.end() #define mask(i) (1LL << (i)) #define bit(x, i) (((x) >> (i)) & 1) #define bp __builtin_popcountll #define file "test" template<class X, class Y> bool minz(X &x, const Y &y) { if (x > y) { x = y; return true; } return false; } template<class X, class Y> bool maxz(X &x, const Y &y) { if (x < y) { x = y; return true; } return false; } const int base = 31; const ll mod = 1e9 + 7; // 998244353; const ll oo = (ll) 1e16; const int N = 2e5 + 5; vi mask_list[N]; bool dp[25][(1 << 20)]; int a[N], b[N]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifndef ONLINE_JUDGE freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); #endif // ONLINE_JUDGE int n, m; cin >> n >> m; forr(i, 1, n) cin >> a[i]; forr(i, 1, m) cin >> b[i]; forr(mask, 0, (1 << m) - 1) { int sum = 0; forr(i, 1, m) if (bit(mask, i - 1)) sum += b[i]; mask_list[sum].pb(mask); } dp[0][0] = true; forr(i, 1, n) { forr(mask, 0, (1 << m) - 1) { for(int mask2 : mask_list[a[i]]) { if ((mask | mask2) == mask) dp[i][mask] |= dp[i - 1][mask ^ mask2]; } } } bool res = false; forr(mask, 0, (1 << m) - 1) res |= dp[n][mask]; cout << (res ? "YES" : "NO"); return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:52:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |     freopen("test.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:53:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |     freopen("test.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...