제출 #1282497

#제출 시각아이디문제언어결과실행 시간메모리
1282497abyfu은행 (IZhO14_bank)C++20
71 / 100
1096 ms2624 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; if (n > m){ cout << "NO"; return; } 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++){ int u = (k >> o) & 1, v = (j >> o) & 1; if (u == 1 && u != v){ ax = 0; break; } } if (ax){ dp[i][j] = max(dp[i][j], dp[i - 1][(j xor k)]); if (dp[i][j] == 1) break; } } 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(); }

컴파일 시 표준 에러 (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...