Codeforces Round #686 Div. 3

Codeforces Round #686 (Div. 3) 解题报告 Codeforces Round #686 (Div. 3) A. Special Permutation Description 让你输出111 ~ nnn的一个排列aaa,并满足∀i∈[1,n],ai≠i\forall i \in [1, n], a_i \neq i∀i∈[1,n],ai​​=i Tutorial 如果nnn为偶数直接倒序输出即可,否则将中间的数字与开头或结尾进行交换 Solution #include <bits/stdc++.h> using namespace st 阅读详情

A. Special Permutation

题目要求构造一个数列,保证 a[i] != i
直接将1-n的数列向后移一位即可

int T,n;
int a[maxn];
 
int main(){
	
	scanf("%d",&T);
	while(T--){
		
		memset(a,-1,sizeof a);
		scanf("%d",&n);
		for(int i=1;i<n;i++){
			a[i] = i+1;
		}
		a[n] = 1;
		for(int i=1;i<n;i++){
			printf("%d ",a[i]);
		}
		printf("%d\n",a[n]);
	}
	return 0;
}

B. Unique Bid Auction

题目要求输出最小并且只有一个的数字,不存在输出-1
定义一个数组用来记录每个数字出现的次数
然后遍历找到出现一次的数字
再遍历一遍找到这个数字对应原数组下标即可

int T,n;
int a[maxn],b[maxn];
 
int main(){
	
	scanf("%d",&T);
	while(T--){
		
		int ans = -1;
		int id = -1;
		scanf("%d",&n);
		for(int i=1;i<=n;i++) b[i] = 0;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			b[a[i]]++; // 记录每个数字的种数 找到只有一种的那个数 
		}
		
		for(int i=1;i<=n;i++){
			if(b[i] == 1){
				id = i; // 记录下只有一种并且最小的数字 
				break; 
			}
		}
		for(int i=1;i<=n;i++){
			if(a[i] == id){
				ans = i;
				break;
			} 
		}
		printf("%d\n",ans);
	}
	return 0;
}

C. Sequence Transformation

题目要求给定一个序列,选一个固定的数字
每次选取不包含这个数的区间删去
最后保证序列中剩余的全部都是一开始选定的数字
问最少的操作次数

我们可以把序列分成好几段,去记录相同数字的段数
例如序列 1 2 3 2 2 2 1
数字1的段数就是2 数字2的段数是2 数字3的段数是1
这样我们就可以发现如果选定数字是1
操作次数就是数字1的段数-1
如果选定数字是2
操作次数就是数字2的段数+1
如果将序列改成1 2 3 2 2 2 3
那么如果选定数字是3
操作次数就是数字3的段数
总结一下
选定数字1时序列的头尾元素都是1
如果是这样一个序列1 2 3 1 2 1 ,操作次数依旧是数字1的段数-1,所以如果首尾元素相同并且是选定数字的话,操作次数就是选定数字的段数-1
选定数字2时序列头尾元素都不是选定元素
那么此时操作次数就是选定数字的段数+1
选定数字3时序列首尾元素中有一个与选定数字相同
此时的操作次数就是选定数字的段数

int T,n;
int a[maxn],b[maxn],cnt[maxn];

int main(){
	
	scanf("%d",&T);
	while(T--){
		
		int ans = INF;
		scanf("%d",&n);
		for(int i=1;i<=n;i++) cnt[i] = 0;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		
		for(int i=1;i<=n;i++){ // 求每个数的连续块数 
			cnt[a[i]]++;
			while(i+1 <= n && a[i] == a[i+1]) i++;
		}
		
		int tmp = 0;
		for(int i=1;i<=n;i++){
			if(cnt[a[i]] != 0){
				if(a[1] == a[n] && a[1] == a[i]){
					tmp = cnt[a[i]] - 1;
				}else if(a[1] == a[i] || a[n] == a[i]){
					tmp = cnt[a[i]];
				}else if(a[1] != a[i] && a[n] != a[i]){
					tmp = cnt[a[i]] + 1;
				}
			}
			ans = min(ans,tmp);
		}
		printf("%d\n",ans);
	}
	return 0;
}
Codeforces Round #686 (Div. 3) A-F题解 Codeforces Round #686 (Div. 3) A-F题解 A. Special Permutation 题意 给定 nnn ,输出一个长度为 nnn 的全排列,每个位置 iii 上的数不等于 iii。 思路 1−n1-n1−n全排列循环右移一位。 代码 #include <bits/stdc++.h> using namespace std; const int M = 110; int dp[M]; int main() { int T; cin > 阅读详情

