Mistwald ZOJ - 3497 (矩阵快速幂)

SPD5 集线器协议内容解析 ​ 若不同SPD5 Hub后面的本地侧设备同时发送请求,则是22和23、24的混合过程,先通过LID裁决,再通过HID裁决,这里的LID是本地设备的,若LID一致,则看HID,由于SPD5 Hub的本地侧设备HID均为111,因此实际上是比较SPD5 Hub的HID,这个过程在前文提到,SPD5 Hub会转换HID。​ 若MR27[4]=1且MR27[3:0]=1,如果MR51[3:0]=1时,发送IBI,并且MR48[7]置1,将GETSTATUS CCC的待处理中断位[3:0]更新为0001。 阅读详情

Mistwald

ZOJ - 3497

In chapter 4 of the game Trails in the Sky SC, Estelle Bright and her friends are crossing Mistwald to meet their final enemy, Lucciola.

Mistwald is a mysterious place. It consists of M * N scenes, named Scene (1, 1) to Scene (M, N). Estelle Bright and her friends are initially at Scene (1, 1), the entering scene. They should leave Mistwald from Scene (M, N), the exiting scene. Note that once they reach the exiting scene, they leave Mistwald and cannot come back. A scene in Mistwald has four exits, north, west, south, and east ones. These exits are controlled by Lucciola. They may not lead to adjacent scenes. However, an exit can and must lead to one scene in Mistwald.

Estelle Bright and her friends walk very fast. It only takes them 1 second to cross an exit, leaving a scene and entering a new scene. Other time such as staying and resting can be ignored. It is obvious that the quicker they leave Mistwald, the better.

Now you are competing with your roommate for who uses less time to leave Mistwald. Your roommate says that he only uses P seconds. It is known that he lies from time to time. Thus, you may want to code and find out whether it is a lie.


Input

There are multiple test cases. The first line of input is an integer T ≈ 10 indicating the number of test cases.

Each test case begins with a line of two integers M and N (1 ≤ M, N ≤ 5), separated by a single space, indicating the size of Mistwald. In the next M lines, the ith line contains N pieces of scene information, separated by spaces, describing Scene (i, 1) to Scene (i, N). A scene description has the form "((x1,y1),(x2,y2),(x3,y3),(x4,y4))" (1 ≤ xk ≤ M; 1 ≤ yk ≤ N; 1 ≤ k ≤ 4) indicating the locations of new scenes the four exits lead to. The following line contains an integer Q (1 ≤ Q ≤ 100). In the next Q lines, each line contains an integer P (0 ≤ P ≤ 100,000,000), which is the time your roommate tells you.

Test cases are separated by a blank line.

Output

For each P, output one of the following strings in one line: "True" if it cannot be a lie; "Maybe" if it can be a lie; "False" if it must be a lie.

Print a blank line after each case.

Sample Input
2
3 2
((3,1),(3,2),(1,2),(2,1)) ((3,1),(3,1),(3,1),(3,1))
((2,1),(2,1),(2,1),(2,2)) ((3,2),(3,2),(3,2),(3,2))
((3,1),(3,1),(3,1),(3,1)) ((3,2),(3,2),(3,2),(1,1))
3
1
2
10

2 1
((2,1),(2,1),(2,1),(2,1))
((2,1),(2,1),(2,1),(2,1))
2
1
2
Sample Output
Maybe
False
Maybe

True
False


题意:

给定一个有向图(最多25个节点,每个节点的出度最多为4),给定起点和终点,然后从起点开始走,走到终点就停止,否则一直往下走,问能不能P步到达终点。也就是说从起点出发,走一条长度为P的路径,路径中间点不能经过终点(但可以反复经过其他点)。如果从起点出发P步后,不能到达终点,就是False,如果可以到达终点也可以到其他别的点,就是Maybe,如果P步后只能到达终点(到别的点没有长度为P的路径),则是Yes。


思路:一开始就老想着搜索了,但是搜索还不知如何下手,然后看了网上题解才恍然大悟,如果大家学过离散数学的话,这个题实际上就是让我们求某个点到某个点的多步可达路径,而求多步可达路径就是矩阵的幂,也就是传递。

