Submission #239011

#TimeUsernameProblemLanguageResultExecution timeMemory
239011NONAMEAlkemija (COCI18_alkemija)C++17
80 / 80
81 ms15992 KiB
#include <iostream> #include <vector> #include <queue> #include <fstream> using namespace std; typedef long long ll; typedef pair <ll, ll> pll; const int N = 2e5 + 10; int n, m, ost[N], l[N], r[N]; bool mk[N], f[N]; vector <int> ps[N], v[N]; queue <int> q; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("in.txt", "r", stdin); cin >> n >> m; for (int i = 0; i < m; ++i) { int x; cin >> x; f[x] = 1; } cin >> m; for (int i = 0; i < m; ++i) { cin >> l[i] >> r[i]; ost[i] = l[i]; for (int j = 0; j < l[i]; ++j) { int x; cin >> x; ps[x].push_back(i); if (f[x]) --ost[i]; } if (!ost[i]) { q.push(i); mk[i] = 1; } for (int j = 0; j < r[i]; ++j) { int x; cin >> x; v[i].push_back(x); } } while (!q.empty()) { int u = q.front(); q.pop(); for (int i = 0; i < r[u]; ++i) { int x = v[u][i]; if (!f[x]) { f[x] = 1; for (int j = 0; j < ps[x].size(); ++j) { int p = ps[x][j]; if (mk[p]) continue; --ost[p]; if (!ost[p]) { q.push(p); mk[p] = 1; } } } } } int answer = 0; for (int i = 1; i <= n; ++i) answer += f[i]; cout << answer << "\n"; for (int i = 1; i <= n; ++i) if (f[i]) cout << i << " "; }

Compilation message (stderr)

alkemija.cpp: In function 'int main()':
alkemija.cpp:64:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int j = 0; j < ps[x].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...