CodeForces541div2-B-Draw!(有详细推导)

【WRF湿度调整策略】WRF/ERA5湿度数据对比 阅读详情

题目传送门
题意:
题目转化为同一个选手的相邻比分构成一个闭区间(最开始的0 0也算),求这些区间的交集大小(不能重复计算,端点值注意不要计算)。
思路:
设a1 b1 a2 b2分别是上一次和当前的比分,我们计算区间[a1,a2],[b1,b2]的交集的时候,一般是min(a2,b2) - max(a1,b1) + 1(如果前者小于后者则continue).这样计算的话,我们将两个区间的所有点都就算在内了,那么之前的端点有没有在上次已经计算了呢?
如果a1 != b1,那么min(a1,b1) < max(a1,b1),在上一次计算的时候,使用min(a1,b1)计算的,所以min(a1,b1)这个端点会计算在内。在当前计算的时候,使用的是max(a1,b1),min(a2,b2) - max(a1,b1) + 1会把max(a1,b1)就算在内,但是由于min(a1,b1) < max(a1,b1),所以上次的min(a1,b1)在这一次没有重复计算。
如果a1 == b1,那么min(a1,b1) == max(a1,b1),在上一次计算的时候,使用min(a1,b1)计算的,所以min(a1,b1)这个端点会计算在内。在当前计算的时候,使用的是max(a1,b1),min(a2,b2) - max(a1,b1) + 1会把max(a1,b1)就算在内,但是由于min(a1,b1) == max(a1,b1),所以上次的min(a1,b1)在这一次重复计算。所以使用的是min(a2,b2) - max(a1,b1) 。
最后ans+1,加上最开始的0 0
下面的代码都是AC的。
详情见代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include<cmath>

using namespace std;

typedef long long LL;

#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define per(i,a,b) for(int i = a;i <= b;++i)
#define rep(i,a,b) for(int i = a;i >= b;--i)
const int maxn = 1e4;
int n = 0,m = 0; 
struct node{
	int s,e;
}; 
node a[maxn+10];
void solve(){//思维能力还是不行,总想着细致模拟,把问题想得太复杂,太细节化,这就是大佬和弱鸡的区别
	LL ans = 0;
	per(i,1,n){
		if(min(a[i].s,a[i].e) < max(a[i-1].s,a[i-1].e)){
			continue;
		}
		if(a[i-1].s == a[i-1].e){//如果前面的比分相等,那么他在上一次计算就已经算过了,每一次都是[]闭区间,
		//如果不相等,那么上一次用的是min(a[i-1].s,a[i-1].e),而这一次使用的是max(a[i-1].s,a[i-1].e)
		//因为a[i-1].s != a[i-1].e,所以两者不相等,所以断电不会重复算 
			ans += (min(a[i].s,a[i].e) - max(a[i-1].s,a[i-1].e));
		}else{
			ans += (min(a[i].s,a[i].e) - max(a[i-1].s,a[i-1].e) + 1);
		}
	}
	printf("%I64d\n",ans+1);//最后+1,加上0 0 
}
int main(){
	//std::ios::sync_with_stdio(false);
	while(~scanf("%d",&n)){
		a[0].s = a[0].e = 0;
		per(i,1,n){
			scanf("%d %d",&a[i].s,&a[i].e);
		}
		solve();
	}
	
	return 0;
}

比赛的时候想得复杂版本:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include<cmath>

using namespace std;

typedef long long LL;

#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define per(i,a,b) for(int i = a;i <= b;++i)
#define rep(i,a,b) for(int i = a;i >= b;--i)
const int maxn = 3e5;
int n = 0,m = 0;
struct node{
	int s,e;
};
node a[maxn+10];

void solve(){
	LL ans = 0;
	bool flag = false;
	per(i,1,n){
		if(a[i].s == a[i-1].s && a[i].s == a[i].e && a[i].s == a[i-1].e){
			if(i >= 2 && a[i].s == a[i-2].s || flag == true){
				continue;
			}
			++ans;
			flag = true;
			continue;
		}
		if(a[i].s < a[i-1].e || a[i].e < a[i-1].s){
			continue;
		}
		int l = max(a[i-1].s,a[i-1].e);
		int r = 0;
		if(a[i].s == a[i].e){
			r = min(a[i].s,a[i].e);
			ans += max(0,r - l);
			if(flag == false){
				++ans;
				flag = true;
			}
			continue;
		}else if(a[i].s > a[i].e){
			r = min(a[i].s-1,a[i].e);
		}else{
			r = min(a[i].s,a[i].e-1);
		}
		if(flag == false){
			++ans;
		}
		ans += max(0,r - l);
		flag = false;
	}
	printf("%I64d\n",ans);
}
int main(){
	while(~scanf("%d",&n)){
		a[0].s = a[0].e = 0;
		per(i,1,n){
			scanf("%d %d",&a[i].s,&a[i].e);
		}
		solve();
	}
	return 0;
}
C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片 基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正 立即下载

