# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
981803 | blackslex | Bitaro’s Party (JOI18_bitaro) | C++17 | 1156 ms | 417396 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using P = pair<pii, int>;
const int N = 1e5 + 5;
int n, m, q, x, y, t, r, ptr[N], cdp[N];
vector<int> v[N], rev[N];
vector<pii> dp[N];
int main() {
scanf("%d %d %d", &n, &m, &q);
int k = ceil(sqrt(n));
while (m--) scanf("%d %d", &x, &y), v[x].emplace_back(y), rev[y].emplace_back(x);
for (int i = 1; i <= n; i++) cdp[i] = -1e9;
for (int i = 1; i <= n; i++) {
priority_queue<P> pq;
pq.emplace(pii(0, i), n + 1);
for (auto &e: rev[i]) {
auto [x, y] = dp[e][0];
pq.emplace(pii(x + 1, y), e);
ptr[e] = 1;
}
while (!pq.empty() && dp[i].size() <= k) {
auto [x, y] = pq.top(); pq.pop();
dp[i].emplace_back(x);
if (ptr[y] < dp[y].size()) {
auto [cx, cy] = dp[y][ptr[y]]; ptr[y]++;
pq.emplace(pii(cx + 1, cy), y);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |