Submission #531060

#TimeUsernameProblemLanguageResultExecution timeMemory
531060mdubaisiAlkemija (COCI18_alkemija)C++14
8 / 80
52 ms65540 KiB
#include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #define endl "\n" #define debug(x) cout << "DEBUG" << x << ": " #define fastimize() ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL) #define all(v) (v.begin()), (v.end()) #define endof(v) v[v.size() - 1] #define setall(a, val) memset(a, val, sizeof a) #define range(v, s, e) (v.begin() + s), (v.begin() + e) #define ll long long const ll MOD = 1e9 + 7; const int N = 1e6 + 1; const ll M = 30; using namespace std; bool have[N], used[N]; struct Reaction { vector<int> to; vector<bool> need; Reaction() : to(vector<int>(0)), need(vector<bool>(0)) {} }; int main() { fastimize(); int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int x; cin >> x; have[x] = true; } int k; cin >> k; vector<Reaction> reactions(k); for (int i = 0; i < k; i++) { int l, r; cin >> l >> r; vector<int> y(r); reactions[i].need = vector<bool>(n + 1, false); for (int j = 0; j < l; j++) { int x; cin >> x; if (!have[x]) reactions[i].need[x] = !have[x]; } for (int j = 0; j < r; j++) cin >> y[j]; reactions[i].to = y; } bool flag = true; while (flag) { flag = false; for (int i = 0; i < k; i++) { if (!used[i]) { for (int j = 0; j < reactions[i].need.size(); j++) { if (have[reactions[i].need[j]]) reactions[i].need[j] = false; } if (reactions[i].need != vector<bool>(n + 1, false)) break; flag = true; used[i] = true; for (int x : reactions[i].to) have[x] = true; break; } } } int ans = 0; for (int i = 1; i <= n; i++) ans += have[i]; cout << ans << endl; for (int i = 1; i <= n; i++) if (have[i]) cout << i << ' '; cout << endl; }

Compilation message (stderr)

alkemija.cpp: In function 'int main()':
alkemija.cpp:61:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for (int j = 0; j < reactions[i].need.size(); j++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#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...