POJ - Lake Counting(DFS)

YOLO11实战 第010期-基于yolo11的农业杂草作物目标检测实战文档(详细教程) 通过这条曲线,用户可以评估模型的检测能力,分析模型在不同阈值下对真实目标的检测是否全面。通过这条曲线,可以评估模型在目标检测任务中的整体性能,并找到合适的置信度阈值,以在精确率和召回率之间做出最佳平衡。PR 曲线越接近右上角,模型性能越好,曲线下方的面积越大,说明模型在不同置信度下的。),它展示了不同置信度下的召回率。条曲线都显示了随着召回率的增加,精确度略有下降的趋势,但整体上精确度保持在很高的水平。通过这条曲线,可以选择合适的置信度阈值,以优化模型的检测结果,平衡精确率和召回率。反映了分类器的准确性。 阅读详情
Lake Counting

Description

Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water ('W') or dry land ('.'). Farmer John would like to figure out how many ponds have formed in his field. A pond is a connected set of squares with water in them, where a square is considered adjacent to all eight of its neighbors.

Given a diagram of Farmer John's field, determine how many ponds he has.

Input

* Line 1: Two space-separated integers: N and M

* Lines 2..N+1: M characters per line representing one row of Farmer John's field. Each character is either 'W' or '.'. The characters do not have spaces between them.

Output

* Line 1: The number of ponds in Farmer John's field.

Sample Input

10 12
W........WW.
.WWW.....WWW
....WW...WW.
.........WW.
.........W..
..W......W..
.W.W.....WW.
W.W.W.....W.
.W.W......W.
..W.......W.

Sample Output

3

Hint

OUTPUT DETAILS:

There are three ponds: one in the upper left, one in the lower left,and one along the right side.

Source

USACO 2004 November
/*
*  假设从任意一点W开始,不停地把邻接的部分用'.'代替。1次DFS之后与初始动这个W连接的所有W都被替换成'.'因此直到图中不再存在W为止。
*  总共进行DFS的次数就是最后的结果咯!8个方向对应了8种状态转移,每个各自作为DFS的参数至多被调用一次,所以时间复杂度为:O(8*N*M)。
*
*/
#include <iostream>

using namespace std;

char pos[101][101];
int n,m;
void dfs(int x, int y)
{
    pos[x][y] = '.';
    for(int dx = -1; dx <= 1; dx++)
    for(int dy = -1; dy <= 1; dy++)
    {
        int nx = x + dx, ny = y + dy;
        if(0<=nx&&nx<n&&0<=ny&&ny<m&&pos[nx][ny]=='W')
        dfs(nx,ny);
    }
    return ;
}
int main(void)
{
    while(cin>>n>>m)
    {
        for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
        cin>>pos[i][j];
        int res = 0;
        for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
        {
            if(pos[i][j] == 'W')
            {
                dfs(i,j);
                res++;
            }
        }
        cout<<res<<endl;
    }
    return 0;
}


【MATLAB代码】UKF组合导航例程,15维状态量、3维观测量。附完整的代码,有中文注释、误差输出图像 摘要 本文提出了一种基于15维误差状态模型的UKF组合导航算法,实现了三维位置、速度和姿态的高精度估计。算法采用严格的误差状态模型,包含位置(3)、速度(3)、姿态(3)、陀螺偏差(3)和加速度计偏差(3)共15个状态量,通过3维GNSS位置观测进行校正。仿真结果表明,相比纯IMU积分,UKF算法能有效抑制误差积累,显著提高导航精度。文中提供了完整的MATLAB源代码,可直接运行并复现三维轨迹对比、位置/速度曲线及误差分析结果。 阅读详情

相关推荐

Ubuntu22.04上如何用Docker一键部署Ragflow+Ollama(附CUDA配置避坑指南)

本文详细介绍了在Ubuntu22.04系统上使用Docker一键部署Ragflow+Ollama的完整流程,特别提供了CUDA配置的避坑指南。从硬件兼容性检查、驱动安装到容器网络配置,手把手教你搭建本地化大模型环境,解决CUDA驱动冲突等常见问题,助力开发者快速构建AI应用开发平台。

weixin_26875109的博客 284

POJ 2386 Lake Counting [DFS]

POJ 2386 Lake Counting 简单的DFS,用了stack代替递归,输入有问题,搞了蛮久,算法是没问题。所以以后一定要记得加上检查输入的那一步 然后对于点的定义以后就这么办吧 此外还有stack的用法,也可以这样//POJ 2386 #include <cstdio> #include <stack> using namespace std; class Point { pub

