Submission #299982

#TimeUsernameProblemLanguageResultExecution timeMemory
299982shrek12357Alkemija (COCI18_alkemija)C++14
80 / 80
667 ms50040 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> using namespace std; int main() { int n, m; cin >> n >> m; //vector<int> nums; queue<int> q; bool vis[100005]; for (int i = 0; i <= n; i++) { vis[i] = false; } for (int i = 0; i < m; i++) { int temp; cin >> temp; q.push(temp); vis[temp] = true; } map<set<int>, vector<set<int>>> adjList; map<int, vector<set<int>>> groups; map<set<int>, int> counts; int k; cin >> k; for (int i = 0; i < k; i++) { int a, b; cin >> a >> b; set<int> s1, s2; for (int j = 0; j < a; j++) { int temp; cin >> temp; s1.insert(temp); } for (int j = 0; j < b; j++) { int temp; cin >> temp; s2.insert(temp); } adjList[s1].push_back(s2); for (auto i : s1) { groups[i].push_back(s1); } counts[s1] = 0; } int counter = 0; while (q.size() > 0) { //vis[q.front()] = true; counter++; int curNode = q.front(); q.pop(); for (auto i : groups[curNode]) { counts[i]++; if (counts[i] == i.size()) { for (auto j : adjList[i]) { for (auto k : j) { if (!vis[k]) { vis[k] = true; q.push(k); } } } } } } cout << counter << endl; int cnt = 0; for (int i = 0; i <= n; i++) { if (vis[i]) { cnt++; cout << i; if (cnt != counter) { cout << " "; } } } cout << endl; }

Compilation message (stderr)

alkemija.cpp: In function 'int main()':
alkemija.cpp:62:18: warning: comparison of integer expressions of different signedness: 'std::map<std::set<int>, int>::mapped_type' {aka 'int'} and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |    if (counts[i] == i.size()) {
#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...