相关推荐

AXI总线的Burst Type以及地址计算 | WRAP到底是怎么一回事?

AXI总线的transaction是burst-based的,因此有必要好好研究一下不同burst type的工作原理。此处略过burst的定义以及burst size、burst length等信号的介绍。

qiuzhongyu123的博客 2万+

Codeforces Round #659 (Div. 2)A-D题解

Codeforces Round #659 (Div. 2)A-D题解 //打牛客多校去了,CD晚点施工 //写于rating值2032/2056 这一场cf是补的,题目分布并没有按照往常的难度梯度递增。 这场是同时有div1和div2,对于div2的人来说这场如果策略得到及时跟过题人数多的题去写C的话是个上分的好机会。 A题难度为一般div2场的B B1B2题难度为一般div2场的DE CD难度对应一般div2场的DE Codeforces Round #659 (Div. 2) A题难度系数1200 一

StandNotAlone的博客 1万+

嵌入式开发语言-C语言编程

C语言编程概述环境在Windows上构建C语言的环境安装在Mac上构建C语言的环境安装 概述 “C语言”被称为适合嵌入式系统开发的编程语言之一。 C语言在一般的编程中也是熟悉的开发语言,但实际上,如果试着使用C语言制作微型计算机的控制程序等,就必须使用与“普通的C程序”不同的使用方法。 作为一般的C语言的学习方法,使用“printf”“scanf”等标准函数的程序开发是固定的,但这些都是以UNIX和Windows等环境上的应用程序开发为前提的。 对此,没有显示器和键盘的嵌入式系统的微型计算机控制程序,该如何

编程老王 7981

信奥入门级相关的比赛(2025.01.13)

信奥入门级相关的比赛(2025.01.13)

青少年趣味编程 3921

ST-LINK调试STM32H743必看:CubeMX工程中缺失的这行代码导致程序跑飞

本文深入剖析了使用ST-LINK调试STM32H743时,因CubeMX工程中缺失电源电压档位配置代码而导致程序跑飞或出现“Can not access memory”错误的问题。文章解释了H7系列电源与时钟耦合的核心原理,提供了具体的代码修复方案和系统化的调试排查思路,帮助开发者从根本上解决这一常见调试困境。

weixin_29191669的博客 281

Shell数学计算(算术运算,加减乘除运算)

声明: 本篇博客的学习途径主要为以下网站和课堂讲解,发博客目的仅为学习使用,在该博客的基础上做了一定程序的简略和修改。 参考博客 : 原文链接:http://c.biancheng.net/shell/ Shell数学计算Shell数学计算数学计算命令对整数进行数学运算: (()) / let / $[] /exprShell (())Shell let命令bc命令:一款数学计算器在 Shell 中使用 bc 计算器 Shell数学计算 默认情况下,Shell 不会直接进行算术运算,而是把+两边的数据(数

AKUANer的博客 2万+

Codeforces #322 div2 ABCDF

cf#322 div2 相对较易,AB较易,CD需要一些基础功力,EF比前面的题难了很多,F比E要容易一些,但也很难做。

ned_chu的博客 749

【数据分析与挖掘实战】金融风控之贷款违约预测详解1(有代码和数据集)

金融风控一.题目理解1.1.题目概况1.2数据概况1.3预测指标二.数据来源三.查看数据四.分类指标计算示例4.1混淆矩阵4.2准确度4.3precision(精确度),recall(召回率),f1-score4.4P-R曲线4.5ROC曲线4.6AUC曲线4.7KS值五.数据分析5.1基本信息5.2查看数据集中特征缺失值,唯一值等5.3查看特征的数值类型有哪些,对象类型有哪些5.3.1数值连续型变量分析5.3.2非数值类别型变量分析5.3.3总结:5.4变量分布可视化5.4.1单一变量分布可视化 更新中~

m0_49263811的博客 1万+

Codeforces Round #747 (Div. 2)

