洛谷 P5731 【深基5.习6】蛇形方阵
更多...
#include <luogu.h>
|
static int | main (istream &cin, ostream &cout) |
|
static pair< int, int > | move_forward (int dir, int current_x, int current_y) |
|
洛谷 P5731 【深基5.习6】蛇形方阵
在文件 luogu.h 第 455 行定义.
◆ main()
int luogu::P5731::main |
( |
istream & |
cin, |
|
|
ostream & |
cout |
|
) |
| |
|
static |
< Direction 0 = R, 1 = D, 2 = L, 3 = U
在文件 luogu.cpp 第 1506 行定义.
1509 int square[9][9] = {};
1513 for(
int i = 1; i <= n * n; i++) {
1514 square[current_x][current_y] = i;
1515 auto [next_x, next_y] =
move_forward(dir, current_x, current_y);
1516 if(next_x < 0 || next_x >= n || next_y < 0 || next_y >= n || square[next_x][next_y] != 0) {
1517 dir = (dir + 1) % 4;
1519 const auto next =
move_forward(dir, current_x, current_y);
1520 current_x = next.first;
1521 current_y = next.second;
1523 for(
int i = 0; i < n; i++) {
1524 for(
int j = 0; j < n; j++) {
1525 cout << setw(3) <<
right << setfill(
' ') << square[i][j];
static pair< int, int > move_forward(int dir, int current_x, int current_y)
引用了 move_forward() , 以及 acwing::acwing1929::right.
被这些函数引用 luogu::TEST().
◆ move_forward()
pair< int, int > luogu::P5731::move_forward |
( |
int |
dir, |
|
|
int |
current_x, |
|
|
int |
current_y |
|
) |
| |
|
static |
< R
< D
< L
< U
在文件 luogu.cpp 第 1532 行定义.
1533 int next_x = current_x;
1534 int next_y = current_y;
1549 return make_pair(next_x, next_y);
被这些函数引用 main().
该类的文档由以下文件生成: