Submission #1012012

#TimeUsernameProblemLanguageResultExecution timeMemory
1012012if_test_ACBank (IZhO14_bank)C++14
100 / 100
82 ms16980 KiB
//author : TCT #include <bits/stdc++.h> using namespace std; #define all(a) (a).begin(), (a).end() #define st first #define se second typedef long long ll; typedef pair<ll, ll> ii; #define int long long const int INF = 1e9; const ll LINF = 1e18; const int dx[4] = {0, 0, -1, 1}; const int dy[4] = {-1, 1, 0 ,0}; const int N = 20; int n, m; int a[N + 4], b[N + 4]; ii dp[(1 << N) + 4]; signed main() { ios::sync_with_stdio(0); cin.tie(0); // freopen("", "r", stdin); // freopen("", "w", stdout); cin >> n >> m; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < m; i++) cin >> b[i]; memset(dp, -1, sizeof dp); dp[0] = ii(0, 0); for(int mark = 1; mark < (1 << m); mark++) { for(int i = 0; i < m; i++) { if(!(mark & (1 << i))) continue; ii val = dp[mark ^ (1 << i)]; if(val.st == -1) continue; if(val.se + b[i] < a[val.st]) dp[mark] = ii(val.st, val.se + b[i]); else if(val.se + b[i] == a[val.st]) dp[mark] = ii(val.st + 1, 0); } if(dp[mark].st == n) { cout << "YES" << '\n'; return 0; } } cout << "NO" << '\n'; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:33:26: warning: 'void* memset(void*, int, size_t)' writing to an object of type 'ii' {aka 'struct std::pair<long long int, long long int>'} with no trivial copy-assignment [-Wclass-memaccess]
   33 |  memset(dp, -1, sizeof dp);
      |                          ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from bank.cpp:2:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'ii' {aka 'struct std::pair<long long int, long long int>'} declared here
  211 |     struct pair
      |            ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...