more time 405

如何利用PREEvision和MATLAB开发AUTOSAR软件组件

在业界,比较著名的电子电气架构开发工具要属德国Vector公司开发的PREEvision工具了,而MATLAB/Simulink软件是非常高效且实用的基于模型的应用软件开发工具。利用PREEvision与Simulink联合开发AUTOSAR应用软件组件的开发流程有三种,分别是:“自上而下”开发流程(从PREEvision开始),“自下而上”开发流程(从Simulink开始),以及“双向”开发流程。如下图所示,无论哪一种开发流程,PREEvision与Simulink工具都是通过arxml文件进行信息交互的

怿星科技的博客 5396

POJ 2386 Lake Counting(dfs)

题目链接: http://poj.org/problem?id=2386 解题思路: 搜索大水题。。。 AC代码: #include #include using namespace std; int n,m; char a[110][110]; void dfs(int x,int y){ if(x=n || y=m|| a[x][y] == '.')

piaocoder 446

鸿蒙OS+UniApp文件上传实战:如何解决大文件分片上传的3大坑?

本文深入探讨鸿蒙OS与UniApp结合实现大文件分片上传的实战方案,重点解决分片策略设计、网络中断处理和进度管理三大技术难题。通过鸿蒙分布式特性与UniApp跨平台能力的结合,提供动态分片调整、断点续传和跨设备进度同步等优化方案,显著提升大文件上传成功率和用户体验。

weixin_29250403的博客 474

IEEE投稿完整流程——以IEEE Transactions on Cybernetics为例【附:论文格式模板】

前言 以下是官方的流程,包括了论文的格式和提交的流程,重要!重要!重要! 在IEEE的官网中,也有论文提交的文件 可以直接参考: 中文版: 作者指南 英文版: Manuscripts-Author-Guide 作者指南的版本指导流程可能和最新版的官网不一致!!! 或者在下面的链接中,按照你的论文类型,选择不同的论文模板: IEEE article template 以下以IEEE Transactions on Cybernetics 为例子 IEEE Transactions on Cyberne

XC___XC的博客 10万+

深度优先搜索 DFS Depth-First Search 若干数和为k POJ2386 Lake Counting

