# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985641 | SmuggingSpun | Bitaro’s Party (JOI18_bitaro) | C++14 | 2 ms | 3596 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>
#define taskname "A"
using namespace std;
template<class T>void maximize(T& a, T b){
if(a < b){
a = b;
}
}
int n, m, q;
namespace sub12{
const int lim = 1e5 + 5;
vector<int>e[lim];
int deg[lim], dp[lim];
void solve(){
memset(deg, 0, sizeof(deg));
for(int _ = 0; _ < m; _++){
int u, v;
cin >> u >> v;
e[u].emplace_back(v);
deg[v]++;
}
int t, y;
cin >> t >> y;
bitset<lim>busy;
busy.reset();
for(int _ = 0; _ < y; _++){
int x;
cin >> x;
busy.set(x);
}
queue<int>Q;
memset(dp, -1, sizeof(dp));
for(int i = 1; i <= n; i++){
if(deg[i] == 0){
Q.push(i);
dp[i] = -busy.test(i);
}
}
while(!Q.empty()){
int u = Q.front();
Q.pop();
for(int& v : e[u]){
maximize(dp[v], dp[u] + 1);
if(--deg[v] == 0){
Q.push(v);
}
}
}
cout << dp[t];
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> m >> q;
if(q == 1){
sub12::solve();
}
}
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... |