Submission #974024

#TimeUsernameProblemLanguageResultExecution timeMemory
974024NotLinuxViruses (BOI20_viruses)C++17
11 / 100
1 ms600 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() void solve(){ int G, N, M; cin >> G >> N >> M; vector < vector < vector < int > > > graph(G); while (N--) { int a, k; cin >> a >> k; vector < int > b(k); for (auto &x: b) { cin >> x; } graph[a].push_back(b); } vector < int > shortest(G , -1); shortest[0] = shortest[1] = 1; while (true) { bool change = false; for (int i = 2; i < G; ++i) { for (auto &v : graph[i]) { int sum = 0; for (auto x : v) { if (shortest[x] == -1) { sum = -1; break; } sum += shortest[x]; } if (sum != -1 and (shortest[i] == -1 or shortest[i] > sum)) { shortest[i] = sum; change = true; } } } if (!change) { break; } } for (int i = 2; i < G; ++i) { if (shortest[i] == -1) { cout << "YES\n"; } else { cout << "NO " << shortest[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...