Codeforces Round #747 (Div. 2) 这一场下班,下早了,C思路在一个分类的地方错了,写了个假算法,一直WA然后两题就下班了,这一场难度相对以前的Div2难度小一点吧,主要还是我反应太慢了,每次把问题复杂化,每次div2就只能过两题,真的很菜。以后争取CF都写一个题解总结一下。 A 给你一个n,要你求出两个数分别是 l,rl,rl,r,使得 $ l,l+1,l+2,l+3…,r-2,r-1,r$ 的和等于 n 一开始总在算前n项和,浪费好几分钟时间,最后发现根本解不出两个未知数的方

万伏小太阳 353

使用C#实现的多人语音视频系统:WebSocket与WebRTC集成

通过上述的代码示例,我们可以使用C#编写一个多人语音视频系统,该系统集成了WebSocket和WebRTC技术。当然,这只是一个简单的示例,实际的多人语音视频系统可能需要更多的功能和优化。通过结合这两种技术,我们可以实现实时的语音和视频通信,支持多人同时参与。在上述代码中,我们创建了一个WebSocket服务器,监听在本地的8080端口,并创建了一个WebRTC连接。接下来,我们将详细介绍如何使用C#编写一个多人语音视频系统,包括使用WebSocket建立连接和使用WebRTC进行实时通信。

TjsReact的博客 1635

Android/Linux驱动开发:使用dev_dbg进行设备驱动调试

在本文中,我们将介绍如何使用dev_dbg宏和相关的函数来进行设备驱动调试。函数在该目录下创建了一个名为"debug"的debugfs文件。在这些函数中,您可以执行与您的设备驱动相关的调试操作。函数在该目录下创建了一个名为"debug"的debugfs文件。在这些函数中,您可以执行与您的设备驱动相关的调试操作。的结构体指针,其中包含了我们定义的文件操作函数。的结构体指针,其中包含了我们定义的文件操作函数。在上面的示例中,我们首先通过调用。在上面的示例中,我们定义了。在上面的示例中,我们定义了。

ByteKnight的博客 375

Codeforces Round 926 (Div. 2)

因为这幅图,假如2和3都是危险点,但是对于1子树外得点来说,1子树就1个危险点,因为简单路径不能有重复,如果2通过1得子树走出去了,那么就不能走回来,因此顶多就一个。考虑两个有限制的相邻节点(i,j),那么我们把原序列拆成n段来数,最后用乘法原理相乘即可,对于每一段就是每个数有pos[j] - pos[i]个数,并且有j-i+1个位置,我们考虑用隔板法计数即可。Q2:我们可以多画两个图,则可以发现2*2有2个,3*3有4个,4*4有6个,因此我们可以得出结论2*(n-1)就是我们至少要涂的个数。

scanner 1104

数据分析案例-2024年裁员数据集可视化分析

本实验数据集来源于Kaggle,原始数据集为2020-2024年裁员数据,共有3577条,12个变量,该数据集提供了不同公司的裁员信息。它包括以下几栏:Company:裁员发生的公司名称。Location_HQ:公司总部位置。Industry:公司所属的行业或部门。Laid_Off_Count:公司解雇的员工数量。Percentage:公司员工被解雇的百分比。Date:裁员发生的日期。Source:信息来源网址。Funds_Raised:公司募集资金的信息。

m0_64336780的博客 1万+

Codeforces Round 541 (Div. 2)

layout: post title: Codeforces Round 541 (Div. 2) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces - 并查集 --- 传送门 A.Sea Battle (签到) 题意 给你一个上下两个矩形,让他们左边对着拼起来,求出他们外面一圈的面积 思路 关键就是中间那一...

weixin_30244889的博客 171

android 蓝牙通讯demo

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

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Codeforces Round #541 (Div. 2) 题解

Codeforces Round #541 (Div. 2) 题目链接:https://codeforces.com/contest/1131 A. Sea Battle 题意: 给出两个矩形的宽和高,满足第一个矩形的左上顶点为(0,0),右下顶点为(w1,-h1);第二个矩形的坐下顶点为(0,0),右上顶点为(w2,h2)。然后求围绕这两个矩形一圈的格子个数为多少。 题...

dft539533的博客 283

深度学习工具包 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 Round #541 (Div. 2)(题解)

Codeforces Round #541 (Div. 2)(题解) A. Sea Battle 题目大意 给出两个长方形,其左边界对其,一个摆放在另一个上,问其周长 解题思路 较长的宽乘二,长相加乘二再加上四个角即为周长 AC代码 #include&lt;bits/stdc++.h&gt; using namespace std; #define int long long int32_t m...

FLY_WHITE的博客 322

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

codeforces 541 div2

