codefores544D

图论:Dijkstra算法——最详细的分析,图文并茂,一次看懂! Dijstra算法 阅读详情

In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city a to city b, or from city b to city a. The road network is such that from any city you can get to any other one by moving along the roads.

You want to destroy the largest possible number of roads in the country so that the remaining roads would allow you to get from city s1 to city t1 in at most l1 hours and get from city s2 to city t2 in at most l2 hours.

Determine what maximum number of roads you need to destroy in order to meet the condition of your plan. If it is impossible to reach the desired result, print -1.

Input
The first line contains two integers n, m (1 ≤ n ≤ 3000, ) — the number of cities and roads in the country, respectively.

Next m lines contain the descriptions of the roads as pairs of integers ai, bi (1 ≤ ai, bi ≤ n, ai ≠ bi). It is guaranteed that the roads that are given in the description can transport you from any city to any other one. It is guaranteed that each pair of cities has at most one road between them.

The last two lines contains three integers each, s1, t1, l1 and s2, t2, l2, respectively (1 ≤ si, ti ≤ n, 0 ≤ li ≤ n).

Output
Print a single number — the answer to the problem. If the it is impossible to meet the conditions, print -1.

Example
Input
5 4
1 2
2 3
3 4
4 5
1 3 2
3 5 2
Output
0
Input
5 4
1 2
2 3
3 4
4 5
1 3 2
2 4 2
Output
1
Input
5 4
1 2
2 3
3 4
4 5
1 3 2
3 5 1
Output
-1

这题告诉我们如何用BFS当权值相同时n^2求任意两点间最短路,还有补集转化的力量

using namespace std;
#include<bits/stdc++.h>
#define N 3001
#define forw(i,x) for(int i=fir[x];i;i=ne[i])
int way[N][N];
int n,m;
int x,y;
int s1,t1,l1,s2,t2,l2;
int ne[N*2],fir[N],to[N*2],cnt=1;
void add(int x,int y)
{
    ne[++cnt]=fir[x];fir[x]=cnt;to[cnt]=y;
}
bool vis[N];
queue<int>q;
int res=2e9;
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;add(x,y);add(y,x);
    }
    for(int i=1;i<=n;i++)
    {
        memset(vis,0,sizeof(vis));
        vis[i]=1;way[i][i]=0;
        while(!q.empty())q.pop();
        q.push(i);
        while(!q.empty())
        {
            int ind=q.front();q.pop();
            forw(j,ind)
            {
                int v=to[j];
                if(!vis[v])
                {
                    vis[v]=1;
                    way[i][v]=way[i][ind]+1;
                    q.push(v);
                }
            }
        }
    }
    if(0)
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cout<<way[i][j]<<" ";
        }
        puts("");
    }
    cin>>s1>>t1>>l1;
    cin>>s2>>t2>>l2;
    if(way[s1][t1]>l1||way[s2][t2]>l2)
    {
        puts("-1");return 0;
    }
    res=way[s1][t1]+way[s2][t2];//可能不选仅这一种可能,无相交 
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            int it=way[i][j];
            int jj=way[s1][i]+way[j][t1]+it;
            int kk=way[s2][i]+way[j][t2]+it;
            if(jj<=l1&&kk<=l2) res=min(res,jj+kk-it);
            it=way[i][j];
            jj=way[s1][i]+way[j][t1]+it;
            kk=way[s2][j]+way[i][t2]+it;
            if(jj<=l1&&kk<=l2) res=min(res,jj+kk-it);           
        }
    }
    cout<<m-res<<endl;
}
Codeforces算法竞赛代码解析与实战 本文还有配套的精品资源,点击获取 简介:Codeforces是一个深受程序员和算法爱好者喜爱的在线编程竞赛平台。本系列文章将解析Codeforces竞赛中的代码名称及其背后的算法问题。文章将涵盖问题的唯一ID、难度分类以及代码文件的命名规则,同时提供针对不同难度级别(A到G)的问题代码分析。此外,文章还会探讨如何使用C++语言编写高效且功能强大的算法代码,并介绍如何在竞赛中... 阅读详情

