# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
497250 | SirCovidThe19th | Link (CEOI06_link) | C++17 | 361 ms | 8460 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;
const int mx = 5e5 + 5;
int n, k, ans, indeg[mx], nxt[mx], dst[mx]; bool vis[mx];
void solveIndeg0(){
queue<int> q; memset(dst, 0x3f, sizeof(dst));
dst[1] = 0;
for (int i = 1; i <= n; i++) if (!indeg[i]) q.push(i);
while (!q.empty()){
int cur = q.front(), to = nxt[cur]; q.pop();
vis[cur] = 1;
if (dst[cur] > k) dst[cur] = 1, ans++;
dst[to] = min(dst[to], dst[cur] + 1);
if (!(--indeg[to])) q.push(to);
}
}
void solveCyc(int cur){
vector<int> nodes;
while (!vis[cur]) nodes.push_back(cur), vis[cur] = 1, cur = nxt[cur];
int stPos = 1e9, longest = -1, sz = nodes.size(); bool ok[sz] = {};
for (int i = 0, pos = i, D = 2e9; i < sz * 2; i++, pos = i % sz){
D = min(D + 1, dst[nodes[pos]]);
ok[pos] |= (D <= k);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |