# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
671749 |
2022-12-13T16:28:31 Z |
smartmonky |
Bank (IZhO14_bank) |
C++14 |
|
21 ms |
2732 KB |
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
const int N = 1e5;
vector <int> g[N];
int n, vis[25][N];
void rec(int pos, int v){
if(pos == n + 1){
cout <<"YES";
exit(0);
}
vis[pos][v] = 1;
for(auto to : g[pos]){
if((v & to) == 0 && !vis[pos + 1][(v ^ to)])
rec(pos + 1, (v ^ to));
}
}
main(){
int m;
cin >> n >> m;
vector <int> v(n + 1), a(m + 1);
for(int i = 1; i <= n; i++){
cin >> v[i];
}
for(int i = 1; i <= m; i++){
cin >> a[i];
}
for(int i = 1; i < (1 << m); i++){
int sum = 0;
for(int j = 0; j < m; j++)
if(i & (1 << j)){
sum += a[j + 1];
}
cout << sum << endl;
for(int j = 1; j <= n; j++){
if(v[j] == sum)g[j].pb(i);
}
}
rec(1, 0);
cout << "NO";
}
Compilation message
bank.cpp:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
24 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
2732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |