|
@@ -2,10 +2,13 @@
|
|
|
date = "2020-07-06T23:00:00+08:00"
|
|
|
draft = false
|
|
|
tags = []
|
|
|
-title = "初始化数组的不同方法及其运行时间"
|
|
|
+title = "Different Ways to Initialize an Array, and their Performance"
|
|
|
authors = ["xry111"]
|
|
|
+summary = "Discuss minor performance issues introduced by array initialization in competitive programming."
|
|
|
+++
|
|
|
|
|
|
+# 初始化数组的不同方法及其运行时间
|
|
|
+
|
|
|
众所周知,在程序设计竞赛中我们往往要初始化数组。初始化数组有很多不同的写法,
|
|
|
那么它们哪种更快呢?我们将进行一些计时测试,比较和分析它们的运行时间。
|
|
|
|
|
@@ -273,7 +276,7 @@ int main() {}
|
|
|
洛谷等评测系统会将多组数据的运行时间叠加起来,作为总运行时间,
|
|
|
这就会产生可观的差距。
|
|
|
|
|
|
-对此一种解决方法是使用 `= default()` 显式指定默认构造函数,例如:
|
|
|
+对此一种解决方法是使用 `= default` 显式指定默认构造函数,例如:
|
|
|
|
|
|
```c++
|
|
|
struct node
|