Submission #850043

#TimeUsernameProblemLanguageResultExecution timeMemory
8500431075508020060209tcPovjerenstvo (COI22_povjerenstvo)C++14
0 / 100
478 ms104888 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int n;int m; vector<int>be[500005]; vector<int>e[500005]; int vis[500005]; int clr[500005]; vector<int>vc; vector<int>ans; void dfs(int nw){ vis[nw]=1; vc.push_back(nw); for(int i=0;i<be[nw].size();i++){ int v=be[nw][i]; if(vis[v]){continue;} clr[v]=clr[nw]^1; dfs(v); } } signed main(){ cin>>n>>m; for(int i=1;i<=m;i++){ int a;int b; cin>>a>>b; be[a].push_back(b); be[b].push_back(a); e[a].push_back(b); } for(int i=1;i<=n;i++){ if(vis[i]){continue;} dfs(i); vector<int>va;vector<int>vb; for(int j=0;j<vc.size();j++){ if(clr[vc[j]]){ va.push_back(vc[j]); }else{ vb.push_back(vc[j]); } } vc.clear(); int ok=1; for(int j=0;j<va.size();j++){ if(e[va[j]].size()==0){ok=0;} } if(ok){ for(int j=0;j<vb.size();j++){ ans.push_back(vb[j]); } continue; } swap(va,vb); ok=1; for(int j=0;j<va.size();j++){ if(e[va[j]].size()==0){ok=0;} } if(ok){ for(int j=0;j<vb.size();j++){ ans.push_back(vb[j]); } continue; } cout<<-1;return 0; } cout<<ans.size()<<endl; for(int i=0;i<ans.size();i++){ cout<<ans[i]<<" "; } }

Compilation message (stderr)

Main.cpp: In function 'void dfs(long long int)':
Main.cpp:14:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 | for(int i=0;i<be[nw].size();i++){
      |             ~^~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:38:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int j=0;j<vc.size();j++){
      |                 ~^~~~~~~~~~
Main.cpp:47:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for(int j=0;j<va.size();j++){
      |                 ~^~~~~~~~~~
Main.cpp:51:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         for(int j=0;j<vb.size();j++){
      |                     ~^~~~~~~~~~
Main.cpp:58:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int j=0;j<va.size();j++){
      |                 ~^~~~~~~~~~
Main.cpp:62:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         for(int j=0;j<vb.size();j++){
      |                     ~^~~~~~~~~~
Main.cpp:70:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 | for(int i=0;i<ans.size();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...