相关推荐

PINN——加入物理约束的神经网络

【摘要】 基于物理信息的神经网络(Physics-informed Neural Network, 简称PINN),是一类用于解决有监督学习任务的神经网络,它不仅能够像传统神经网络一样学习到训练数据样本的分布规律,而且能够学习到数学方程描述的物理定律。与纯数据驱动的神经网络学习相比,PINN在训练过程中施加了物理信息约束,因而能用更少的数据样本学习到更具泛化能力的模型。本文主要解析这种神经网络以...

qq_39444290的博客 4583

迪杰斯特拉(Dijkstra)算法

一 算法介绍 迪杰斯特拉算法是由荷兰计算机科学家在1956年发现的算法,此算法使用类似广度优先搜索的方法解决了带权图的单源最短路径问题。它是一个贪心算法。 二 核心思想 1. 选定一个点,这个点满足两个条件:1.未被选过,2.距离最短 2. 对于这个点的所有邻近点去尝试松弛 三 算法步骤 首先,可以设置两个集合分别是A和B,A用来存放已经求出最短路径的点,B用来存放还未计算出最短路径的点,接下来就可以开始做题啦!!! 我们从图中任选一点来解题,假设我们将源点source选择..

xiaoxi_hahaha的博客 12万+

卡方检验的隐藏逻辑:为什么正态分布的平方和如此重要?

本文深入探讨了卡方检验的核心逻辑,揭示了正态分布平方和在统计检验中的重要性。通过分析卡方分布与伽马分布的关系,以及实际应用案例,帮助读者理解卡方检验的原理、局限及高级应用场景,为数据分析提供有力工具。

3a9bq4r8t2y的博客 208

Codeforces 601A The Two Routes【最短路】

