NEED HELP !

Revision en3, by Jinwoo-Sung, 2025-05-19 12:32:51

TO ALL GOOD CODERS PLEASE HELP ME OUT

Hey guys, i have spent way too much time on upsolving this problem but i cant get what i am doing wrong

Problem --> 2109D - D/D/D

My code --> ` void dfs(int x , vector &visited , vector<vector>&adj , string &res , int &count , int &j){ if(count > j) return; if(count % 2 == j % 2) res[x-1] = '1'; visited[x] = true;

for(int neighbour : adj[x]){
    if(!visited[neighbour]){
        count++;
        dfs(neighbour , visited , adj ,res , count , j);
    }
}

}

void solve(){ int n , m , l; cin >> n >> m >> l;

string res(n , '0');

vector<vector<int>>adj(n+1);
vector<int>a(l);
vector<int>visited(n , false);

//* members of multiset
for(int k = 0; k < l; k++){
    cin >> a[k];
}

//* adj list
for(int k =0 ; k < m; k++){
    int u , v;
    cin >> u >> v;

    adj[u].pb(v);
    adj[v].pb(u);
}


res[0] = '1';
for(int k = 0; k < l; k++){
    int count = 0, j = a[k];
    dfs(1 , visited , adj ,res , count , j);
}

cout << res << endl;

}

int main(){ int t; cin >> t;

while(t--){
    solve();
}

} `

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English Jinwoo-Sung 2025-05-19 12:34:46 16
en4 English Jinwoo-Sung 2025-05-19 12:34:02 16
en3 English Jinwoo-Sung 2025-05-19 12:32:51 10
en2 English Jinwoo-Sung 2025-05-19 12:32:18 4 Tiny change: 'ing wrong \nProblem ' -> 'ing wrong '\n'\nProblem '
en1 English Jinwoo-Sung 2025-05-19 12:31:49 1277 Initial revision (published)