# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
68463 |
2018-08-17T07:33:03 Z |
ekrem |
Bank (IZhO14_bank) |
C++ |
|
313 ms |
129916 KB |
#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
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 time |
Memory |
Grader output |
1 |
Correct |
88 ms |
129400 KB |
Output is correct |
2 |
Correct |
88 ms |
129524 KB |
Output is correct |
3 |
Correct |
89 ms |
129728 KB |
Output is correct |
4 |
Correct |
98 ms |
129728 KB |
Output is correct |
5 |
Correct |
107 ms |
129728 KB |
Output is correct |
6 |
Correct |
138 ms |
129728 KB |
Output is correct |
7 |
Correct |
101 ms |
129744 KB |
Output is correct |
8 |
Correct |
107 ms |
129888 KB |
Output is correct |
9 |
Correct |
109 ms |
129888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
129888 KB |
Output is correct |
2 |
Correct |
103 ms |
129888 KB |
Output is correct |
3 |
Correct |
103 ms |
129888 KB |
Output is correct |
4 |
Correct |
103 ms |
129888 KB |
Output is correct |
5 |
Correct |
102 ms |
129888 KB |
Output is correct |
6 |
Correct |
104 ms |
129888 KB |
Output is correct |
7 |
Correct |
101 ms |
129888 KB |
Output is correct |
8 |
Correct |
102 ms |
129888 KB |
Output is correct |
9 |
Correct |
102 ms |
129888 KB |
Output is correct |
10 |
Correct |
104 ms |
129888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
129888 KB |
Output is correct |
2 |
Correct |
89 ms |
129888 KB |
Output is correct |
3 |
Correct |
92 ms |
129888 KB |
Output is correct |
4 |
Correct |
90 ms |
129888 KB |
Output is correct |
5 |
Correct |
89 ms |
129888 KB |
Output is correct |
6 |
Correct |
88 ms |
129888 KB |
Output is correct |
7 |
Correct |
89 ms |
129888 KB |
Output is correct |
8 |
Correct |
87 ms |
129888 KB |
Output is correct |
9 |
Correct |
88 ms |
129888 KB |
Output is correct |
10 |
Correct |
89 ms |
129888 KB |
Output is correct |
11 |
Correct |
105 ms |
129888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
129400 KB |
Output is correct |
2 |
Correct |
88 ms |
129524 KB |
Output is correct |
3 |
Correct |
89 ms |
129728 KB |
Output is correct |
4 |
Correct |
98 ms |
129728 KB |
Output is correct |
5 |
Correct |
107 ms |
129728 KB |
Output is correct |
6 |
Correct |
138 ms |
129728 KB |
Output is correct |
7 |
Correct |
101 ms |
129744 KB |
Output is correct |
8 |
Correct |
107 ms |
129888 KB |
Output is correct |
9 |
Correct |
109 ms |
129888 KB |
Output is correct |
10 |
Correct |
104 ms |
129888 KB |
Output is correct |
11 |
Correct |
103 ms |
129888 KB |
Output is correct |
12 |
Correct |
103 ms |
129888 KB |
Output is correct |
13 |
Correct |
103 ms |
129888 KB |
Output is correct |
14 |
Correct |
102 ms |
129888 KB |
Output is correct |
15 |
Correct |
104 ms |
129888 KB |
Output is correct |
16 |
Correct |
101 ms |
129888 KB |
Output is correct |
17 |
Correct |
102 ms |
129888 KB |
Output is correct |
18 |
Correct |
102 ms |
129888 KB |
Output is correct |
19 |
Correct |
104 ms |
129888 KB |
Output is correct |
20 |
Correct |
96 ms |
129888 KB |
Output is correct |
21 |
Correct |
89 ms |
129888 KB |
Output is correct |
22 |
Correct |
92 ms |
129888 KB |
Output is correct |
23 |
Correct |
90 ms |
129888 KB |
Output is correct |
24 |
Correct |
89 ms |
129888 KB |
Output is correct |
25 |
Correct |
88 ms |
129888 KB |
Output is correct |
26 |
Correct |
89 ms |
129888 KB |
Output is correct |
27 |
Correct |
87 ms |
129888 KB |
Output is correct |
28 |
Correct |
88 ms |
129888 KB |
Output is correct |
29 |
Correct |
89 ms |
129888 KB |
Output is correct |
30 |
Correct |
105 ms |
129888 KB |
Output is correct |
31 |
Correct |
102 ms |
129888 KB |
Output is correct |
32 |
Correct |
118 ms |
129888 KB |
Output is correct |
33 |
Correct |
130 ms |
129888 KB |
Output is correct |
34 |
Correct |
142 ms |
129888 KB |
Output is correct |
35 |
Correct |
146 ms |
129888 KB |
Output is correct |
36 |
Correct |
194 ms |
129888 KB |
Output is correct |
37 |
Correct |
99 ms |
129888 KB |
Output is correct |
38 |
Correct |
110 ms |
129888 KB |
Output is correct |
39 |
Correct |
134 ms |
129888 KB |
Output is correct |
40 |
Correct |
155 ms |
129888 KB |
Output is correct |
41 |
Correct |
212 ms |
129888 KB |
Output is correct |
42 |
Correct |
132 ms |
129888 KB |
Output is correct |
43 |
Correct |
146 ms |
129888 KB |
Output is correct |
44 |
Correct |
182 ms |
129888 KB |
Output is correct |
45 |
Correct |
118 ms |
129888 KB |
Output is correct |
46 |
Correct |
135 ms |
129888 KB |
Output is correct |
47 |
Correct |
182 ms |
129888 KB |
Output is correct |
48 |
Correct |
106 ms |
129888 KB |
Output is correct |
49 |
Correct |
108 ms |
129888 KB |
Output is correct |
50 |
Correct |
210 ms |
129888 KB |
Output is correct |
51 |
Correct |
141 ms |
129888 KB |
Output is correct |
52 |
Correct |
141 ms |
129888 KB |
Output is correct |
53 |
Correct |
157 ms |
129916 KB |
Output is correct |
54 |
Correct |
194 ms |
129916 KB |
Output is correct |
55 |
Correct |
194 ms |
129916 KB |
Output is correct |
56 |
Correct |
195 ms |
129916 KB |
Output is correct |
57 |
Correct |
313 ms |
129916 KB |
Output is correct |
58 |
Correct |
190 ms |
129916 KB |
Output is correct |