Submission #173573

# Submission time Handle Problem Language Result Execution time Memory
173573 2020-01-04T16:20:57 Z tourist Bank (IZhO14_bank) C++14
0 / 100
1000 ms 888 KB
#include <iostream>
#include <vector>

using namespace std;

#define ll long long
#define sz(x) (int)x.size()
#define pii pair < int, int >
#define endl "\n"
#define METH ios::sync_with_stdio(0); cin.tie(0);
#define BEGIN cout << "BEGIN" << endl;
#define END cout << "END" << endl;

const int mod = 1e9 + 7;															/// ANOTHER HASH MOD: 228228227
const int prime = 29;																	/// ANOTHER HASH PRIME: 997
const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8);

int n, m;
vector < int > done;
vector < int > a, b;
vector < vector < int > > dp;

inline void read() {
	scanf("%d %d", &n, &m);
	a.resize(n);
	b.resize(m);
	done.resize(2000);
	for (int i = 0; i < n; i++) {
		vector < int > temp(1 << m, 0);
		dp.push_back(temp);
	}
	for (auto i : dp) {
		for (auto j : i) {
			cout << j;
		}
		cout << endl;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		done[a[i]]++;
	}
	for (int i = 0; i < m; i++) {
		scanf("%d", &b[i]);
	}
}

void calc(int used, int cur, ll sum) {
	if (dp[cur][used]) {
		cout << "AH SHIT HERE WE GO AGAIN" << endl;
		return;
	}
	if (cur == n) {
		cout << "YES" << endl;
		exit(0);
	}
	if (sum == a[cur]) {
		calc(used, cur + 1, 0);
		return;
	}
	if (used == (1 << m) - 1) {
		return;
	}
	for (int i = 0; i < m; i++) {
		if (used >> i & 1) {
			continue;
		}
		calc(used | (1 << i), cur, sum + (ll)b[i]);
	}
}

inline int solve() {
	calc(0, 0, 0);
	cout << "NO" << endl;
}

int main() {
	int t = 1;
	while (t--) {
		read();
		solve();
	}
}

Compilation message

bank.cpp: In function 'int solve()':
bank.cpp:74:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
bank.cpp: In function 'void read()':
bank.cpp:24: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:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   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]
   scanf("%d", &b[i]);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -