Submission #799308

# Submission time Handle Problem Language Result Execution time Memory
799308 2023-07-31T12:22:34 Z elotelo966 Naboj (COCI22_naboj) C++17
0 / 110
98 ms 18996 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 1000000005
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mid (start+end)/2
#define mod 1000000007
vector <int> v[200005];
int re[200005];
vector <pair<int,int>> cev;

inline void dfs(int node,int ata,int renk){
    for(int i=0;i<v[node].size();i++){
        int go=v[node][i];
        if(go==ata || re[go]!=-1)continue;
        re[go]=renk^1;
        //cout<<node<<" "<<renk<<'\n';
        cev.push_back({go,renk^1});
        dfs(go,ata,renk^1);
    }
}

int32_t main(){
    faster
    int n,m;cin>>n>>m;
    memset(re,-1,sizeof(re));
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    re[1]=0;
    cev.push_back({1,1});
    dfs(1,-1,1);
    cout<<cev.size()<<'\n';
    for(int i=0;i<cev.size();i++){
        cout<<cev[i].first<<" "<<cev[i].second<<'\n';
    }
    return 0;
}

Compilation message

naboj.cpp: In function 'void dfs(long long int, long long int, long long int)':
naboj.cpp:13: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]
   13 |     for(int i=0;i<v[node].size();i++){
      |                 ~^~~~~~~~~~~~~~~
naboj.cpp: In function 'int32_t main()':
naboj.cpp:36:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i=0;i<cev.size();i++){
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 18996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6484 KB Output isn't correct
2 Halted 0 ms 0 KB -