相关推荐

云点播、云播放破解网页版

目前网上都流传者各种不同版本,或不同名称的云播源码,基本上每一个我都有用过,我个人认识这个比较好,所以分享给大家,但收了点资源分,应该不过份,我想大家也会理解的, 本云点播版本,适用于网站爱好者,初学者或及常用看电影的朋友。 里有有说明, 希望对大家有用。 如果好请顶一下。 http://pan.baidu.com/share/link?shareid=2826978429&uk=2989350859 http://pan.baidu.com/share/link?shareid=2828278302&uk=2989350859 http://pan.baidu.com/share/link?shareid=2829601278&uk=2989350859 http://pan.baidu.com/share/link?shareid=2830696748&uk=2989350859

leetcode 686. Repeated String Match 题解

leetcode 686. Repeated String Match 题解。

Frank Chan的窝 874

解密高并发系统的瓶颈:五大解决方案

在互联网应用中,高并发是指在短时间内同时有大量的用户访问一个网站或服务,造成系统压力过大,导致服务器宕机或服务停止响应的情况。高并发是互联网应用面临的一个重要问题,需要采取一系列措施来解决。负载均衡、缓存、数据库优化、异步处理和分布式架构是解决高并发问题的主要方法。在实际应用中,需要根据具体情况选择不同的方法来解决高并发问题。在高并发情况下,使用负载均衡是解决问题的一种常见方法。负载均衡可以通过将请求分配到多个服务器上,从而减少单个服务器的负载。这可以通过硬件设备或软件实现。

BUG制造者:图图 <p>这是一个P标签</p> 3903

云点播使用方法

具体可参考云点播官方文档 (1).在页面中引入文件 在合适的地方引入播放器样式文件与脚本文件: <link href="https://imgcache.qq.com/open/qcloud/video/tcplayer/tcplayer.css" rel="stylesheet"> <!--如果需要在 Chrome 和 Firefox 等现代浏览器中通过 H5 播放 HLS 格式的视频,需要在 tcplayer.v4.1.min.js 之前引入 hls.min.0.13.2m.js。-

pacholy的博客 4023

Synopsys安装教程Ubuntu22.04版本

在Ubuntu22版本上安装Synopsys等系列工具,安装DC,VCS等等

qq_59529218的博客 5725

表格数据学习的图神经网络综述

今天学习一篇发表在中科院一区期刊《ACM Computing Surveys》的综述文章《Graph Neural Networks for Tabular Data Learning: A Survey with Taxonomy & Directions》,该刊主要刊载计算机理论方法领域的系统性综述与教程论文,注重跨学科技术融合研究,最新的影响因子为28.0。本文的目的在于通过学习这篇文章,了解关于表格数据学习点图神经网络一些基础知识。

qq_41009600的博客 799

Codeforces Round #686 (Div. 3) E. Number of Simple Paths 拓扑排序+组合数学

题意:给一个有n个点,n条边的联通图。问有多少条简单路径。 简单路径是指:一条边最多经过一次的路径。 思路:首先,这个联通图,可以看成是一棵树,然后再加上一条边。 对于一棵树的话,任意两点都可到达,简单路径就是N * (N-1) / 2 然后考虑加上一条边之后,很容易知道,一棵树,加上一条边,必形成一个环。 然后我们考虑多的这条边会带来的贡献即可。 如上图所示,把环上每个点作为根,会分成三颗树。对于在同一颗子树中的点,每个点到自己所在子树内任意一点的简单路径只有一条,而到达不同子树的路径则有两条。 所以d

菜鸡的学习记录 347

一分钟了解 “提示词工程”、“上下文工程”、“驾驭工程”

在大模型刚刚进入大众视野的初期,开发者面临的最大挑战是如何让模型听懂人类的指令。这一阶段被称为提示词工程时代。其核心思想非常直观:通过精心设计输入的文本提示,引导模型输出符合预期的结果。这一时期的开发者更像是“提示词巫师”,他们热衷于寻找所谓的“魔法咒语”。典型的技巧包括角色设定、思维链、少样本学习以及输出格式约束。例如,仅仅在问题前加上一句“请一步步思考”,模型的推理能力往往就能得到显著提升。然而,随着应用场景的复杂化,提示词工程的局限性逐渐暴露。

h a 6 6 6 c k 为 你解决复杂难题! 568

