Submission #68463

#TimeUsernameProblemLanguageResultExecution timeMemory
68463ekremBank (IZhO14_bank)C++98
100 / 100
313 ms129916 KiB
#include <bits/stdc++.h> #define st first #define nd second #define mp make_pair #define pb push_back #define N 1100005 using namespace std; int n, m, ans, a[30], b[30], dp[30][N]; vector < int > g[30]; void dfs(int node, int top, int x, int yap){ if(node > m){ if(top == a[yap]) g[yap].pb(x); return; } x *= 2; dfs(node + 1, top + b[node], x + 1, yap); dfs(node + 1, top, x, yap); } bool bul(int node, int bit){ // cout << node << " -> " << bit << endl; int &r = dp[node][bit]; if(r != -1) return r; if(node > n) return r = 1; for(int i = 0; i < g[node].size(); i++) if((bit&g[node][i]) == 0) if(bul(node + 1, (bit|g[node][i]))) return r = 1; return r = 0; } int main(){ // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); memset(dp, -1, sizeof dp); scanf("%d %d",&n ,&m); for(int i = 1; i <= n; i++) scanf("%d",a + i); for(int i = 1; i <= m; i++) scanf("%d",b + i); for(int i = 1; i <= n; i++) dfs(1, 0, 0, i); // for(int i = 1; i <= n; i++,puts("")) // for(int j = 0; j < g[i].size(); j++) // printf("%d ",g[i][j]); if(bul(1, 0)) printf("YES\n"); else printf("NO\n"); return 0; }

Compilation message (stderr)

bank.cpp: In function 'bool bul(int, int)':
bank.cpp:29:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   return r = 1;
          ~~^~~
bank.cpp:30:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < g[node].size(); i++)
                 ~~^~~~~~~~~~~~~~~~
bank.cpp:33:14: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
     return r = 1;
            ~~^~~
bank.cpp:34:11: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  return r = 0;
         ~~^~~
bank.cpp: In function 'int main()':
bank.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n ,&m);
  ~~~~~^~~~~~~~~~~~~~~~
bank.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",a + i);
   ~~~~~^~~~~~~~~~~~
bank.cpp:45:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",b + i);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...