864F(tarjan思想)

AltiumDesigner.zip 立即下载
F. Cities Excursions
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There are n cities in Berland. Some pairs of them are connected with m directed roads. One can use only these roads to move from one city to another. There are no roads that connect a city to itself. For each pair of cities (x, y) there is at most one road from x to y.

A path from city s to city t is a sequence of cities p1, p2, ... , pk, where p1 = s, pk = t, and there is a road from city pi to city pi + 1 for each i from 1 to k - 1. The path can pass multiple times through each city except t. It can't pass through t more than once.

A path p from s to t is ideal if it is the lexicographically minimal such path. In other words, p is ideal path from s to t if for any other path qfrom s to t pi < qi, where i is the minimum integer such that pi ≠ qi.

There is a tourist agency in the country that offers q unusual excursions: the j-th excursion starts at city sj and ends in city tj.

For each pair sj, tj help the agency to study the ideal path from sj to tj. Note that it is possible that there is no ideal path from sj to tj. This is possible due to two reasons:

  • there is no path from sj to tj;
  • there are paths from sj to tj, but for every such path p there is another path q from sj to tj, such that pi > qi, where i is the minimum integer for which pi ≠ qi.

The agency would like to know for the ideal path from sj to tj the kj-th city in that path (on the way from sj to tj).

For each triple sj, tj, kj (1 ≤ j ≤ q) find if there is an ideal path from sj to tj and print the kj-th city in that path, if there is any.

Input

The first line contains three integers n, m and q (2 ≤ n ≤ 3000,0 ≤ m ≤ 3000, 1 ≤ q ≤ 4·105) — the number of cities, the number of roads and the number of excursions.

Each of the next m lines contains two integers xi and yi (1 ≤ xi, yi ≤ n, xi ≠ yi), denoting that the i-th road goes from city xi to city yi. All roads are one-directional. There can't be more than one road in each direction between two cities.

Each of the next q lines contains three integers sj, tj and kj (1 ≤ sj, tj ≤ n, sj ≠ tj, 1 ≤ kj ≤ 3000).

Output

In the j-th line print the city that is the kj-th in the ideal path from sj to tj. If there is no ideal path from sj to tj, or the integer kj is greater than the length of this path, print the string '-1' (without quotes) in the j-th line.

Example
input
7 7 5
1 2
2 3
1 3
3 4
4 5
5 3
4 6
1 4 2
2 6 1
1 7 3
1 3 2
1 3 5
output
2
-1
-1
2
-1
解题思路:这题比较巧妙,假设没有环的情况,我们可以直接dfs得到答案复杂度为O(n * n),可以接受,但是现在回出现环的情况,这种情况会导致后面的点都是无解的,这时候我们用tarjan思想就行,我们令low[v]为无穷大,如果出现dfn[v] >= low[v]说明出现了环,这是后面dfs到的点都是无解,反之没有环。我是参考这个人的思路:http://blog.youkuaiyun.com/weixin_37517391/article/details/78105828?locationNum=2&fps=1
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3000 + 10;
int inf = 0x3f3f3f3f;
int n, m, q;
int ans[400010];
int num[maxn];
int Instack[maxn];
int dfn[maxn];
int low[maxn];
int tot;
vector<int> edge[maxn];
struct query{
    int s, t, k, id;
}Query[400010];
vector<int> temp[maxn];
vector<int> S[maxn];
void init()
{
    for(int i = 1; i <= n; i++)
    {
        edge[i].clear();
        S[i].clear();
    }
    memset(ans, -1, sizeof(ans));

}
void dfs(int u, int status, int depth)
{
     dfn[u] = ++tot;
     low[u] = inf;
     Instack[u] = 1;
     num[depth] = u;
     if(status)
     {
         for(int i = 0; i < temp[u].size(); i++)
         {
             int loc = temp[u][i];
             int id = Query[loc].id;
             int kk = Query[loc].k;
             if(kk <= depth) ans[id] = num[kk];
         }
     }
     for(int i = 0; i < edge[u].size(); i++)
     {
         int v = edge[u][i];
         if(dfn[v] == 0)
         {
             dfs(v, status && dfn[u] < low[u], depth + 1);
             low[u] = min(low[u], low[v]);
         }
         else if(Instack[v] == 1)
         {
             low[u] = min(low[u], dfn[v]);
         }
     }
     Instack[u] = 0;
}
int main()
{
    while(~scanf("%d%d%d", &n, &m, &q))
    {
        init();
        int u, v;
        for(int i = 1; i <= m; i++)
        {
            scanf("%d%d", &u, &v);
            edge[u].push_back(v);
        }
        for(int i = 1; i <= n; i++)
        {
            sort(edge[i].begin(), edge[i].end());
        }
        int s, t, k;
        for(int i = 1; i <= q; i++)
        {
            scanf("%d%d%d", &s, &t, &k);
            Query[i].s = s;
            Query[i].t = t;
            Query[i].k = k;
            Query[i].id = i;
            S[s].push_back(i);
        }
        for(int i = 1; i <= n; i++)
        {
            memset(dfn, 0, sizeof(dfn));
            memset(Instack, 0, sizeof(Instack));
            for(int j = 1; j <= n; j++) temp[j].clear();
            for(int j = 0; j < S[i].size(); j++)
            {
                int loc = S[i][j];
                int tt = Query[loc].t;
                temp[tt].push_back(loc);
            }
            tot = 0;
            dfs(i, 1, 1);
        }
        for(int i = 1; i <= q; i++) printf("%d\n", ans[i]);
    }
    return 0;
}



