problemscpp
A collection of my answers to algorithm problems in c++.
函数
acwing::acwing1671 命名空间参考

  1. 三角形
更多...

函数

int main (istream &cin, ostream &cout)
 
 TEST (acwing1671, case1)
 

详细描述

  1. 三角形

函数说明

◆ main()

int acwing::acwing1671::main ( istream &  cin,
ostream &  cout 
)

在文件 acwing.cpp5635 行定义.

5635 {
5636 int ans = 0;
5637 unordered_map<int, set<int>> col;
5638 unordered_map<int, set<int>> row;
5639 set<pair<int, int>> us;
5640 int n;
5641 cin >> n;
5642 for(int i = 0; i < n; i++) {
5643 int x;
5644 int y;
5645 cin >> x >> y;
5646 us.insert(make_pair(x, y));
5647 row[x].insert(y);
5648 col[y].insert(x);
5649 }
5650 for(auto [x, y]: us) {
5651 const int max_width = max(abs(*row[x].begin() - y), abs(*row[x].rbegin() - y));
5652 const int max_height = max(abs(*col[y].begin() - x), abs(*col[y].rbegin() - x));
5653 ans = max(ans, max_width * max_height);
5654 }
5655 cout << ans;
5656 return 0;
5657 }

被这些函数引用 TEST().

◆ TEST()

acwing::acwing1671::TEST ( acwing1671  ,
case1   
)

在文件 acwing_test.cpp2708 行定义.

2708 {
2709 istringstream in("4\n"
2710 "0 0\n"
2711 "0 1\n"
2712 "1 0\n"
2713 "1 2");
2714 auto out = ostringstream();
2715 main(in, out);
2716 const auto ans = out.str();
2717 ASSERT_EQ("2", ans);
2718 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().