codeforces #686 div3 D.Number into Sequence 2021.1.4

codeforces #686 div3 D.Number into Sequence You are given an integer n (n>1). Your task is to find a sequence of integers a1,a2,…,ak such that: ·each ai is strictly greater than 1; ·a1⋅a2⋅…⋅ak=n (i. e. the product of this sequence is n); ·ai+1 is divisi

u014567353的博客 386

PCB层叠结构与阻抗计算

1.Core 和 PP PCB两个重要组成部分:Core 和 Prepreg(半固态片,简称PP)。 如下图所示, Core 的两个表面都铺有铜箔,可作为信号层、电源层、地层等导电层,Core的上下表面之间填充的是固态材料; PP的表面不铺铜,在PCB中起填充作用,其材质是半固体的树脂材料,因此比Core略软一些。 在制作多层板时,需配合使用Core和PP,一般在两个Core 之间应选PP作为填...

sinat_15677011的博客 1万+

【软考高项论文】论信息系统项目管理的干系人绩效域

例如,在处理与电信运营商合作铺设光纤网络的问题时,考虑到其在通信设施建设和运维方面的专业性和重要性,我们将之定位为高权力高利益的干系人,给予了高度关注和优先沟通。项目全程,我们对干系人绩效域的执行效果进行了定期检查和评估,通过定量与定性的数据收集,确认了项目在干系人管理上的成效,具体表现为:建立了稳固的工作关系网络,使干系人普遍认可项目目标;鉴于本项目牵涉到政府各级部门、企事业单位、市民团体、技术研发伙伴等多种类型的干系人,且干系人的诉求和影响力各异,因此,有序且持续的干系人参与管理显得尤为关键。

Programming Talk 1681

Codeforces Round #686 (Div. 3)

Codeforces Round #686 (Div. 3) 传送门(点击传送) 之后会补全,坑位占上先写点想写的东西 B. Unique Bid Auction 题意: 思路: 代码: #include<bits/stdc++.h> using namespace std; struct node{ int num,loc; }person[200005]; int main() { ios::sync_with_stdio(false); cin.tie(0);cou

blacktion 228

手把手教你玩转CPU微架构--​第三章:乱序执行的“魔法”——如何让指令“插队”提升效率​​3.4 动手实验:用Gem5模拟器分析乱序执行对IPC的提升(对比顺序执行)

摘要:本章通过Gem5模拟器对比乱序执行(O3CPU)和顺序执行的性能差异,实验采用SPECCPU2017和PARSEC3.0基准测试,配置7级流水线、4指令/周期发射宽度及多级缓存。结果显示,乱序执行平均提升IPC超过100%,关键因素包括动态指令调度、缓存命中率提升(L1达92%)和TAGE分支预测(准确率95%)。优化方向包括增大指令缓存和发射队列深度。实验验证了乱序执行在减少流水线停顿和提升吞吐量方面的显著优势。

MHD0815的博客 165

Codeforces Round #686 (Div. 3) 题解

题目链接:Codeforces Round #686 (Div. 3) A. Special Permutation 整体向前循环移一位 int main() { int t; cin >> t; while(t--) { int n; cin >> n; for(int i=1;i<=n;i++) { if((i+1)%(n+1)==0) cout << 1 << ' '; else cout <&lt

张小生的先生的博客 341

倾斜摄影与地面激光点云融合高精度建模研究

本文研究了倾斜摄影与地面激光点云融合精细化建模技术,并通过相应的源代码实现了建模过程。该方法将倾斜摄影和激光扫描相结合,能够获得高精度的三维建模结果,为相关领域的研究和应用提供了有力支持。近年来,倾斜摄影和激光扫描技术的快速发展为高精度三维建模提供了新的机遇和挑战。本文针对倾斜摄影与地面激光点云融合建模这一前沿领域展开研究,旨在通过相应的源代码实现精细化的建模过程。同时,使用激光扫描仪进行地面激光扫描,获取地面的点云数据。经过数据融合和精细化建模处理后,我们获得了高精度的三维建模结果。

LpmShell的博客 1245

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Codeforces Round #686 (Div. 3) C - Sequence Transformation

Codeforces Round #686 (Div. 3) C 大意:每次都可以删掉两个相同数字之间的不同数字,问最少多少次操作之后可以使得序列中只剩下一种数字. 举例: 1 2 2 2 3 1 1 1 1 1 1 0 1 1 1 1 2 1 1 2 3 4 5 1 思路:用队列去重,map当标记数组(记录),最后在几个特殊点判断一下就好了 AC代码 #include<iostream> #include<cstring> #include<algorithm> #i

