제출 #80905

#제출 시각아이디문제언어결과실행 시간메모리
80905farukkastamonuda은행 (IZhO14_bank)C++14
52 / 100
1080 ms44228 KiB
#include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000000 #define md 1000000007 #define li 2005 #define mpt make_pair #define pb push_back using namespace std; int n, m, A[22], B[22]; unordered_map <int, int> mp[1005]; vector<int> v[22]; bool dp[22][(1 << 20) + 5]; void dfs(int sayi, int msk, int ind){ if(mp[sayi][msk] == 1) return ; if(sayi == 0){ v[ind].pb(msk); mp[sayi][msk] = 1; return ; } mp[sayi][msk] = 1; int flag = 0; for(int i = 1;i <= m; i++){ if(!(msk&(1 << (i - 1)))){ if(sayi >= B[i]){ flag = 1; dfs(sayi - B[i], msk | (1 << (i - 1)), ind); } } } if(flag == 0) return ; } void solve(int node, int msk){ if(node == n + 1){ printf("YES\n"); exit(0); } if(dp[node][msk] == true) return ; dp[node][msk]=true; for(int i = 0; i < (int)v[node].size(); i ++){ if(! (msk & v[node][i]) ) solve(node + 1, msk | v[node][i]); } } int main(){ 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(A[i], 0, i); for(int j = 0; j <= 1000 ; j ++) mp[j].clear(); } solve(1, 0); printf("NO\n"); return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:46: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:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[i]);
   ~~~~~^~~~~~~~~~~~~
bank.cpp:51: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...