YOLO26算法日历数字识别+训练好的模型+102张数据集+pyqt可视化界面.zip 附训练好的 YOLO 权重与 PyQt 可视化检测界面,页面底部含可视化效果预览,毕设/课设开箱即用。 【数据集概况】 · 检测类别(中文):[数字(number)] 【训练曲线与评估图】 【模型训练配置】 参数 | 值 模型 | yolo26n 训练轮数 | 100 epochs 输入尺寸 | 640x640 批次大小 | 24 优化器 | auto 初始学习率 | 0.01 训练设备 【关键指标汇总】 训练了 97 个 epoch,最终轮指标: 指标 | 数值 mAP50 | **0.9156** mAP50-95 | 0.7374 Precision | 0.8626 Recall | 0.8381 train/box_loss | 0.8790 train/cls_loss | 0.7499 val/box_loss | 0.7874 val/cls_loss | 0.6025 【训练过程分析】 训练开始后,我注意到前几轮的 loss 下降特别快,这让我有点兴奋,但随着训练的深入,loss 的降幅变得不那么明显了。在训练的第 30 轮左右,val_loss 开始趋于平稳,这让我稍微放心了一些,但同时也感觉压力倍增,因为一旦训练过早平稳,就容易陷入过拟合的泥沼。经过 97 轮的磨炼,最终 mAP50 达到了 0.9156,这让我松了一口气。不过,mAP50-95 仅有 0.7374,和 mAP50 之间有明显的差距,说明模型在低置信度的检测上还需要优化。从 loss 曲线来看,训练过程总体上比较平稳,没有明显的过拟合迹象,但也让人觉得有些枯燥。我心想,要是能早点找到一个陡峭上升的训练曲线该有多好,这样至少能让人心态更积极一些。 随着训练进行到后半段,模型开始逐渐收敛,但这个过程并不是一帆风顺的。在训... 使用场景:毕业设计、课程设计、深度学习入门、工业场景落地验证。 立即下载

相关推荐

风储VSG-基于虚拟同步发电机的风储并网系统Simulink仿真

内容概要:本文介绍了“Plecs全桥LLC谐振变换器仿真模型”这一技术资源,聚焦于隔离型全桥LLC谐振变换器的建模、仿真与参数设计,涵盖其在电力电子系统中的关键应用,如软启动、闭环控制、变频控制及效率优化等。该模型支持对LLC变换器在不同工作模式下的动态响应与性能表现进行深入研究,适用于探究谐振拓扑结构、磁性元件设计、谐振参数匹配以及先进控制策略的科研与工程实践。同时,文档配套提供了仿真模型、设计报告与计算书等完整资料,强化了其实用性与教学价值。; 适合人群:具备电力电子、自动化或电气工程等相关专业背景,从事电力电子变换器研发、系统仿真与控制算法设计的科研人员、工程师及研究生。; 使用场景及目标:①用于全桥LLC谐振变换器的建模、仿真与动态性能分析;②支持对软启动过程、闭环稳压控制、变频调谐及效率优化等核心技术的研究与教学;③为电力电子电源系统的工程设计、参数优化与控制策略验证提供高精度仿真平台。; 阅读建议:建议结合Plecs或Simulink等仿真工具进行动手实践,重点理解电路拓扑构建、谐振参数计算、控制器设计与系统稳定性分析,并配合文档中的设计报告与计算书,系统掌握从理论到仿真的完整流程。