z314591085的博客 183

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Codeforces Round #686 (Div. 3)E. Number of Simple Paths

Codeforces Round #686 (Div. 3)E. Number of Simple Paths 题意: 给一个有nnn个结点的基环树,求简单路径个数。 思路: 对于一个nnn个结点的无根树,其简单路径个数是Cn2=n(n−1)2C_{n}^2=\cfrac{n(n-1)}{2}Cn2​=2n(n−1)​,因为你可以选取任意两个不同的结点,他们直接都有一条简单路径。 现在加上一条边eee,对于每一对结点,都有两种不同的路径到达。 考虑对于环上一个结点uuu,其子树之间不能通过新增的路径eee产

Z7784562的博客 243

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Codeforces Round #686 (Div. 3) 1454E Number of Simple Paths

Codeforces Round #686 (Div. 3) 1454E Number of Simple Paths Problem Description You are given an undirected graph consisting of n vertices and n edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any ot

BenFromHRBUST的优快云博客 406

Codeforces Round #686 (Div. 3) C. Sequence Transformation 模拟

You are given a sequence a, initially consisting of n integers. You want to transform this sequence so that all elements in it are equal (i. e. it contains several occurrences of the same element). To achieve this, you choose some integer x that occurs at

qq_45891413的博客 328

基环树 Codeforces Round #686 (Div. 3) E题

基环树 Codeforces Round #686 (Div. 3) E题 题意: 给定一棵n个结点的基环树,求所有长度大于等于1的路径的个数 解析: 如果没有环的话,本来可以这么求, 因为有环,如果经过环的话,环里可以沿顺时针或逆时针,所以还要多加上 cnt[i] * (n-cnt[i]) cnt[i]代表环上挂着的子树的结点数,n-cnt[i]代表另外的那些结点,cnt[i]这些结点到另外的结点都有两路可以走。 如上图a到b 这样。 int main(){ scanf("%d",&t

weixin_44745441的博客 207

二分、RMQ/单调栈 Codeforces Round #686 (Div. 3) F题

二分、RMQ/单调栈 Codeforces Round #686 (Div. 3) F题 题意: 将数组恰分成三段,第一段的最大值 = 第二段的最小值 = 第三段的最大值 思路: 看到有博主用单调栈做,看着还挺繁琐的 然后学着用二分,RMQ做了一下 如何二分? 满足单调性 区间最大值随区间长度增大而增大 区间最小值随区间长度增大而减小 先枚举第一个分界点,然后二分第二个分界点, 如果max1 < min1 || max1 < max2 说明第二个分界点应该往右移,让最小值更小点,第二个最大值更

weixin_44745441的博客 215

【CodeForces】Codeforces Round #686 (Div. 3) CEF

好久没有div3场了,就去水了一场,队友先看了D,我看了C,队友AC了D题告诉我说简单题,然后我就跳了ABD这三题 C. Sequence Transformation 大致题意 给你一个数列,让你选择一个数列中已经存在的值xxx,然后重复进行一个操作:每次选择一个不含有xxx的区间并将其删除,请问最少需要多少次操作 分析 由于xxx是自己定的,所以简单来说就是找出一个xxx,将数列中的xxx移去后,数列断开的地方最少 简单的暴力题,无非是怎么样实现好看一点 AC code #include <bit

AC不动机的博客 586

Codeforces Round #686 (Div. 3) E

题目:E 题意:给定一个n个点n条边的连通图,问能组成的简单路径有多少种,不能的点构成的简单路径即不同的。 n个点n-1条边可以构成一个树形连通图另一条边加入必成环。 我们首先找到这个环,基于此进行操作。 1:环的不同的简单路径即Cn2∗2C_n^2*2Cn2​∗2,点到点两条不同的路径。 2:普通的连通图,即答案是Cn2C_n^2Cn2​ 我们首先完善环的个数,再将每一个环看作树根找到树的点size也就找到了边数,求解一个树的简单路径个数。 最后剩下第i棵树的子节点到其他树的子节点的个数,Ci1C_i^1

weixin_43958964的博客 246
上一篇: 信息学奥赛Sightseeing Trip(最小环路径+Floyd)
下一篇: Codeforces Round #200 (Div. 1)
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

你数过天上的星星吗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值