제출 #165769

#제출 시각아이디문제언어결과실행 시간메모리
165769MercenaryBank (IZhO14_bank)C++14
100 / 100
252 ms14588 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "A" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 2e5 + 5; const int logn = log2(maxn) + 1; const int mod = 1e9 + 7; int n , m; int a[maxn] , b[maxn]; vector<int> can[21]; bool dp[21][1 << 20]; void dfs(int u , int mask){ if(u == n){ cout << "YES"; exit(0); } if(dp[u][mask])return; dp[u][mask] = 1; for(int c : can[u + 1]){ if(!(c & mask))dfs(u + 1 , mask | c); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } srand(time(0)); cin >> n >> m; for(int i = 1 ; i <= n ; ++i){ cin >> a[i]; } for(int i = 0 ; i < m ; ++i){ cin >> b[i]; } for(int i = 1 ; i < (1 << m) ; ++i){ int s = 0; for(int j = 0 ; j < m ; ++j){ if(i & (1 << j))s += b[j]; } for(int j = 1 ; j <= n ; ++j){ if(a[j] == s)can[j].pb(i); } } dfs(0,0); cout << "NO"; }

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

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