Submission #885758

#TimeUsernameProblemLanguageResultExecution timeMemory
885758degiakhanhBank (IZhO14_bank)C++17
27 / 100
754 ms262144 KiB
/* _ _ _ _ _ _ | | / | | | | | | (_) | |/ /| |__ __ _ _ __ | |__ __| | ___ _ __ ______ _ _ | ( | '_ \ / _` | '_ \| '_ \ / _` |/ _ \ '_ \ |_ / _` | | | |\ \| | \ | (_| | | | | | \ | | (_| | __/ |_) | / / (_| | | |_| \_|_| |_|\__,_|_| |_|_| |_| \__,_|\___| .__/ /___\__,_|_| | | |_| */ #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define all(v) v.begin(), v.end() #define test() \ int _t; \ cin >> _t; \ while (_t--) #define testig() \ int _t; \ cin >> _t; \ cin.ignore(); \ while (_t--) #define binarys(l, r, lv, rv, mid) for (int l = lv, r = rv, mid = (l + r) >> 1; l <= r; mid = (l + r) >> 1) #define fi first #define se second #define clz(n) 31 - __builtin_clz(n) #define vec2d(n, m) vector<vector<int>>(n + 1, vector<int>(m + 1, 0)) template <class T, class P> bool maximize(T &a, P b) { if (a < b) return a = b, true; return false; } template <class T, class P> bool minimize(T &a, P b) { if (a > b) return a = b, true; return false; } const ll inf = 0x3f3f3f3f3f3f3f3f; const int iinf = 0x3f3f3f3f; const int maxn = 1e5 + 69; const int mod = 998244353; const int base = 311; int n, m; int A[21], B[21], id[1001]; set<int> a[1001], b; ll bit = 0; bool res = false; string rs[] = {"NO", "YES"}; void bt(int p = 1){ if(res) return; for(int i: a[A[p]]){ if(bit & i) continue; bit ^= i; if(p == n) res = true; else bt(p + 1); if(res) return; bit ^= i; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("main.inp", "r")) { freopen("main.inp", "r", stdin); freopen("main.out", "w", stdout); } cin >> n >> m; for(int i = 1; i <= n; i++) cin >> A[i]; a[0].insert(0); b.insert(0); vector<int> c; for(int i = 0; i < m; i++){ cin >> B[i]; for(int j: b){ if(j + B[i] > 1000) continue; c.pub(j + B[i]); for(int v: a[j]) a[j + B[i]].insert(v | (1 << i)); } while(c.size()){ b.insert(c.back()); c.pob(); } } bt(); cout << rs[res]; return 0; }

Compilation message (stderr)

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