回答編集履歴
3
修正
answer
CHANGED
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
```C++
|
|
42
42
|
#include <utility> // std::pair
|
|
43
43
|
#include <algorithm> // std::generate_n
|
|
44
|
-
#include <iterator> // std::begin, std::end
|
|
45
44
|
#include <iostream>
|
|
46
45
|
|
|
47
46
|
int main() {
|
|
@@ -51,7 +50,7 @@
|
|
|
51
50
|
// P[N] を(1,0), (2,0), ... (N,0) で埋める
|
|
52
51
|
int i = 1;
|
|
53
52
|
std::generate_n(P, N,
|
|
54
|
-
[&]() { return std::pair<int,int>(++
|
|
53
|
+
[&]() { return std::pair<int,int>(i++,0); });
|
|
55
54
|
|
|
56
55
|
// デキタカナ?
|
|
57
56
|
for ( auto item : P) {
|
2
修正
answer
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
[追記] 別解:
|
|
41
41
|
```C++
|
|
42
42
|
#include <utility> // std::pair
|
|
43
|
-
#include <algorithm> // std::
|
|
43
|
+
#include <algorithm> // std::generate_n
|
|
44
44
|
#include <iterator> // std::begin, std::end
|
|
45
45
|
#include <iostream>
|
|
46
46
|
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
|
|
51
51
|
// P[N] を(1,0), (2,0), ... (N,0) で埋める
|
|
52
52
|
int i = 1;
|
|
53
|
-
std::
|
|
53
|
+
std::generate_n(P, N,
|
|
54
54
|
[&]() { return std::pair<int,int>(++i,0); });
|
|
55
55
|
|
|
56
56
|
// デキタカナ?
|
1
追記
answer
CHANGED
|
@@ -36,4 +36,27 @@
|
|
|
36
36
|
9,0
|
|
37
37
|
10,0
|
|
38
38
|
*/
|
|
39
|
+
```
|
|
40
|
+
[追記] 別解:
|
|
41
|
+
```C++
|
|
42
|
+
#include <utility> // std::pair
|
|
43
|
+
#include <algorithm> // std::generate
|
|
44
|
+
#include <iterator> // std::begin, std::end
|
|
45
|
+
#include <iostream>
|
|
46
|
+
|
|
47
|
+
int main() {
|
|
48
|
+
const int N = /* 100010 */ 10;
|
|
49
|
+
std::pair<int,int> P[N];
|
|
50
|
+
|
|
51
|
+
// P[N] を(1,0), (2,0), ... (N,0) で埋める
|
|
52
|
+
int i = 1;
|
|
53
|
+
std::generate(std::begin(P), std::end(P),
|
|
54
|
+
[&]() { return std::pair<int,int>(++i,0); });
|
|
55
|
+
|
|
56
|
+
// デキタカナ?
|
|
57
|
+
for ( auto item : P) {
|
|
58
|
+
std::cout << item.first << ',' << item.second << std::endl;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
39
62
|
```
|