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

AcWing 2060. 奶牛选美 更多...

class  acwing2060
 
struct  point
 
struct  pointequal
 
struct  pointhash
 

函数

void flood (point first, bool occupy[55][55], unordered_set< point, pointhash, pointequal > *edge, char cowhide[55][55], int n, int m)
 
 TEST (acwing2060, case1)
 

详细描述

AcWing 2060. 奶牛选美

函数说明

◆ flood()

void acwing::acwing2060::flood ( point  first,
bool  occupy[55][55],
unordered_set< point, pointhash, pointequal > *  edge,
char  cowhide[55][55],
int  n,
int  m 
)

在文件 acwing.cpp371 行定义.

372 {
373 auto que = queue<point>();
374 const auto eq = pointequal();
375 que.push(first);
376 while(!que.empty()) {
377 auto p = que.front();
378 if(!eq(p, first) && occupy[p.x][p.y]) {
379 que.pop();
380 continue;
381 }
382 occupy[p.x][p.y] = true;
383 point nexts[] = {point(p.x + 1, p.y), point(p.x - 1, p.y), point(p.x, p.y + 1), point(p.x, p.y - 1)};
384 for(auto next: nexts) {
385 if(0 <= next.x && next.x <= n && 0 <= next.y && next.y <= m && !occupy[next.x][next.y]) {
386 if(cowhide[next.x][next.y] == 'X') {
387 que.push(next);
388 } else {
389 edge->insert(p);
390 }
391 }
392 }
393 que.pop();
394 }
395 }

被这些函数引用 acwing::acwing2060::acwing2060::main().

◆ TEST()

acwing::acwing2060::TEST ( acwing2060  ,
case1   
)

在文件 acwing_test.cpp306 行定义.

306 {
307 istringstream in("6 16\n"
308 "................\n"
309 "..XXXX....XXX...\n"
310 "...XXXX....XX...\n"
311 ".XXXX......XXX..\n"
312 "........XXXXX...\n"
313 ".........XXX....");
314 auto out = ostringstream();
315 acwing2060::main(in, out);
316 const auto ans = out.str();
317 ASSERT_EQ("3", ans);
318 }
int main(int argc, char **argv)
Definition: main.cpp:5

引用了 main().