A. The Two Routes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In Absurdistan, there are n towns (number

世界很大 729

Arcgis 10.3 与 ArcGIS Engine 10.3 安装与破解

Arcgis 10.3 与 ArcGIS Engine 10.3 安装与破解

weixin_52127098的博客 4725

MEMS惯性传感器关键参数解析与误差优化策略

本文深入解析了MEMS惯性传感器的关键性能参数,如零偏稳定性、噪声与随机游走、振动整流误差等,并阐述了这些误差如何导致设备导航漂移、姿态不稳等问题。文章重点探讨了从硬件选型、系统设计到校准补偿、算法融合(如卡尔曼滤波)以及温度补偿等实战优化策略,旨在帮助工程师有效提升自动驾驶、无人机等设备的测量精度与稳定性。

weixin_28363123的博客 414

codeforces-601A The Two Routes (Floyd)

题意: 是n个城市之间任意两个城市间要么有火车线路要么有汽车线路,要从1出发到n,而且火车和汽车不能同时到达一个城市,问两者都到达的最短时间。 分析: 肯定有一种车可以从1直接到达n,并且这样肯定是最优的判断另一种能不能到达n就行了。 /*floyed算法求单源最短路径 i,j,k,其中k是中间结点,i是起点,k是终点 */ #include&amp;lt;bits/stdc++.h&amp;gt; #...

xx_ii 286

Pytorch(一) Pytorch 的安装

安装步骤 1.检查是否有合适的GPU, 若有安装Cuda与CuDNN 2.下载pytorch安装文件,进行pytorch的安装 检查电脑是否有合适的GPU 在桌面上右击如果能找到NVIDA控制面板,则说明该电脑有GPU。控制面板如下,并通过查看系统信息获取支持的Cuda版本 点击 帮助->点击 系统信息 弹出下面的对话框,在驱动程序版本那一栏就能看到该计算机使用的驱动版本。 ...

开开心心 25万+

Codeforces 601A The Two Routes(暴力)

题目链接:Codeforces 601A The Two Routes代码#include <cstdio> #include <cstring> #include <queue> #include <algorithm>using namespace std; const int maxn = 405; const int inf = 0x3f3f3f3f;int N, M, G[maxn][ma

不慌不忙、不急不躁 1086

手把手教你学simulink(41.4)--逆变器电场景示例:基于Simulink的主从控制的多逆变器协同控制(Multi-Inverter Coordinated Control)

需求分析在现代电力系统中,分布式发电和储能系统的广泛应用使得多个逆变器并联运行成为常见的应用场景。为了确保多个逆变器之间的协同工作,实现系统的稳定性和高效性,通常采用主从控制(Master-Slave Control)策略。主从控制通过一个主控制器(Master)来协调多个从控制器(Slave),确保所有逆变器的输出电压、频率和功率分配符合预期目标。本项目将基于Simulink平台,开发一个多逆变器协同控制系统,采用主从控制策略,实现对多个逆变器的精确控制和优化。

MHD0815的博客 306

HyperLynx中层叠设计实例

这两种方式有点区别,前一种方式只是增加层,需要自行修改层的类型,后一种方式可以选定为某一种类型,如果是增加信号层,软件会默认同时增加一层介质层。层叠已经有8层,按照示例的层叠有4个信号层、3个地平面层和1个电源平面层,对照进行层名称(LayerName)、介质类型(Type)及用途(Usage)设置。在这列中,有的是白色,有的是淡蓝色。白色的说明可以修改,如第一行是介质,通常在最外层的介质有两个用途,阻焊层和介质,单击该行会出现一个下拉菜单,选择SolderMask,即为阻焊层。...

小幽余生不加糖 5877

Codeforces 601A The Two Routes

题意: 给你n座城镇,并给出m条铁路,每条铁路的长度为1,除有铁路的地方之为,其他任意两点之间都存在道路长度也是1。铁路只能动车过,公路只能汽车过。现在动车和汽车同时从1城市出发要到n城市,问动车、汽车都到达n城市的最早时间。 思路: 分析下题目。可以发现,一定有动车或者汽车其中一种可以直接从1城市到n城市的,因为其中一定有一条直通的铁路或者公路。剩下的就是求另一种不能直接到的交替工具到n的

w446506278的博客 324

VN1640 CH5 I/O通道终极指南:【从硬件原理—>工程实战—>自动化测试实战】

摘要:本文详细解析Vector VN1640 CH5 I/O通道的硬件原理与工程应用,涵盖模拟输入(AIN)、数字输入(DIN)和数字输出(DOUT)三大功能模块的配置指南。通过硬件隔离设计实现高精度信号采集与驱动控制,重点分析开漏输出特性及保护机制。提供PWM控制、ECU上电时序测试、传感器闭环控制等实战案例的CAPL脚本代码,并强调多设备同步采集的精准性(时间偏差<1µs)。适用于汽车电子HIL测试、ECU信号监测等场景,所有方案均通过实际项目验证。

汽车控制器系统开发、VIL测试、HIL测试、MIL测试、EMS电喷系统标定与开发、热管理系统标定 759

dijkstra算法

有向非负带权如图所示: 为了更加方便理解dijkstra算法,我们先把所有的有向边全部删掉,从源点开始,红色表示未被访问的点,白色表示已经被访问过的点,设v0到v0的路径为0,v0到所有点的距离为无穷大 如下图所示:从v0开始,我们将与v0相连的边全找出来,如下图所示,找到所有边中权值最小的边,并且,将与该条边相连的点标记为已经访问,此时,该条边就是v0到v1的最短路径。(可证明,若改条边...

kenniszy的博客 4512

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Dijkstra算法

解决最短路问题的dijkstra算法

LHLYX的博客 259

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

探索高效编程神器:Codeforces - 竞技编程平台与代码库

探索高效编程神器:Codeforces - 竞技编程平台与代码库 去发现同类优质开源项目:https://gitcode.com/ 是一个全球知名的在线编程竞赛平台,也是开发者交流和分享代码的宝地。无论你是初学者,还是经验丰富的程序员,Codeforces 都能提供一个锻炼编程技能、提升算法理解、与全球顶尖开发者竞技的机会。 技术分析 Codeforces 的核心在于其比赛系统。该系统基于Web...

gitblog_00070的博客 7422

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

Dijkstra 算法

Dijksta 算法用于求单源最短路径长度,所谓单源最短路径长度就是,在一个图中求一个顶点到其他所有顶点的最短路径长度。适用于带权值的图,不能用于带负权值的图。

fufufu_的博客 1311

【每日一题】codeforces 20C(1900)(最短路之Dijkstra算法)

想她一次就背十个单词,当我英语过六级后,我就去告诉她,我很在意她 每日一题,坚持使我快乐 今日份快乐:codeforces 20C 传送门 明天份快乐:codeforces 20C 传送门 题目大意 给出一个无向图,有 n 个节点,m 条边,第 i 条边的长度为wi 问:从 1 到 n 号的最短距离 分析 这是一个赤裸裸的最短路的题 ...

mldl_的博客 705

单源最短路径问题之Dijkstra算法详解

单源最短路径问题之Dijkstra算法详解单源最短路径:给定一个图G=(V,E)G=(V,E),找到从给定源结点s∈Vs \in V到每个结点v∈Vv \in V的最短路径。Dijkstra算法目标:是解决带权重的有向图的单源最短路径问题。 前提:假设对于所有的边(u,v)∈E(u,v) \in E,都有w(u,v)≥0w(u,v) \geq 0。 该算法会在运行过程中维护一个结点集合SS。符号

nxiangbo的专栏 2632

最短路径---迪杰斯特拉算法[图中一个顶点到其他顶点的最短距离]

转自大神:https://www.cnblogs.com/skywang12345/p/3711512.html 是真的牛逼 看大神的吧 舒服点 我注释了点最后代码的部分 迪杰斯特拉算法介绍 迪杰斯特拉(Dijkstra)算法是典型最短路径算法,用于计算一个节点到其他节点的最短路径。它的主要特点是以起始点为中心向外层层扩展(广度优先搜索思想),直到扩展到终点为止。 基本思...

dingdunzeng9939的博客 2986

【智能算法】Dijkstra算法

Dijkstra算法的基本思想是从源点开始,逐步确定到达其他各顶点的最短路径。在每一步中,它都选择当前已确定最短路径的顶点集合中,距离源点最近的顶点,并更新与该顶点相邻的顶点的最短路径估计值。

大雨淅淅的博客 3313

【图论】Dijkstra 算法

Dijkstra算法求单源最短路径,基于贪心策略,使用优先队列优化,时间复杂度O((V+E)logV),要求边权非负,是图论中最基础高效的最短路径算法之一。

zhangmohan123321的博客 3181

数据结构--Dijkstra算法最清楚的讲解

迪杰斯特拉(Dijkstra)算法是典型最短路径算法,用于计算一个节点到其他节点的最短路径。 它的主要特点是以起始点为中心向外层层扩展(广度优先搜索思想),直到扩展到终点为止基本思想 通过Dijkstra计算图G中的最短路径时,需要指定起点s(即从顶点s开始计算)。 此外,引进两个集合S和U。S的作用是记录已求出最短路径的顶点(以及相应的最短路径长度),而U则是记录还未求出最短路径的顶点(以及该

heroacool的专栏 16万+

Codefores C. ABBB

思路:只要是AB或者BB就会被消除,换句话说只要当前B前面有字符就可以与当前B抵消(因为只有A,B,这两个在B前面都可以抵消),最后的形式必然是AAAAA....或者BAAAAA...... 所以只要判断当前是B并且当前B前面还有字母,那就可以抵消

m0_74969835的博客 355
上一篇: codeforces544C
下一篇: codeforces544E
Timsei
博客等级 码龄10年 344粉丝 159原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值