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

#include <leetcode.h>

静态 Public 成员函数

static int digArtifacts (int n, vector< vector< int > > &artifacts, vector< vector< int > > &dig)
 

详细描述

在文件 leetcode.h1698 行定义.

成员函数说明

◆ digArtifacts()

int leetcode::count_artifacts_that_can_be_extracted::Solution::digArtifacts ( int  n,
vector< vector< int > > &  artifacts,
vector< vector< int > > &  dig 
)
static

在文件 leetcode.cpp4335 行定义.

4335 {
4336 auto *grid = new bool *[n];
4337 for(int i = 0; i < n; i++) {
4338 grid[i] = new bool[n];
4339 memset(grid[i], 0, n * sizeof(bool));
4340 }
4341 for(auto i: dig) {
4342 grid[i[0]][i[1]] = true;
4343 }
4344 int ans = 0;
4345 for(auto artifact: artifacts) {
4346 bool flag = true;
4347 for(int i = artifact[0]; i <= artifact[2]; i++) {
4348 for(int j = artifact[1]; j <= artifact[3]; j++) {
4349 if(!grid[i][j]) {
4350 flag = false;
4351 break;
4352 }
4353 }
4354 if(!flag) {
4355 break;
4356 }
4357 }
4358 if(flag) {
4359 ans++;
4360 }
4361 }
4362 for(int i = 0; i < n; i++) {
4363 delete[] grid[i];
4364 }
4365 delete[] grid;
4366 return ans;
4367 }

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


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