Submission #229240

# Submission time Handle Problem Language Result Execution time Memory
229240 2020-05-03T22:35:52 Z MetB Burza (COCI16_burza) C++14
0 / 160
176 ms 48376 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
 
#define N 1000003
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;

int n, k, ptr;
bitset <1 << 21> d[400];

vector <int> g[N];
vector < pair <int, int> > v[100];

pair <int, int> dfs (int x, int p, int h) {
	if (h == k) {
		if (h) v[++ptr].push_back ({ptr, h - 1});
		return {ptr, ptr};
	}

	int l = 0, r = 0;

	for (int to : g[x]) {
		if (to != p) {
			auto a = dfs (to, x, h + 1);
			if (!l) l = a.first;
			r = a.second;
		}
	}

	if (h && l) v[r].push_back ({l, h - 1});

	return {l, r};
}

int main () {
	cin >> n >> k;

	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back (b);
		g[b].push_back (a);
	}

	if (k * k >= n) {
		cout << "DA";
		return 0;
	}

	dfs (0, -1, 0);

	d[0][0] = 1;
	for (int i = 1; i <= ptr; i++) {
		for (int j = 0; j < (1 << k); j++) {
			for (auto a : v[i]) {
				if (j & (1 << a.second)) {
					d[i][j] = d[i][j] | d[a.first - 1][j ^ (1 << a.second)];
				}
			}
		}
	}

	for (int j = 0; j < (1 << k); j++)
		if (d[ptr][j]) {
			cout << "DA";
			return 0;
		}

	cout << "NE";
}
# Verdict Execution time Memory Grader output
1 Correct 36 ms 24320 KB Output is correct
2 Correct 159 ms 25080 KB Output is correct
3 Correct 18 ms 23808 KB Output is correct
4 Correct 18 ms 23808 KB Output is correct
5 Runtime error 46 ms 48248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 159 ms 24952 KB Output is correct
2 Correct 143 ms 24952 KB Output is correct
3 Correct 18 ms 23808 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Correct 139 ms 24952 KB Output is correct
6 Runtime error 47 ms 48120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Correct 165 ms 25096 KB Output is correct
2 Correct 143 ms 24952 KB Output is correct
3 Correct 18 ms 23808 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Runtime error 49 ms 48120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 48 ms 48376 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 Correct 141 ms 24824 KB Output is correct
2 Correct 172 ms 24944 KB Output is correct
3 Correct 19 ms 23808 KB Output is correct
4 Correct 18 ms 23808 KB Output is correct
5 Runtime error 54 ms 48248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 170 ms 25080 KB Output is correct
2 Correct 151 ms 24824 KB Output is correct
3 Correct 19 ms 23808 KB Output is correct
4 Correct 21 ms 23808 KB Output is correct
5 Runtime error 53 ms 48352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 24952 KB Output is correct
2 Correct 155 ms 24952 KB Output is correct
3 Correct 19 ms 23808 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Incorrect 155 ms 24952 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 49 ms 24312 KB Output is correct
2 Correct 163 ms 25080 KB Output is correct
3 Correct 19 ms 23808 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Runtime error 48 ms 48120 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 24192 KB Output is correct
2 Correct 141 ms 25080 KB Output is correct
3 Correct 19 ms 23808 KB Output is correct
4 Correct 19 ms 23808 KB Output is correct
5 Runtime error 46 ms 48124 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 75 ms 24452 KB Output is correct
2 Correct 176 ms 25208 KB Output is correct
3 Correct 19 ms 23808 KB Output is correct
4 Correct 18 ms 23808 KB Output is correct
5 Incorrect 77 ms 24408 KB Output isn't correct
6 Halted 0 ms 0 KB -