teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

修正

2020/08/31 03:37

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -13,7 +13,7 @@
13
13
  using P1 = std::pair<int, int>;
14
14
 
15
15
  struct P2 {
16
- P2(int _y, int _x) : y(_y), x(_x)
16
+ P2(int y, int x) : y(y), x(x)
17
17
  {
18
18
  }
19
19
 

2

修正

2020/08/31 03:37

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -19,6 +19,7 @@
19
19
 
20
20
  bool operator<(const P2 &rhs) const
21
21
  {
22
+ // y の値を優先してソートするなら
22
23
  return y != rhs.y ? y < rhs.y : x < rhs.x;
23
24
  }
24
25
 

1

修正

2020/08/31 03:29

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -37,8 +37,8 @@
37
37
  s1.emplace(y, x);
38
38
  s2.emplace(y, x);
39
39
 
40
- for (const auto &val : s2)
40
+ for (const auto &point : s2)
41
- std::cout << "(y, x) = " << val.y << "," << val.x << std::endl;
41
+ std::cout << "(y, x) = " << point.y << "," << point.x << std::endl;
42
42
  }
43
43
 
44
44
  ```