YukimuraYukino's blog

By YukimuraYukino, 8 years ago, In English

I was trying to solve this problem: 343D. I used for each to iterate through the adjacent list in DFS and get MLE: 17028123

for (int v: adj[u]) {
	if (flag[v]) continue;
	DFS(v);
}

Then I switch to normal for statement and got AC: 17028517

for (int i = 0; i < adj[u].size(); ++i) {
	int v = adj[u].get(i);
	if (flag[v] == false) DFS(v);
}

Could someone explain why this happened, please ?

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it