Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Common Mistakes #2368

Closed
1 task done
ksyx opened this issue Jul 4, 2020 · 0 comments · Fixed by #2369
Closed
1 task done

[BUG] Common Mistakes #2368

ksyx opened this issue Jul 4, 2020 · 0 comments · Fixed by #2369
Labels
Content Bug / 页面内容有误 Something isn't working help wanted / 需要帮助 Extra attention is needed

Comments

@ksyx
Copy link
Member

ksyx commented Jul 4, 2020

  • 我正在着手修复这个问题

我正在访问这个页面(最好带链接)

https://oi-wiki.org/intro/common-mistakes/

我发现页面有这样的问题

  1. Line 177
    这样写虽然在正确性上没有问题,但是如果你直接对函数的返回值取 max,如 `a = Max(func1(), func2())` ,而这个函数的运行时间较长,则会大大影响程序的性能,因为宏展开后是 `a = func1() > func2() ? func1() : func2()` 的形式,调用了三次函数,比正常的 max 函数多调用了一次。

这不止时间复杂度的问题了吧,例如 func1() 里面是 return ++a;a 是全局变量,这样每次执行 func1() return 的值都不一样
2. Line 186

++ti[t];  // 记录结点访问次数方便测试

方便调试?
3. Line 237

-   指针指向的区域已经 `free` 或 `delete` 。

delete 内存区域怪怪的

@ksyx ksyx added Content Bug / 页面内容有误 Something isn't working help wanted / 需要帮助 Extra attention is needed labels Jul 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content Bug / 页面内容有误 Something isn't working help wanted / 需要帮助 Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant