Submission #726385

#TimeUsernameProblemLanguageResultExecution timeMemory
726385JohannViruses (BOI20_viruses)C++14
0 / 100
1 ms340 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 >> key[i] >> k; 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); ans.assign(G, -1); 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]; if (ans[k] == -1) ans[k] = idx.first; 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 " << ans[i] << "\n"; } return 0; }

Compilation message (stderr)

Viruses.cpp: In function 'int main()':
Viruses.cpp:27:21: warning: unused variable 'a' [-Wunused-variable]
   27 |     for (int i = 0, a, k; i < N; ++i)
      |                     ^
#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...