제출 #393329

#제출 시각아이디문제언어결과실행 시간메모리
393329asbsfds은행 (IZhO14_bank)C++14
100 / 100
642 ms62020 KiB
#include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long llint; const int maxn = 30; const int base = 31337; const int mod = 1e9+7; const int inf = 0x3f3f3f3f; const int logo = 20; const int off = 1 << logo; const int treesiz = off << 1; int n, m; int a[maxn], b[maxn]; bool dp[maxn][treesiz]; vector< int > v[maxn]; bool solve(int x, int mask) { if (x == n) return true; if (dp[x][mask]) return false; dp[x][mask] = true; bool out = false; for (int i = 0; i < v[x].size(); i++) { int tmask = v[x][i]; if ((mask & tmask) == 0) { int nmask = mask | tmask; out |= solve(x + 1, nmask); } } return out; } int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", a+i); for (int i = 0; i < m; i++) scanf("%d", b+i); int lim = (1 << m); for (int mask = 0; mask < lim; mask++) { int sum = 0; for (int i = 0; i < m; i++) { if (mask & (1 << i)) sum += b[i]; } for (int i = 0; i < n; i++) { if (sum == a[i]) v[i].push_back(mask); } } memset(dp, false, sizeof dp); if (solve(0, 0)) printf("YES\n"); else printf("NO\n"); return 0; }

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

bank.cpp: In function 'bool solve(int, int)':
bank.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for (int i = 0; i < v[x].size(); i++) {
      |                  ~~^~~~~~~~~~~~~
bank.cpp: In function 'int main()':
bank.cpp:38:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   38 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
bank.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |   scanf("%d", a+i);
      |   ~~~~~^~~~~~~~~~~
bank.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |   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...