Submission #850043

# Submission time Handle Problem Language Result Execution time Memory
850043 2023-09-15T16:44:54 Z 1075508020060209tc Povjerenstvo (COI22_povjerenstvo) C++14
0 / 100
478 ms 104888 KB
#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

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 time Memory Grader output
1 Correct 308 ms 104888 KB Output is correct
2 Correct 290 ms 68740 KB Output is correct
3 Correct 6 ms 25176 KB Output is correct
4 Correct 47 ms 34744 KB Output is correct
5 Correct 169 ms 58816 KB Output is correct
6 Correct 219 ms 67032 KB Output is correct
7 Correct 228 ms 77004 KB Output is correct
8 Correct 231 ms 71988 KB Output is correct
9 Correct 478 ms 79960 KB Output is correct
10 Incorrect 437 ms 65716 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 317 ms 104884 KB Output is correct
2 Correct 230 ms 67888 KB Output is correct
3 Correct 222 ms 75844 KB Output is correct
4 Incorrect 474 ms 70264 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 26200 KB Output is correct
2 Correct 8 ms 25944 KB Output is correct
3 Correct 7 ms 25944 KB Output is correct
4 Incorrect 8 ms 25900 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 308 ms 104888 KB Output is correct
2 Correct 290 ms 68740 KB Output is correct
3 Correct 6 ms 25176 KB Output is correct
4 Correct 47 ms 34744 KB Output is correct
5 Correct 169 ms 58816 KB Output is correct
6 Correct 219 ms 67032 KB Output is correct
7 Correct 228 ms 77004 KB Output is correct
8 Correct 231 ms 71988 KB Output is correct
9 Correct 478 ms 79960 KB Output is correct
10 Incorrect 437 ms 65716 KB Output isn't correct
11 Halted 0 ms 0 KB -