所以我们把所给的矩阵位置每个点按1-m*n表好号,然后就相当于每个点可以通向四个点,有向路径,然后用邻接矩阵存下来,接下来用矩阵快速幂求解就可以了。

code:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
struct Matrix
{
    LL  m[50][50];
} I, A, B;
int ssize;
Matrix Mul(Matrix a,Matrix b)
{
    int i, j, k;
    Matrix c;
    for(i = 1; i <= ssize; i++)
    {
        for(j = 1; j <= ssize; j++)
        {
            c.m[i][j]=0;
            for(k = 1; k <= ssize; k++)
            {
                c.m[i][j]+=(a.m[i][k]*b.m[k][j]);
            }
        }
    }
    return c;
}

Matrix quickpagow(LL n)
{
    Matrix m = A, b = I;
    while(n)
    {
        if(n & 1)
            b = Mul(b,m);
        n = n >> 1;
        m = Mul(m,m);
    }
    return b;
}

int main()
{
    int t;
    int N, M;
    scanf("%d",&t);
    while(t--)
    {
        memset(I.m,0,sizeof(I.m));
        memset(A.m,0,sizeof(A.m));
        memset(B.m,0,sizeof(B.m));
        scanf("%d%d",&N,&M);
        getchar();

        int T = N*M;
        for(int i = 1; i <= T; i++)
        {
            I.m[i][i] = 1;
        }
        int x1, y1, x2, y2, x3, y3, x4, y4;
        for(int i = 1; i <= N; i++)
            for(int j = 1; j <= M; j++)
            {
                scanf("((%d,%d),(%d,%d),(%d,%d),(%d,%d))",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
                getchar();
                if(i==N && j==M)//图中路径不能经过终点
                    continue;
                A.m[(i-1)*M+j][(x1-1)*M+y1]=1;
                A.m[(i-1)*M+j][(x2-1)*M+y2]=1;
                A.m[(i-1)*M+j][(x3-1)*M+y3]=1;
                A.m[(i-1)*M+j][(x4-1)*M+y4]=1;
            }
        ssize = T;
        int q, p;
        scanf("%d",&q);
        while(q--)
        {
            scanf("%d",&p);
            B = quickpagow(p);
            if(B.m[1][T]==0)
                printf("False\n");
            else
            {
                int flag = 0;
                for(int i = 1; i < T; i++)
                {
                    if(B.m[1][i])
                    {
                        flag = 1;
                        break;
                    }
                }
                if(!flag)
                    printf("True\n");
                else//  恰好P步 既能到达终点又能到达其他点
                    printf("Maybe\n");
            }
        }
        printf("\n");
    }
    return 0;
}


YOLOv12改进策略【卷积层】| CVPR-2020 利用DynamicConv 动态卷积 结合A2C2f进行二次创新,提高精度 在大规模视觉预训练中,通常模型的性能受到数据、参数和FLOP三个关键因素的影响。一般来说,模型的参数数量越多,FLOP也越高,但在移动设备等对计算资源有限制的场景下,需要低FLOP的模型同时又希望模型能从大规模预训练中受益。传统的方法很难在增加参数的同时保持低FLOP,因此需要一种新的设计来解决这个问题,模块应运而生。 阅读详情

相关推荐

《Ventoy 制作系统安装 U 盘的具体步骤》

然后您可以在电脑的磁盘管理中对 U 盘进行快速格式化,选择 FAT32 或 NTFS 文件系统。至此,Ventoy 系统安装 U 盘就制作完成了。您可以在需要安装系统的电脑上,从 U 盘启动,然后选择相应的系统镜像进行安装。安装完成后,将您需要的操作系统镜像文件(如 Windows、Linux 等的 ISO 格式镜像)复制到 U 盘的根目录。在安装程序中,选择您插入的 U 盘设备,确保选择正确,以免误操作。2. 确认选择的 U 盘盘符正确,防止误操作导致其他磁盘数据丢失。点击“安装”按钮,等待安装完成。

jiyiwangluokeji的博客 2664

Hello!YZOJ!(YZOJ-1000)

【问题描述】 经过超 200h 废寝忘食的连续奋战,YZOJ 3.0 终于在2021年3月28号正式和大家见面了,在此感谢cc、ww、zhb在YZOJ的二次开发过程中给予的帮助与支持。 这是你第一次与 YZOJ 得见面,请你输出如下两行字符串(任何一个字符都不能错漏哦): Hello! YZOJ! 【输出格式】 两行字符串 【样例输出】 Hello! YZOJ! 【参考程序】 #include<bits/stdc++.h> using namespace std; int main() {

以太以北 551

Windows下Maven环境变量配置避坑指南:解决‘mvn‘不被识别问题

本文详细解析了Windows系统中配置Maven环境变量时常见的'mvn'不被识别问题,特别是当系统提示“无法将‘mvn’项识别为cmdlet、函数、脚本文件或可运行程序的名称”时的解决方案。文章从问题根源入手,提供了清晰的配置步骤、深入的排查方法以及针对PowerShell的特殊处理,旨在帮助开发者彻底解决环境变量配置难题,确保Maven命令正常使用。

weixin_28826961的博客 389

ZOJ - 3497 Mistwald(离散数学)

题意:一张n*m的图,告诉你每一个点可以到达哪4个点,然后给出一个p,问从(1,1)出发P步之后,是否能到达(n,m),如果一定能达,输出true,如果可能到达输出maybe,如果不能到达,输出false思路:我们可以给每一个点编号0 - n * m - 1,再建立一个邻接矩阵A,这样就是求0是否能到达n * m - 1,离散数学曾学过这样一个性质,A的p方得到的邻接矩阵,aij表示从i到j有多少...

GYH0730的博客 340

给麒麟KylinOS服务器加把锁:手把手配置符合等保要求的密码强度策略

本文详细介绍了如何在麒麟KylinOS服务器上配置符合等保要求的密码强度策略,包括pwquality.conf和login.defs的核心参数设置、等保合规的进阶配置技巧以及企业环境中的平衡艺术。通过实战案例和测试方法,帮助管理员构建坚固的密码防线,确保系统安全。

weixin_33749242的博客 417

【Allegro学习笔记】常规标贴封装创建-0402封装创建实例

摘要 本文主要介绍如何使用Allegro制作表面贴装封装。 所使用的软件 使用Allegro制作常规贴片封装主要使用的软件有Pad Designer和Allegro 1 0402类封装制作 1.1 0402类封装焊盘分析 0402封装尺寸图如图1...

Honglong 1万+

zoj-3497-Mistwald-矩阵

题意:有一个n*m的矩阵,矩阵上每一个格子有四个传送门,分别通向四个格子,题目给出了每个格子的四个传送门所能到达的地方。起点在(1,1),终点是(n,m),当走到终点的时候就不能再走了,也就是说一旦你到达了终点,就会直接离开这个矩阵。问说从起点开始走P(0 ≤ P ≤ 100,000,000)步能不能到达终点。 输出的情况是True,Maybe和False。Ture对应的就是走了P步以后只能

青竹梦 1657

55、磁吸附爬壁机器人运动仿真与位置控制

本文针对大型船舶喷涂作业中人工操作存在的高风险与低效率问题,提出一种基于麦克纳姆轮的磁吸附爬壁机器人运动控制方案。通过建立Adams虚拟样机与MATLAB/Simulink控制系统的联合仿真模型,设计了速度和位置双闭环控制系统,采用模糊PI控制器优化速度响应,并引入位置反馈补偿重力引起的垂直偏移。研究结果表明,模糊PI控制器在响应速度、超调抑制和位置稳定性方面优于传统PI控制器,且位置反馈能有效校正横向移动中的下坠现象,尤其在跨越焊缝等复杂工况下仍可保持稳定运行,显著提升了爬壁机器人的运动精度与作业可靠性。

linux6sysadmin的博客 167

Mistwald(ZOJ3479)

原文链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3497 给出n*m个点,然后每个点会往其他的点移动,然后给定移动的方向点。求判断,在规定步数下,一定能到达终点输出true,不一定就maybe,否则就False。 把n*m个点离散化,然后给定的点到点就相当于在一个(n*m)*(n*m)的图中建立连接,然后对

Linnnnnger的博客 419

【RT-DETR有效改进】全新的SOATA轻量化下采样操作ADown(轻量又涨点,附手撕结构图)

本文给大家带来的改进机制是利用2024/02/21号最新发布的YOLOv9其中提出的ADown模块来改进我们的Conv模块,其中YOLOv9针对于这个模块并没有介绍,只是在其项目文件中用到了,我将其整理出来用于我们的YOLOv8的项目,经过实验我发现该卷积模块(作为下采样模块)首先可以大幅度降低参数值,其次其精度上也有很高的提升,同时本文的内容目前网络上并无其它人总结(也是最新发布的,可以说BUff是集满了)大家可以尝试以下在自己数据集上的效果。

Snu77的博客 4768

【华为OD机试真题 2025C卷】895、贪心歌手 | 机试真题+思路参考+代码解析 (C++、Java、Py、C语言、JS)

【华为OD机试真题 2025C卷】895、贪心歌手 | 机试真题+思路参考+代码解析 (C++、Java、Py、C语言、JS) 华为od机试,华为od机试真题,华为od机试E卷,华为odE卷,华为od机试真题E卷,华为OD,华为OD机试,华为OD机试真题,华为od机考,华为od机试D卷,华为od机试真题D卷,华为od手撕代码,华为od,华为od机试C卷,华为od e卷,华为2025e卷,od机试,2025E卷,华为OD机试E卷,什么是华为od,华为od介绍,全面了解华为od,2025华为od,如何备战华

KJ.JK 961

ZOJ 3497 Mistwald

这道题是浙江省赛的中档题,虽然在同步赛上做了很长时间,依然没有坐出来。后来嵩哥说是矩阵乘法+log(p),二分我还知道点,矩阵乘法就知之甚少了,然后这两天做了几个矩阵乘法的水题,算是有点了解了。 这道题给了一个有向图,每个节点出度最多为4,规定起点(1,1),终点(m,n),问能否在p步内到达,注意中间节点不能经过终点。p步后,如果只能到达终点,则输出“True”,不能到达输出“False”,其

七里的专栏 1710

set_input_delay/set_output_delay介绍

针对这一类的情况,在做block时,cts之后,便需要将update_io_latency给关闭。那么,计算的timing就是错误的了。对于hier flow来讲,切分block,进行timing budget的时候,clock tree还未长。计算block端口上的timing,通常需要用到set_input_delay和set_output_delay告知工具外部电路的延迟信息,以方便工具计算端口上的timing。此时,工具在计算in2reg的timing时,便会将2.67ns的delay带进来。

芯冰乐 317

zoj 3497 Mistwald 矩阵快速幂

知道了矩阵的新作用,矩阵A^P,A[i][j]的数值是从i到j长度为P的路径条数,矩阵相乘如果A[i][k为1,B[k][j]为1,A[i][j] 必然>=1,表明以k为桥梁将i和j连接起来,和floyd算法本质上是一致的。 传送门:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4320 #include #incl

NM的专栏 452

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

ZOJ 3497 Mistwald【矩阵快速幂】【图论】

题目链接http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4320思路题意是给你一张图,起点是1,终点是m*n,一旦走到终点就立马停止不能再走了,问你可不能正好P步到达终点。可能输出maybe,一定输出true,不可能输出false。这里要用到离散数学的一个定理,就是一张图的邻接矩阵A,P次方后得到的邻接矩阵APA^P 中的元素ai

初涉_代码世界 820

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Mistwald( ZOJ - 3497,这也能用矩阵快速幂?!)

一.题目链接: ZOJ-3497 二.题目大意: m × n 的图. 起点为 (1, 1),终点为(m,n). 给出每个点的四个去处. 然后 Q 次询问 每次有一个整数 p 代表移动次数. p 次移动后 if 不能到达终点,则输出 "False". else if 只能移动到终点,则输出"True" else 输出"Maybe" 三.分析: 本以为是个暴搜,结果是只披着搜...

The___Flash的博客 199

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

ZOJ 3497 Mistwald(矩阵快速幂)

题目: Mistwald Time Limit: 2 Seconds      Memory Limit: 65536 KB In chapter 4 of the game Trails in the Sky SC, Estelle Bright and her friends are crossing Mistwald to meet their final ene

hexiecs的技术专栏 876

ZOJ 3497 Mistwald 矩阵快速幂

思路:先将二维的坐标转换成一维的坐标,然后用矩阵存储,然后进行pci路径转移。关键点就是不能从出口处转移。#include &lt;string&gt; #include &lt;iostream&gt; #include &lt;cstdio&gt; #include &lt;cstring&gt; using namespace std; const int N = 26; int n,m; ...

Peppermint__的博客 268

【已解决】zoj 3497 Mistwald 矩阵快速幂

时隔几个月重新做,终于ac了! 题目看似是图论,但事实是矩阵相乘。根据离散数学书上说的,邻接矩阵A的k次幂得到的新矩阵B中,bij表示ai到aj长度为k的通路数。 上面的方法计算的是任意两点通路数,而本题目要求终点不能有出边,基于酱紫,只要把终点那一行全部置为0就ok,这里不求通路数,改为求能否k步到达终点。 #include #include #include #include #

leolin_的专栏 1010

zoj3497:Mistwald(矩阵快速幂)

传送门 题意 有一个n*m的矩阵,矩阵上每一个格子有四个传送门,分别通向四个格子,题目给出了每个格子的四个传送门所能到达的地方。起点在(1,1),终点是(n,m),当走到终点的时候就不能再走了,也就是说一旦你到达了终点,就会直接离开这个矩阵。问说从起点开始走P(0 ≤ P ≤ 100,000,000)步能不能到达终点。 输出的情况是True,Maybe和False。Ture对应的就是走...

anquan1533的博客 116

ZOJ 3497 Mistwald(矩阵快速幂)

水题 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll

宝树啊宝树 467

矩阵快速幂 ZOJ 3497 Mistwald

题目传送门 题意:看似给了一个迷宫,每个点能传送到4个地方,问在P时间能否到达终点 分析:其实是一个有向图,可以用邻接矩阵存图,连乘P次看是否能从1到n*m,和floyd的传递背包思想一样 #include <bits/stdc++.h> int tot; struct Mat { int m[30][30]; Mat() { ...

weixin_33862514的博客 101

zoj 3497 Mistwald(矩阵快速幂)

#include #include #include #include #include #include #define inputt int t;cin>>t; #define pi acos(-1.0) #define lson o*2,l,m #define rson o*2+1,m+1,r #define Mid (l+r)/2 #define MAXN 30 typedef

Enigmo的博客窝 370

zoj 3497 Mistwald(矩阵快速幂)

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3497.   按照规则处理一下建图即可, 然后就是一个最大25*25的矩阵快速幂了     #include&lt;bits/stdc++.h&gt; using namespace std; struct node{ int ma[33][33]; }; i...

三水的鱼塘♂ 260

ZOJ 3497 Mistwald (矩阵快速幂解决类似图论问题)

点击打开链接 这道题的题意大概是有一个n*m的图,会告诉你每一个点的出边,与哪四个点相连(可能是重复的),注意这是单向的连接。问从起点(1,1)开始,走P步之后,是一定到终点(n,m),还是可能到,还是不可能到终点?其中在行走的过程中,除了第P步到达的点,其他都不能是终点,但是可以重复经过其他点。 这道题由于方便起见,把起点设置为(0,0),终点就是(n-1,m-1),按行优先

Muya 596
上一篇: Sorting the Coins(思维)
下一篇: Restoration of string (拓扑排序)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值