深度优先搜索(DFS,Depth-First Search):从一个状态开始,不断转移新的状态,直到无法转移,然后退回上个状态,继续转移。 例如,数独,填入一个字之后继续填下一个字,如果无解,返回前一个情况,换一个数字继续填入,反复,最终求解。 例如: 给定整数a1,a2,…,an,判断是否可以选出若干数,使它们的和为k。 int a[MAX_N]; int n, k; bool dfs(int i, int sum) { if(i == n) return sum == k; if(dfs(i +

weixin_51273276的博客 272

数字信号处理(一):Xilinx Vivado DDS IP核设计实例(文末附源码)

前言 在数字信号处理时我们经常会用到数字变频,包数字下变频(DDC)和数字上变频(DUC),这其中会用到Xilinx公司的DDS IP核或者Altera公司的NCO IP核来产生本振频率,以现数字域信号频谱搬移。本文我们通过例化Xilinx公司的DDS IP核来产生混频器本振输入频率,并给出Modelsim仿真测试结果。 1、Xilinx DDS IP简介 Xilinx公司的DDS IP核使用AX...

FPGA_Designer 1万+

POJ 2386 Lake Counting DFS初步

POJ 2386 Lake Counting DFS初步 标签(空格分隔): 算法 算法竞赛 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 ...

辣鸡的博客 290

基于Verilog的8位CPU设计及UART扩展实现方案,包含完整的架构设计、核心代码实现和仿真验证方法

基于Verilog的8位CPU设计及UART扩展实现方案,包含完整的架构设计、核心代码实现和仿真验证方法

a_zxswer的博客 190

Open-Sora代码详细解读(1):解读DiT结构

目前开源的DiT视频生成模型不是很多,Open-Sora是开发者生态最好的一个,涵盖了DiT、时空DiT、3D VAE、Rectified Flow、因果卷积等Diffusion视频生成的经典知识点。本篇博客从Open-Sora的代码出发,深入解读背后的原理。

沉迷单车的追风少年 2264

深度优先搜索 ACM-DFS:POJ 2386 Lake Counting

ACM-DFS:POJ 2386 Lake Counting题意简要概括输入输出示例数据解题思路一(失败):解题思路二(成功) 为简化文章,原题请直接看原题链接 题意简要概括 在一个字符矩阵中,字符为’W’时,表示该处有水。该’W’与其周围的八个位置相通,如下面所示。一个水潭由其包含的所有相通的’W’构成。 ... .W. ... 输入 第一行给出两个参数n和m 第二行到第n=1行:每行给出m个...

LiJgQg的博客 298

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

POJ 2386 Lake Counting

POJ 2386 Lake Counting Description Due to recent rains, water has pooled in various places in Farmer John’s field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 10...

指弹键盘哼民谣 268

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

POJ 2386 Lake Counting(DFS:求8连通分量的个数)

POJ 2386 Lake Counting(DFS:求8连通分量的个数) http://poj.org/problem?id=2386 题意:给你一个N*M的字符网格,要你求该网格中有多少个有字符’w’构造的8连通分量. 分析:直接DFS求出连通分量个数即可.之前很多题目与本题类似. AC代码: #include using namespace std; const int maxn=

code 1098

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Lake Counting(POJ No.2386) (深度优先搜索dfs)

有一个大小为 N x M 的园子,雨后积起了水。八连通的积水被认为是连接在一起的。请求出园子里总共有多少水洼?(八连通指的是下图中相对W的*部分) 限制条件 N,M<=100 输入样例(‘W’表示积水,‘.’表示没有积水) 输出样例 3 从任意W开始,不停地把邻接的‘.’用W代替,1次dfs后与该W相连的W都变成了‘.’,经历了多少次dfs就有多少个水洼。 代码如下 ...

Hermione__的博客 314

Lake Counting POJ2386 ( dfs )

Description Due to recent rains, water has pooled in various places in Farmer John’s field, which is represented by a rectangle of N x M (1 &amp;amp;lt;= N &amp;amp;lt;= 100; 1 &amp;amp;lt;= M &amp;amp;lt;= 100) squares. Each squar...

逐梦er的博客 2143

POJ2386 Lake Counting【DFS】

Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 55916 Accepted: 27265 Description Due to recent rains, water has pooled in various places in Farmer John’s field, which is represented by a...

cutlery1137的博客 334

POJ2386 Lake Counting 深搜dfs

Description: Due to recent rains, water has pooled in various places in Farmer John’s field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each squ...

匿名攻城狮 843

【ACM】【DFS】【水】POJ 2386 Lake Counting

Lake Counting 点我前往题目页面 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 49820 Accepted: 24452 Description Due to recent rains, water has pooled in various places in Fa...

lesileqin的博客 236

Lake Counting/POJ 2386/DFS

Lake Counting/POJ 2386/DFS 题目 Due to recent rains, water has pooled in various places in Farmer John’s field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) sq...

weixin_45600829的博客 160

【POJ 2386 --- Lake Counting】DFS

【POJ 2386 --- Lake Counting】DFS Description Due to recent rains, water has pooled in various places in Farmer John’s field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M...

来日浅谈的博客 514

POJ2386 Lake Counting 【DFS】

Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20782   Accepted: 10473 Description Due to recent rains, water has pooled in various places i

长风的专栏 1846

poj 2386  Lake Counting DFS

n*m的矩阵W是水  .是地问有多少池塘池塘的定义是:W通过 八个 方向连接成的一片算作是一个池塘样例输入中,有左上、左下、右侧三片连接在一起的W因而样例输出给出了3个池塘的答案 #include <cstdio> #include <iostream> #define N 110 using namespace std; int n,m; cha...

ailincheng0815的博客 144

poj2386 Lake Counting DFS

Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either water

ccsu_cherish 607

dfs Lake Counting POJ 2386

有一个大小为N*M的园子,雨后积水。八连通的积水被认为是连接在一起的。请求出园子里总共有多少水洼?(八连通指的是下图中相对W的*的部分) * * * * W * * * * 限制条件: N,M<=100 思路:从任意的W开始,不停地把邻接的部分用 '.' 代替,一次DFS后与初始的这个W八连通的所有W就都被替换成了 '.',因此直到图中不再存在W为止,总共进行DFS的次数...

冲冲冲 161

POJ2386 Lake Counting简单dfs

Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 36918   Accepted: 18352 Description Due to recent rains, water has pooled in various places in

Low Coder的博客 322
上一篇: NYOJ - 蚂蚁的难题(二)(dp)
下一篇: NYOJ - 最少步数【BFS】
SevenMIT
博客等级 码龄15年 60粉丝 162原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值