A. Sea Battle 题意 给两个矩形堆在一起,大的在下,小的在上,左边界对齐,求整个图形的外延有多少格。如图一 答案显然就是最长的宽x2+两个矩形的高x2+4 B. Draw! 题意 给出部分足球比赛的比分,每次进求,赢得一方比分只能加1,可能出现多次相同的比分,最后一个比分为最终得分。求比赛期间出现平局情况的最多次数(就是比分相同的情况)。 思路 先预处理一下,把重复的比分去掉。对于相邻...

lalalafloat的博客 247

Codeforces Round #541 (Div. 2) B. Draw!

题解 题目大意,两个队伍打比赛,按照时间顺序给出部分比分结果,最后一个为结束时的结果,问比赛过程中最多有多少次比分相同 直接遍历所给比分,设两个队伍比分为a和b,min(a[i], b[i]) - max(a[i - 1], b[i - 1]) + 1即为答案,注意负数 如果ab相同则说明(a, a)这个已经计算进答案,让当前的a++防止重复计算 AC代码 #include &lt;stdio.h...

CaprYang的博客 629

Codeforces Round #541 (Div. 2)

Codeforces Round #541 (Div. 2) 题号 题目 知识点 A Sea Battle 思维 B Draw! 贪心模拟 C Birthday 思维 D Gourmet choice E String Multiplication F Asya And Kittens G Most Dangerous Shark

qq_35975367的博客 192

Codeforces Round #541 (Div. 2)B. Draw!(思维)

题目链接:https://codeforces.com/contest/1131/problem/B   题目大意:按照时间发展顺序给出比分,最后一个比分是最终结果,问如果所有比分都出现最多可能有几个平局   题目思路:首先可以发现,对于x:y,假设x&lt;y,那么不能出现的平局是x+1:x+1~y:y,那么我们就可得出一个结论,如果两个区间产生相交,那么这两个区间不会产生新的可以出现的...

smilestruggler_Fly To Higher 302

Codeforces Round #541 (Div. 2) B.Draw!

链接:https://codeforces.com/contest/1131/problem/B 题意: 给n次足球比分,求存在平局的机会。 思路: 结构体存储,unique后,判断是否有分数交叉。 一方当前分数小的时候,下一次分数小于当前对方时不存在平局, 下一次分数介于对方当前分数和下次分数之间时根据下次分数和当前对方分数。 否则表示对方分数被完全包含,反之同理。 代码: ...

weixin_34311757的博客 128

Codeforces Round #541 (Div. 2) B. Draw!

题目链接:http://codeforces.com/contest/1131/problem/B 题目大意:        有两个队伍在踢足球,给你一些时刻的比分情况,问全程下来最多可以有多少次平局出现。 题目思路:       从头到尾遍历每两个时刻,比如第一个时刻比分为 a : b ,第二个时刻为c : d。那么中间这段时间甲方a-c的比分都可出现,乙方b-d的分数都可能出现,那么我...

qq_41645482的博客 167

Codeforces Round #541 (Div. 2) B. Draw!(思维)

  题目链接:https://codeforces.com/contest/1131/problem/B        题意是输入一个n,然后n行每行输入两个数,表示在某一时刻场上两个队的比分,比如说1 1到2 2中间的变化可能是(1 2)(2 2)或者(2 1)(2 2),问在所有的变化中,出现平分的次数最多有多少次。        思路就是在一个比分到下一个比分中,能出现相同的分数的一定...

Charles_Zaqdt的博客 303

B. Draw!--简单思维题--Codeforces Round #541 (Div. 2)

Draw! time limit per test 2 seconds memory limit per test 256 megabytes 题目链接http://codeforces.com/contest/1131/problem/B 说实在的这题做了很久,WA了很多次WA4的2发,WA8的4发。。。思维不够严谨造成了各种漏洞。。。 题目大意:给你n个分数比,最后一个是最终的分数比,让...

孤风的博客 345

Codeforces Round #541(Div.2) B. Draw!解题报告

题目链接 B.Draw! time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output You still have partial information about the score during the historic footba...

zrzzzlll的博客 461

Codeforces Round #541 (Div. 2) (A~F)

目录 Codeforces 1131 A.Sea Battle B.Draw! C.Birthday D.Gourmet choice(拓扑排序) E.String Multiplication(思路) F.Asya And Kittens...

weixin_30293079的博客 85
上一篇: 最大连续和-高效算法
下一篇: Palindromic Matrix(构造法)-CodeForces div2 540C
Mavis code
博客等级 码龄9年 13粉丝 147原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值