Submission #974014

#TimeUsernameProblemLanguageResultExecution timeMemory
974014NotLinuxViruses (BOI20_viruses)C++17
0 / 100
181 ms262144 KiB
//author : FatihCihan #include <bits/stdc++.h> using namespace std; #define int long long #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() const int N = 1e5 + 7; const int inf = 1e18 + 7; int g,n,m,dp[N]; vector < int > mutation[N+1] , bruh[N+1]; int f(int x){ if(dp[x] != inf)return dp[x]; for(auto itr : bruh[x]){ int local_ans = 0; for(auto itr1 : mutation[itr]){ if(itr1 == x){ local_ans = inf; break; } else{ local_ans += f(itr1); } } dp[x] = min(dp[x] , local_ans); } return dp[x]; } void solve(){ for(int i = 0;i<N;i++)dp[i] = inf; cin >> g >> n >> m; for(int i = 0;i<n;i++){ int a,k; cin >> a >> k; bruh[a].push_back(i); mutation[i].resize(k); for(int j = 0;j<k;j++){ cin >> mutation[i][j]; } } for(int i = 0;i<m;i++){ int l; cin >> l; for(int j = 0;j<l;j++){ int gh; cin >> gh; } } dp[0] = dp[1] = 1; for(int i = 2;i<=g-1;i++){ cout << "NO " << f(i) << '\n'; } } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase = 1;//cin >> testcase; while(testcase--)solve(); cerr << 1000.0 * clock() / CLOCKS_PER_SEC << " ms" << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...