Submission #973950

#TimeUsernameProblemLanguageResultExecution timeMemory
973950aegViruses (BOI20_viruses)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int g, n, m; vector<vector<vector<int>>> table; vector<ll> dp; inline ll f(int a, bitset<100> vis) { if(dp[a] != -1) return dp[a]; vis[a] = true; ll ret = INT64_MAX; for(auto &x : table[a]) { ll cur = 0; for(auto &y : x) { if(vis[y] && dp[y] == -1) { cur = -2; break; } cur += f(y, vis); } if(cur == -2) { continue; } ret = min(ret, cur); } dp[a] = ret; return dp[a]; } int main() { cin >> g >> n >> m; table.resize(g); for(int i = 0; i < n; i ++) { int a, k; cin >> a >> k; table[a].push_back(vector<int>(k)); for(int j = 0; j < k; j ++) { cin >> table[a].back()[j]; } } for(int i = 0; i < m; i ++) { int k; cin >> k; for(int j = 0; j < k; j ++) {int tmp; cin >> tmp;} } dp.assign(g, -1); dp[0] = dp[1] = 1; for(int i = 0; i < g; i ++) { cout << "NO " << f(i, bitset<100>(0)) << '\n'; } }
#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...