Submission #726064

#TimeUsernameProblemLanguageResultExecution timeMemory
726064JohannViruses (BOI20_viruses)C++14
0 / 100
1 ms596 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<ll, ll> pii; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<pii> vpii; typedef vector<vpii> vvpii; #define all(x) (x).begin(), (x).end() int G, N, M; vi key; vvi values; vi ans; vi done; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> G >> N >> M; key.resize(N), values.resize(N); for (int i = 0, a, k; i < N; ++i) { cin >> a >> k; key[i] = a; values[i].assign(G, 0); for (int j = 0, c; j < k; ++j) cin >> c, ++values[i][c]; } bool con = true; done.assign(N, false); while (con) { con = false; pii idx = {1LL << 60, -1}; for (int i = 0; i < N; ++i) { if (!done[i]) { ll allStuff = accumulate(all(values[i]), 0LL); if (allStuff == values[i][0] + values[i][1]) idx = min(idx, {allStuff, i}); } } if (idx.second != -1) { done[idx.second] = true; con = true; int k = key[idx.second]; for (int i = 0; i < N; ++i) { values[i][0] += idx.first * values[i][k]; values[i][k] = 0; } } } for (int i = 2; i < G; ++i) { cout << "NO " << values[i][0] + values[i][1] << "\n"; } return 0; }
#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...