Help me in solving DAA109 problem

My issue

Help me to find the error. It prints the right output, but submission is not accepted.

My code

#include <bits/stdc++.h>
using namespace std;
// vector<int>visited(1000);

vector<vector<int> > graph;

void dfs(int node, vector<bool>& visited){
    visited[node]= true;
    
    cout<<node<<" ";
    
    for(int i=0; i<graph[node].size(); i++){
        if(graph[node][i]==1 && (!visited[node])){
            dfs(i, visited);  
        }
    }    
     
}


int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	graph = vector<vector<int>>(n, vector<int>(n, 0));
	vector<bool> visited(n, false);
	
	for(int i=0; i<m; i++){
	    int a,b;
	    cin>>a>>b;
	    graph[a][b]==1;
	    
	}
	
// 	dfs(0, visited[0]);
	
	for(int i=1; i<n;i++ ){
        
        if(!visited[i]){
        dfs(i, visited);
        
        }
	}
    
}

Learning course: Graphs
Problem Link: Check Reachability Practice Problem in Graphs - CodeChef

@savitrik
plzz refer the following code

#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 1;
vector<int> adj[N];
vector<bool> vis(N, 0);

void dfs(int v) {
    if(vis[v]) {
        return;
    }
    vis[v] = true;

    for(auto u: adj[v]) {
        dfs(u);
    }
}

int main() {
    int n, m; 
    cin >> n >> m;

    while(m--) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b); // Directed edge
    }

    dfs(1); // Start dfs from source: 1

    for(int i = 1; i <= n; i++) {
        if(vis[i]) // A node is reachable if it is marked visited
            cout << i << " ";
    }
}