Submission #1282492

#TimeUsernameProblemLanguageResultExecution timeMemory
1282492abyfuBank (IZhO14_bank)C++20
46 / 100
116 ms2612 KiB
//OwO #pragma GCC optimize("O3", "unroll-loops") #include <bits/stdc++.h> #define ll long long #define ld long double #define namein "input.txt" #define nameout "output.txt" #define pque priority_queue #define all(x) x.begin(),x.end() #define fi first #define se second #define pb push_back #define m_pi acos(-1) using namespace std; const ll inf = 1e18; const int linf = 1.5e9; void file(){ if (fopen(namein, "r")){ freopen(namein, "r", stdin); freopen(nameout, "w", stdout); } } const ll mod = 1e9 + 7; const int N = 2e1 + 5, M = 5e5 + 5; bool dp[N][(1 << N)]; int n, m; int a[N], b[N]; vector<int> u[N]; void run(){ cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; int l = (1 << (m + 1)) - 1; for (int i = 0; i <= l; i++) dp[0][i] = 1; for (int i = 1; i <= l; i++){ int v = 0; for (int j = 0; j < m; j++){ if ((i >> j) & 1){ v += b[j]; } } for (int j = 1; j <= n; j++){ if (a[j] == v){ u[j].pb(i); } } } for (int i = 1; i <= n; i++){ for (int j = 1; j <= l; j++){ for (auto k : u[i]){ bool ax = 1; for (int o = 0; o < m; o++){ if ((k >> o) & 1 == 1 && (j >> o) & 1 != (k >> o) & 1){ ax = 0; break; } } if (ax){ if (dp[i - 1][(j ^ k)]) dp[i][j] = 1; if (i == n && dp[i][j]){ cout << "YES"; return; } } } } } cout << "NO"; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //file(); run(); }

Compilation message (stderr)

bank.cpp: In function 'void file()':
bank.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(namein, "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
bank.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen(nameout, "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...