Submission #556712

#TimeUsernameProblemLanguageResultExecution timeMemory
556712lunchboxBitaro’s Party (JOI18_bitaro)C11
Compilation error
0 ms0 KiB
/*
https://oj.uz/problem/view/JOI18_bitaro
Bitaro's Party
*/
#include <bits/stdc++.h>
using namespace std;

using LL = long long;
const int N = 100000, B = 400, Q = 100000;

vector<int> gr[N];
vector<pair<int, int>> pp[N];

void run() {
	int n, m, q;

	scanf("%d%d%d", &n, &m, &q);
	while (m--) {
		int i, j;

		scanf("%d%d", &i, &j), i--, j--;
		gr[j].push_back(i);
	}
	for (int i = 0; i < n; i++) {
		priority_queue<pair<int, int>> pq;

		pq.push({0, i});
		for (int j : gr[i]) {
			for (auto [d, k] : pp[j])
				pq.push({d + 1, k});
			while (pq.size() > B)
				pq.pop();
		}
		while (!pq.empty()) {
			pp[i].push_back(pq.top());
			pq.pop();
		}
	}
	for (int h = 1; h <= q; h++) {
		static int removed[N];
		int i, k, ans = -1;

		scanf("%d%d", &i, &k), i--;
		while (k--) {
			int j;

			scanf("%d", &j), j--;
			removed[j] = h;
		}
		if (k < B) {
			for (auto [d, j] : pp[i])
				if (removed[j] != h) {
					ans = d;
					break;
				}
		} else {
			static int dd[N];
			priority_queue<pair<int, int>> pq;

			memset(dd, -1, n * sizeof * dd);
			pq.push({dd[i] = 0, i});
			while (!pq.empty()) {
				auto [d, i] = pq.top();

				if (dd[i] != d)
					continue;
				if (removed[i] != h)
					ans = max(ans, d);
				for (int j : gr[i])
					if (dd[i] + 1 > dd[j])
						pq.push({dd[j] = dd[i] + 1, j});
			}
		}
		printf("%d\n", ans);
	}

}

int main() {
	run();
	return 0;
}

Compilation message (stderr)

bitaro.c:5:10: fatal error: bits/stdc++.h: No such file or directory
    5 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.