codeforces 864 F

有向图,倍增。 思路:参考大佬的题解 倍增思想,比如求s到t的道路,那么先通过反向图dfs出所有可以到达t的节点。(相当于一棵树)如果s不在其中,输出-1.然后先用正向图的边把st数组初始化一下(用字典序最小的一个)。然后把st[t][0]置为n+1.其他剩余点都保持为0.然后在倍增完成后,如果st[ s ][ TOP ] ==n+1说明x最终可以到达t并且继续走到n+1.(2^TOP>3000

樱花满地集于我心,楪舞纷飞祈愿相随 347

国央企创新负责人如何通过平台实现科技创新资源的系统集成与高效配置?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

图的连通性问题之tarjan算法

Tarjan算法一种由Robert Tarjan提出的求解有向图强连通分量的线性时间的算法。 Tarjan算法是基于对图深度优先搜索的算法,每个强连通分量为搜索树中的一棵子树。搜索时,把当前搜索树中未处理的节点加入一个堆栈,回溯时可以判断栈顶到栈中的节点是否为一个强连通分量。 定义dfn(u)为节点u搜索的次序编号,low(u)为u或u的子树能够追溯到的最早的栈中节点的次序号。 当dfn(u)

cax1165 2811

独立储能的现货电能量与调频辅助服务市场出清协调机制(Matlab代码实现)

内容概要:本文介绍了“Plecs全桥LLC谐振变换器仿真模型”这一技术资源,聚焦于全桥LLC谐振变换器在电力电子系统中的建模与仿真研究。该资源提供了基于Plecs平台的高精度仿真模型,完整呈现了变换器的主电路拓扑、谐振参数设计、软开关实现机制及变频控制策略,能够有效支持对系统效率、动态响应与稳态性能的深入分析。模型充分体现了LLC谐振变换器在实现零电压开关(ZVS)、降低开关损耗和提升能量转换效率方面的优势,适用于新能源发电、储能系统及高效率电源设计等应用场景。; 适合人群:具备电力电子、自动控制及电路理论基础知识,从事电力电子变换器设计、新能源系统开发或相关领域研究的研究生、高校教师及工程技术人员。; 使用场景及目标:①用于全桥LLC谐振变换器的工作原理教学与参数设计实践;②支撑软开关特性、变频控制策略、效率优化等关键技术的仿真验证与性能评估;③作为科研项目、课程设计或毕业设计中电力电子系统仿真的核心参考模型,促进理论与工程实践的结合。; 阅读建议:建议使用者在掌握LLC谐振变换器基本工作原理的基础上,结合相关电力电子教材与Plecs软件操作指南,通过调整谐振元件参数、负载条件及控制策略进行多工况仿真,深入理解其工作机理与优化方法,并结合实验数据对比验证仿真结果的准确性。

深入解析数据通信中的码元速率与比特率:从基础到实战应用

本文深入解析了数据通信中的核心概念码元速率与比特率,通过生动的比喻和公式(比特率=波特率×log₂(M))揭示其本质关系。文章结合BPSK、QPSK、16QAM等调制技术,剖析了从4G/5G到LoRa等实战场景中如何权衡速率、距离与可靠性,并提供了软考真题解析与系统设计建议,帮助读者从理论到应用全面掌握数据速率优化。

weixin_29324877的博客 213

Tarjan算法详解

       在有向图G中,如果两个顶点间至少存在一条路径,称两个顶点强连通(strongly connected)。如果有向图G的每两个顶点都强连通,称G是一个强连通图。非强连通图有向图的极大强连通子图,称为强连通分量(strongly connected components)。如下图中,强连通分量有:{1,2,3,4},{5},{6}       Tarjan算法是基于对图深度优先搜索的算法...

刘伟的博客 1万+

spdk + fio测试nvme 设备的性能

fio的测试对象可以是块设备、文件等,在spdk的使用过程中会unbind默认的nvme driver,所以在系统中是看不到nvme块设备的,在spdk中可以通过fio_plugin的方式,将spdk的用户态driver部分的io功能打包成一个ioengine提供给fio使用,可以综合spdk的高性能和fio提供的复杂场景。更多DPDK相关学习资料有需要的可以自行报名学习,免费订阅,永久学习,或点击这里加。这个jobfile是spdk中提供的例子。领取,关注我持续更新哦!2.7 jobfile的例子。

lingshengxiyou的博客 1089

最近公共祖先LCA问题(特别是Tarjin算法) 转

【白话系列】最近公共祖先 分类: 白话系列 |2012-11-14 08:07 |274人阅读 【序言】         说到最近公共祖先,应该是树论中一个比较重要的话题吧。一般来说,在遇到求最近公共祖先的时候,会有三种常见的做法:对于简单的模拟题——直接模拟就好了;对于大题目中的求最近公共祖先的小桥段——用tarjan来求,因为好打不容易错;对于特意考察最近公共祖先,并且数

yujiazhen1991的专栏 932

pytorch转onnx转paddlepaddle

1.pt转onnx 可查看我之前的文章:https://blog.youkuaiyun.com/oyjwin/article/details/117778583?spm=1001.2014.3001.5501

oyjwin的博客 1461

中国1990-2021连续30年土地利用CLCD数据分享

CLCD(China Land Cover Dataset)数据集是由武汉大学黄昕老师基于Google Earth Engine上的335,709景Landsat数据制作的中国年度土地覆盖数据集。为了提高CLCD的时空一致性,还提出了一种包含时空滤波和逻辑推理的后处理方法。该数据集最大的优势在于每年30米的土地利用分类结果,且连续覆盖了30年时间。相比其他产品如GLC_FCS30、Global30、AGLC2000_2015、FROM-GLC10、ESA10、ESRI10等,CLCD在时间分辨率上更高。

qq_48539301的博客 1万+

求强连通分量的双DFS,Tarjan和Gobow算法详解

1.强连通分量-----双DFS算法 思想:对一个有向图作两遍DFS,第一遍DFS能确定图中每个顶点的DFS完成时间,第二遍DFS从第一遍DFS完成时间的逆序开始遍历,这时得到的一棵棵深度优先搜索树就是一个个对应的强连通分量。 举例: 对于下面这个有向图,我们以C为源节点进行第一遍DFS,可以得到每一个顶点的 (访问时间/完成时间).也就是我们能得到顶点DFS完成时间,逆序为:b->e-

记录每一个小阶段的学习心得,持之以恒! 2296

WSL2下用QEMU模拟ARM开发板:从编译uboot到调试全流程(附常见错误解决)

本文详细介绍了在WSL2环境下使用QEMU模拟ARM开发板的完整流程,包括uboot编译、内核调试等关键步骤。通过QEMU模拟vexpress-a9开发板,开发者可以高效搭建嵌入式开发环境,解决常见错误并提升开发效率。

solidity8miner的博客 286

codeforces864F Cities Excursions 图论,tarjan算法的应用

F. Cities Excursions time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n cities in Berland. Some pa

SUNSET 805

SAP-ABAP:在SAP系统中,COEP表(成本控制对象行项目表)详解

在SAP系统中,COEP表(成本控制对象行项目表)详解

baidu_35680696的博客 1840

012、乘累加单元(MAC):NPU中最基本的计算单元

本文深入剖析了神经网络处理器(NPU)中的核心计算单元——乘累加单元(MAC)。作者通过实际调试案例揭示了MAC单元设计中的关键问题:定点数格式对齐、累加器位宽陷阱、流水线优化和多MAC同步方案。重点讨论了INT8量化中的边界条件处理、偏置项截断风险以及零值检测等实战经验,并提供了三点实用建议:建立精确的C模型、参考RISC-V P扩展指令集、仔细审查芯片规格书。文章强调硬件加速的实际瓶颈往往在于数据搬运而非计算单元本身,为NPU开发者提供了宝贵的工程实践参考。

m0_50546716的博客 298

codeforces864F Cities Excursions

F. Cities Excursionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities in Berland. Some pairs of them are connected with m directe...

qq_41510496的博客 246

2025_NIPS_RAGRouter: Learning to Route Queries to Multiple Retrieval-Augmented Language Models

该研究聚焦检索增强生成(RAG)场景下的大语言模型(LLM)路由问题,提出了首个RAG感知的路由框架RAGRouter。核心解决现有路由方法依赖静态参数知识、忽略检索文档动态影响的缺陷,通过融合文档嵌入、RAG能力嵌入与对比学习,捕捉RAG引发的模型知识表征变化,为每个查询-文档对选择最优LLM。实验覆盖5个知识密集型任务、15个开源/闭源LLM,验证了RAGRouter在性能上超越最佳单LLM和非RAG感知路由方法,且通过阈值机制实现低延迟约束下的性能-效率平衡。

UnknownBody_2的博客 273

Codeforces Round 864F (Codeforces Round #436 Div. 2) F. Cities Excursions tarjan判环

F. Cities Excursions time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n cities in Berland. Some pa

J. Cole 570

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Codeforces 864F Cities Excursions(离线处理+Tarjan)

F. Cities Excursions time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output There are n cities in Berland. Some pairs of them are connected with

yasolx的博客 856

深度学习工具包 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")

codeforces 864F 图论

题意:n个节点的有向图,无重边,无自环。 对于一条从s->t的路径,除了t其他城市都可以被游览多次。理想路径是一条路径从s到t的字典序最小路径。q次询问,每次给出一个si,tis_i, t_i。问从sis_i到tit_i的字典序最小的路径的第k个节点是什么。 可能不存在从sis_i到tit_i的字典序最小路径,当且仅当有以下两种情况。 1.1.没有从sis_i到tit_i的路径。 2.2.为

即使摸爬滚打,满身泥泞,我也要前进 421

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

cf 864 F. Cities Excursions

F. Cities Excursions There are n cities in Berland. Some pairs of them are connected with m directed roads. One can use only these roads to move from one city to another. There are no roads tha...

weixin_30615767的博客 142

Codeforces Round #436 (Div. 2) F. Cities Excursions 字典序dfs+Tarjan判环

题目链接:Cities Excursions 题意:给你一个有向图,问任意两点间的字典序最小路径(如果存在)上的第k个节点是啥。 解法:提前存储好每个点能直接到达的点,并排序,因为这样遍历就是字典序的遍历。提前存储好q个询问,对q的f按从小到大排序,每次对f相同的询问做dfs,起始点是f,提前把起始点是f的询问用vector保存下来,这样在做dfs的过程中,一次性把具有共同起点的这部分询问给得出

ganzibang 593

套题T6

过节(festival.cpp/c/pas) Dxy帮老师们过教师节的时候需要购买礼物。货架上有n 种礼物,每种礼物有不同的个数。每种礼物有价值和花费两种属性,帮他算出最大可以得到的价值。M是带的钱数有多少 Input: 第一行两个数n,m 第2到n+1行:每行三个数a,b,c,表示一种礼物的个数,花费和价值。 Output: 最大可得价值。 样例输入: 1 1 1...

weixin_34245082的博客 306

强连通性Tarjan算法和LCA

其实tarjan算法提出的思想就是DFS深度优先遍历,在遍历的过程中记录某些变量的值,来解决相关问题,下面两个经典的问题都能通过tarjan的思想去解决。在此表达对Robert Tarjan的崇高敬意。连通基础思想就是通过DFS,在深度优先遍历的过程中,记录每个节点上对应的值,在编程中我们需要记录的每个节点的值有DFN(访问的次序),inStack(是否在栈中,引入的栈是做什么的,下面会演示),LO

selous的专栏 1586

最小生成树总结

一.最小生成树问题 给定一张图,图中有许多的节点还有许多长度不同的边将这些点点相互连接,找出连接所有点的最短方式就是最小生成树,可以证明,这样一种最小的情况是不会出现环的,由于所有的无环图都可以看做树,所以成为最小生成树。 二.kruskal算法 顶层思想是分治,选择策略是贪心,实现方法如下:以边为中心,先将所有的边从小到大进行排序,之后依照大小顺序依次选择,如果这条边连接的两个节点是不连通

Coldplay 2004
上一篇: UESTC1722(二分)
下一篇: POJ3436(最大流)
creatorx
博客等级 码龄10年 127粉丝 145原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值