Submission #362331

#TimeUsernameProblemLanguageResultExecution timeMemory
362331codebuster_10Bank (IZhO14_bank)C++17
0 / 100
527 ms262148 KiB
#include <bits/stdc++.h> using namespace std ; #define i64 int64_t // typecast using i64(x) #define int int64_t #define ld long double #define f(i,a,b) for(int i=a; i<b; ++i) #define endl '\n' #define PQ priority_queue #define LB lower_bound #define UB upper_bound #define fr first #define sc second #define all(a) (a).begin(),(a).end() #define allr(a) (a).rbegin(),(a).rend() #define sz(x) ((int)(x).size()) //#ifndef ONLINE_JUDGE template<typename T> void __p(T a) { cout<<a; } template<typename T, typename F> void __p(pair<T, F> a) { cout<<"{"; __p(a.first); cout<<","; __p(a.second); cout<<"}\n"; } template<typename T> void __p(std::vector<T> a) { cout<<"{"; for(auto it=a.begin(); it<a.end(); it++) __p(*it),cout<<",}\n"[it+1==a.end()]; } template<typename T, typename ...Arg> void __p(T a1, Arg ...a) { __p(a1); __p(a...); } template<typename Arg1> void __f(const char *name, Arg1 &&arg1) { cout<<name<<" : "; __p(arg1); cout<<endl; } template<typename Arg1, typename ... Args> void __f(const char *names, Arg1 &&arg1, Args &&... args) { int bracket=0,i=0; for(;; i++) if(names[i]==','&&bracket==0) break; else if(names[i]=='(') bracket++; else if(names[i]==')') bracket--; const char *comma=names+i; cout.write(names,comma-names)<<" : "; __p(arg1); cout<<" | "; __f(comma+1,args...); } //#endif void setIO(string s = "") { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin.exceptions(cin.failbit); if(sz(s)){ freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } } signed main(){ setIO() ; int N, M ; cin >> N >> M ; vector<int> a(N), b(M) ; f(i,0,N) cin >> a[i] ; sort(all(a)) ; f(i,0,M) cin >> b[i] ; vector<vector<int> > dp[1<<M] ; dp[0].push_back({0}) ; for(int mask = 1 ; mask < (1<<M) ; mask++){ int n = __builtin_popcount(mask) ; vector<int> bit ; f(i,0,M){ if(mask & (1<<i)) bit.push_back(i) ; } assert(sz(bit) == n) ; for(int submask = 1 ; submask < (1<<n) ; submask++){ int res = mask , sum = 0 ; f(i,0,n){ if(submask & (1<<i)){ res ^= (1<<bit[i]) ; sum += b[bit[i]] ; } } for(auto v:dp[res]){ dp[mask].push_back(v) ; (dp[mask].back()).push_back(sum) ; } } for(auto v:dp[mask]){ sort(all(v)) ; int cur = 0 ; f(i,0,sz(v)){ if(v[i] == a[cur]){ cur++; if(cur == N){ cout << "YES" ; exit(0) ; } } } } } cout << "NO" ; exit(0) ; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:8:18: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    8 | #define f(i,a,b) for(int i=a; i<b; ++i)
      |                  ^~~
bank.cpp:81:3: note: in expansion of macro 'f'
   81 |   f(i,0,N) cin >> a[i] ; sort(all(a)) ;
      |   ^
bank.cpp:81:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   81 |   f(i,0,N) cin >> a[i] ; sort(all(a)) ;
      |                          ^~~~
bank.cpp: In function 'void setIO(std::string)':
bank.cpp:73:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   73 |     freopen((s+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:74:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   74 |     freopen((s+".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...