Submission #837465

#TimeUsernameProblemLanguageResultExecution timeMemory
837465upedBank (IZhO14_bank)C++14
0 / 100
1 ms596 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; vector<ll> sieve(ll n) { vector<bool> is_prime(n + 1, true); is_prime[0] = is_prime[1] = false; for (ll i = 2; i <= n; i++) { if (is_prime[i] && (long long) i * i <= n) { for (ll j = i * i; j <= n; j += i) is_prime[j] = false; } } vector<ll> primes; for (ll i = 2; i <= n; ++i) { if (is_prime[i]) { primes.push_back(i); } } return primes; } void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } void fileio(const string &name) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } int main() { int n, m; cin >> n >> m; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<int> b(m); for (int i = 0; i < m; ++i) { cin >> b[i]; } vector<vector<uint32_t>> masks(1001); vector<int> dp1(1 << m); for (uint32_t i = 1; i < (1 << m); ++i) { for (int j = 0; j < m; ++j) { if (i & (1 << j)) { dp1[i] = dp1[i ^ (1 << j)] + b[j]; masks[dp1[i]].push_back(i); break; } } } // for (int i = 0; i < 20; ++i) { // cout << i << ": "; // for (int j = 0; j < masks[i].size(); ++j) { // cout << bitset<10>(masks[i][j]) << ' '; // } // cout << '\n'; // } vector<bool> dp2(1 << m, true); for (int i = 0; i < n; ++i) { auto& vm = masks[a[i]]; for (int k = 0; k < (1 << m); ++k) { if (!dp2[k]) continue; bool match = false; for (int j = 0; j < vm.size(); ++j) { if ((k ^ vm[j]) == 0) { match = true; } } dp2[k] = match; } } for (int i = 0; i < 50; ++i) { cout << bitset<10>(i) << ' ' << dp2[i] << '\n'; } for (int i = 0; i < (1 << m); ++i) { if (dp2[i]) { cout << "YES"; return 0; } } cout << "NO"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:49:28: warning: comparison of integer expressions of different signedness: 'uint32_t' {aka 'unsigned int'} and 'int' [-Wsign-compare]
   49 |     for (uint32_t i = 1; i < (1 << m); ++i) {
      |                          ~~^~~~~~~~~~
bank.cpp:73:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<unsigned int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |             for (int j = 0; j < vm.size(); ++j) {
      |                             ~~^~~~~~~~~~~
bank.cpp: In function 'void fileio(const string&)':
bank.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     freopen((name + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((name + ".out").c_str(), "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...