Submission #1114651

#TimeUsernameProblemLanguageResultExecution timeMemory
1114651NotLinuxPovjerenstvo (COI22_povjerenstvo)C++17
100 / 100
272 ms38852 KiB
// Author : FatihCihan #include <bits/stdc++.h> using namespace std; #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() void solve(){ int n,m; cin >> n >> m; vector < int > graph[n]; for(int i = 0;i<m;i++){ int a,b; cin >> a >> b; a-- , b--; graph[a].push_back(b); graph[b].push_back(a); } int vis[n] = {0}; vector < int > ans; for(int i = 0;i<n;i++){ if(vis[i] == 0){ ans.push_back(i+1); for(auto itr : graph[i]){ vis[itr] = 1; } } } cout << sz(ans) << endl; for(auto itr : ans){ cout << itr << " "; } cout << endl; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase = 1;//cin >> testcase; while(testcase--)solve(); cerr << 1000.0 * clock() / CLOCKS_PER_SEC << " ms" << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...