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 ll = long long;
template<class T> bool cmin(T &i, T j) { return i > j ? i=j,1:0; }
template<class T> bool cmax(T &i, T j) { return i < j ? i=j,1:0; }
const int B = 90, N = 1e5;
multiset<int> dist[N];
map<int,int> start_node[N];
vector<int> adj[N];
int banned[N];
void dfs(int u,int d,int start) {
for (int &v: adj[u]) {
if (cmax(start_node[u][start],d)) {
if (dist[v].size() == B) {
if (*dist[v].begin() < d) {
dist[v].erase(dist[v].begin());
dist[v].insert(d);
dfs(v,d+1,start);
}
} else {
dist[v].insert(d);
dfs(v,d+1,start);
}
}
}
}
void solve() {
int n,m,q;
cin >> n >> m >> q;
for (int u,v;m--;) {
cin >> u >> v;
adj[--u].push_back(--v);
}
for (int i=0;i<n;i++) {
dist[i].insert(0);
}
for (int i=0;i<n;i++) {
dfs(i,0,i);
}
for (int u,sz;q--;) {
cin >> u >> sz;
--u;
for (int i=0;i<sz;i++) {
cin >> banned[i];
banned[i]--;
}
}
/*
for (int i=0;i<n;i++) {
for (auto [start,d]: start_node[i]) {
cout << d << " " << start << "\n";
}
cout << "\n";
}
*/
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int _t = 1;
for (int i=1;i<=_t;i++) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |