Submission #48573

# Submission time Handle Problem Language Result Execution time Memory
48573 2018-05-16T17:01:03 Z rkocharyan Bank (IZhO14_bank) C++14
71 / 100
315 ms 235652 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <bitset>
#include <iomanip>
#include <memory>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <climits>
#include <cassert>
using namespace std;

#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define mp make_pair
#define add push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mem(a,b) memset(a, b, sizeof(a))
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:20000007")
#pragma GCC optimize("unroll-loops")

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef vector <int> lnum;

const int N = (int)1e7 + 100;
const int maxn = (int)1e3 + 100;
const int base = (int)1e9;
const int mod = (int)1e9 + 7;
const int inf = INT_MAX;
const long long ll_inf = LLONG_MAX;
const long double PI = acos((long double)-1.0);
const long double eps = 1e-8;

int n, m;
vector <int> A, M;

bitset <36> B[N];
vector <int> can[N];

void rec(int step, int msk) {
	if (step == n) {
		cout << "YES\n";
		exit(false);
	}
	else {
		if (B[step][msk]) return;
		B[step][msk] = true;
		for (int i : can[step]) {
			if (!(i & msk)) rec(step + 1, i ^ msk);
		}
	}
}

void solve() {
	cin >> n >> m;
	A.resize(n), M.resize(m);
	for (int i = 0; i < n; ++i) cin >> A[i];
	for (int i = 0; i < m; ++i) cin >> M[i];
	for (int msk = 0; msk < (1 << m); ++msk) {
		int cur = 0;
		for (int i = 0; i < m; ++i) if (1 & (msk >> i)) cur += M[i];
		for (int i = 0; i < n; ++i) if (A[i] == cur) can[i].add(msk);
	}
	rec(0, 0);
	cout << "NO\n";
}

int main() {
	//ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

	//#define Freopen
#ifdef Freopen
#ifndef _MSC_VER 
#define TASK ""
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);
#endif
#endif

	int T = 1;
	//scanf("%d", &T);

	for (; T; --T) solve();

#ifdef DEBUG
	cerr << double(1.0 * clock() / CLOCKS_PER_SEC) << '\n';
#endif 

	return 0;
}

Compilation message

bank.cpp:31:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 
bank.cpp:32:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:20000007")
# Verdict Execution time Memory Grader output
1 Correct 182 ms 235100 KB Output is correct
2 Correct 181 ms 235124 KB Output is correct
3 Correct 178 ms 235272 KB Output is correct
4 Correct 180 ms 235364 KB Output is correct
5 Correct 238 ms 235364 KB Output is correct
6 Correct 179 ms 235364 KB Output is correct
7 Correct 177 ms 235364 KB Output is correct
8 Correct 252 ms 235540 KB Output is correct
9 Correct 315 ms 235540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 179 ms 235540 KB Output is correct
2 Correct 176 ms 235540 KB Output is correct
3 Correct 181 ms 235540 KB Output is correct
4 Correct 210 ms 235540 KB Output is correct
5 Correct 184 ms 235584 KB Output is correct
6 Correct 183 ms 235584 KB Output is correct
7 Correct 180 ms 235584 KB Output is correct
8 Correct 182 ms 235584 KB Output is correct
9 Correct 180 ms 235584 KB Output is correct
10 Correct 178 ms 235584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 207 ms 235584 KB Output is correct
2 Correct 213 ms 235584 KB Output is correct
3 Correct 208 ms 235584 KB Output is correct
4 Correct 207 ms 235584 KB Output is correct
5 Correct 210 ms 235584 KB Output is correct
6 Correct 216 ms 235584 KB Output is correct
7 Correct 210 ms 235584 KB Output is correct
8 Correct 181 ms 235584 KB Output is correct
9 Correct 211 ms 235584 KB Output is correct
10 Correct 230 ms 235584 KB Output is correct
11 Correct 215 ms 235584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 182 ms 235100 KB Output is correct
2 Correct 181 ms 235124 KB Output is correct
3 Correct 178 ms 235272 KB Output is correct
4 Correct 180 ms 235364 KB Output is correct
5 Correct 238 ms 235364 KB Output is correct
6 Correct 179 ms 235364 KB Output is correct
7 Correct 177 ms 235364 KB Output is correct
8 Correct 252 ms 235540 KB Output is correct
9 Correct 315 ms 235540 KB Output is correct
10 Correct 179 ms 235540 KB Output is correct
11 Correct 176 ms 235540 KB Output is correct
12 Correct 181 ms 235540 KB Output is correct
13 Correct 210 ms 235540 KB Output is correct
14 Correct 184 ms 235584 KB Output is correct
15 Correct 183 ms 235584 KB Output is correct
16 Correct 180 ms 235584 KB Output is correct
17 Correct 182 ms 235584 KB Output is correct
18 Correct 180 ms 235584 KB Output is correct
19 Correct 178 ms 235584 KB Output is correct
20 Correct 207 ms 235584 KB Output is correct
21 Correct 213 ms 235584 KB Output is correct
22 Correct 208 ms 235584 KB Output is correct
23 Correct 207 ms 235584 KB Output is correct
24 Correct 210 ms 235584 KB Output is correct
25 Correct 216 ms 235584 KB Output is correct
26 Correct 210 ms 235584 KB Output is correct
27 Correct 181 ms 235584 KB Output is correct
28 Correct 211 ms 235584 KB Output is correct
29 Correct 230 ms 235584 KB Output is correct
30 Correct 215 ms 235584 KB Output is correct
31 Correct 270 ms 235584 KB Output is correct
32 Correct 247 ms 235652 KB Output is correct
33 Correct 243 ms 235652 KB Output is correct
34 Incorrect 244 ms 235652 KB Output isn't correct
35 Halted 0 ms 0 KB -