problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
luogu::P5461类 参考

洛谷 P5461 赦免战俘 更多...

#include <luogu.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 
static void pardon (bool **matrix, int x0, int y0, int n)
 

详细描述

洛谷 P5461 赦免战俘

在文件 luogu.h627 行定义.

成员函数说明

◆ main()

int luogu::P5461::main ( istream &  cin,
ostream &  cout 
)
static

在文件 luogu.cpp2341 行定义.

2341 {
2342 unsigned int n;
2343 cin >> n;
2344 n = 1 << n;
2345 auto *const matrix = new bool *[n];
2346 for(int i = 0; i < n; i++) {
2347 matrix[i] = new bool[n];
2348 memset(matrix[i], 1, n * sizeof(bool));
2349 }
2350 pardon(matrix, 0, 0, n);
2351 for(int i = 0; i < n; i++) {
2352 for(int j = 0; j < n; j++) {
2353 cout << matrix[i][j] << " ";
2354 }
2355 cout << endl;
2356 delete[] matrix[i];
2357 }
2358 delete[] matrix;
2359 return 0;
2360 }
static void pardon(bool **matrix, int x0, int y0, int n)
Definition: luogu.cpp:2362

引用了 pardon().

被这些函数引用 luogu::TEST().

◆ pardon()

void luogu::P5461::pardon ( bool **  matrix,
int  x0,
int  y0,
int  n 
)
static

在文件 luogu.cpp2362 行定义.

2362 {
2363 if(n == 2) {
2364 matrix[x0][y0] = false;
2365 return;
2366 }
2367 for(int i = 0; i < n / 2; i++) {
2368 for(int j = 0; j < n / 2; j++) {
2369 matrix[x0 + i][y0 + j] = false;
2370 }
2371 }
2372 pardon(matrix, x0, y0 + n / 2, n / 2);
2373 pardon(matrix, x0 + n / 2, y0, n / 2);
2374 pardon(matrix, x0 + n / 2, y0 + n / 2, n / 2);
2375 }

引用了 pardon().

被这些函数引用 main() , 以及 pardon().


该类的文档由以下文件生成: