题解 | Stammering Chemists-2019牛客暑期多校训练营第十场H题

题解 | Road Construction-2019牛客暑期多校训练营第十场G题 题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 示例2: 代码: #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); i++) #d... 阅读详情

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss
题目描述:
在这里插入图片描述
输入描述:
在这里插入图片描述
输出描述:
在这里插入图片描述
示例1:
在这里插入图片描述
题解:
在这里插入图片描述
代码:

#include <bits/stdc++.h>
using namespace std;

typedef array<pair<int, int>, 5> molecule;
molecule isomer[] = {
    { { {1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6} } }, // n-hexane
    { { {1, 3}, {2, 3}, {3, 4}, {4, 5}, {5, 6} } }, // 2-methylpentane
    { { {1, 4}, {2, 3}, {3, 4}, {4, 5}, {5, 6} } }, // 3-methylpentane
    { { {1, 4}, {2, 5}, {3, 4}, {4, 5}, {5, 6} } }, // 2,3-dimethylbutane
    { { {1, 4}, {2, 4}, {3, 4}, {4, 5}, {5, 6} } }, // 2,2-dimethylbutane
};

const char *name[] = {
    "n-hexane", "2-methylpentane", "3-methylpentane",
    "2,3-dimethylbutane", "2,2-dimethylbutane"
};

molecule canonicalize(molecule mol) {
    for (auto& p : mol) if (p.first > p.second) swap(p.first, p.second);
    sort(mol.begin(), mol.end());
    return mol;
}

map<molecule, int> moltype;

void init() {
    for (int i = 0; i < 5; i++) {
        molecule mol = isomer[i];
        int perm[7]; iota(perm + 1, perm + 7, 1);
        do {
            molecule cm = mol;
            for (auto& p : cm) {
                p.first = perm[p.first];
                p.second = perm[p.second];
            }
            moltype[canonicalize(cm)] = i;
        } while (next_permutation(perm + 1, perm + 7));
    }
}

int main() {
    init();
    int T; scanf("%d", &T);
    while (T--) {
        molecule mol;
        for (int i = 0; i < 5; i++)
            scanf("%d%d", &mol[i].first, &mol[i].second);
        puts(name[moltype.at(canonicalize(mol))]);
    }
    return 0;
}

更多问题,更详细题解可关注牛客竞赛区,一个刷题、比赛、分享的社区。
传送门:https://ac.nowcoder.com/acm/contest/discuss

题解 | Graph Games-2019牛客暑期多校训练营第三场A题 题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: You are given an undirected graph with N vertices and M edges. The edges are numbered from 1 to M. Denote the set S(x) as: All the vertice... 阅读详情

相关推荐

题解 | Move-2019牛客暑期多校训练营第六场D题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 题解: 代码: // // Created by Wu Junjie on 2019-06-30. // #include <bits/stdc++.h> const int MAXN = 1010; int n, k...

lastbye的博客 422

2019牛客暑期多校训练营(第十场)

今天感觉被队友带飞了 B Coffee Chicken 水题,不知道为啥写炸了一直在wa。。。队友dfs过了 赛后改改过了 #include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<=(b);++i) #define mem(a,x) memset(a,x,sizeof(a)) #define pb push_ba...

ccsu_deer 611

题解 | RNGs-2019牛客暑期多校训练营第四场H题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: typedef unsigned int u32; typedef unsigned long long u64; struct RNG { virtual void srand(u32 seed)=0; virtual bool gen()=0; }; struct RNG0...

lastbye的博客 394

H-Stammering Chemists

#include<bits/stdc++.h> using namespace std; #define maxn 10 vector<int>vec[maxn]; int du[maxn],vis[maxn]; int main(){ int t; scanf("%d",&t); while(t--){ for(int i=1;i<=10;i++) ...

slass-mot-odet 358

题解 | Blackjack-2019牛客暑期多校训练营第十场A题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 示例2: 题解: 代码: #include<bits/stdc++.h> using namespace std; typedef double db; const int maxn=505; int d[maxn],n...

lastbye的博客 357

检测装置管理培训.pdf

技术分享

2019牛客暑期多校训练营(第十场场)Stammering Chemists (水题

题目来源: https://ac.nowcoder.com/acm/contest/890/H 题意: 给你5组两个节点关系,让你判断属于下面哪个同分异构体。 思路: 输入记录度数,判断度数,来区别同分异构体。 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define IOS ios:...

nuoyanli的博客 1548

执行力训练.pdf

技术分享

题解 | Wood Processing-2019牛客暑期多校训练营第十场J题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 示例2: 题解: 代码: #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); i+...

lastbye的博客 505

1.STM32H743VGT6最小系统板

此款MCU具备较大算力进行频谱运算,为复杂数据运算提供更高效的保障。该MCU具备REV-V和REV-Y两个型号,后者为新版本。

Audiation88的博客 3813

从临床试验到互联网AB测试:边缘结构模型(MSM)如何解决‘时依性混杂’这个老大难问题

本文探讨边缘结构模型(MSM)如何解决时依性混杂问题,适用于临床试验和互联网AB测试。通过逆概率加权(IPTW)等方法,MSM能有效剥离混杂效应,准确评估长期干预效果。文章结合跨领域案例,详细解析MSM的核心原理、实施步骤及在推荐算法效果评估中的实战应用,帮助读者掌握这一先进因果推断工具。

weixin_28725949的博客 211

题解 | Guessing ETT-2019牛客暑期多校训练营第三场C题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: ZYB is a smart guy. One day he learns a new method for representing trees: Euler tour technique (ETT). 、 You can find more details about ETT...

lastbye的博客 749

群晖NAS变身私有Git服务器:DS218+部署与TortoiseGit客户端实战指南

本文详细介绍了如何将群晖NAS(如DS218+)变身为私有Git服务器,并配置TortoiseGit客户端实现高效代码管理。通过硬件检查、系统更新、Git Server套件安装及权限配置等步骤,帮助开发者在局域网内搭建安全、高速的代码托管环境,特别适合小团队协作。

weixin_29252171的博客 231

题解 | Go on Strike!-2019牛客暑期多校训练营第二场C题

**题目来源于牛客竞赛:**https://ac.nowcoder.com/acm/contest/discuss 题目描述: There are N cities in Eddy’s neverland. There are some flights to connect some pair of cities. Except flight, there’s no any other way t...

lastbye的博客 517

告别手动改Hex!用Vector HexView命令行5分钟搞定固件数据“乾坤大挪移”

本文详细介绍了如何利用Vector HexView命令行工具快速实现嵌入式固件数据的自动化迁移,告别手动修改Hex文件的繁琐流程。通过实战案例和脚本示例,展示了如何5分钟内完成数据地址范围的重新映射,提升嵌入式开发效率,特别适用于烧录文件的内存布局调整。

weixin_30635053的博客 715

Oracle EBS报表开发入门:Report Builder安装避坑指南(Win10/11兼容版)

本文详细介绍了在Windows 10/11系统上成功安装和配置Oracle Report Builder的完整避坑指南。通过修改系统兼容性、解决虚拟内存报错、正确设置NLS_LANG和TNS连接等关键步骤,确保开发环境稳定运行。同时,阐述了Report Builder与BI Publisher在现代Oracle EBS报表开发中的协作定位与工作流,帮助开发者高效搭建报表开发环境。

d6e7f8的博客 762

题解 | Travel Dream-2019牛客暑期多校训练营第十场I题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 示例2: 题解: 代码: #include<bits/stdc++.h> using namespace std; const int inf=1000000007; int a[305][305],d[2][305][...

lastbye的博客 429

【Agent】AI Agent架构趋势及演进

本文系统介绍了AI Agent架构的发展趋势和技术框架,涵盖单Agent与多Agent系统设计、提示词工程与上下文管理、SpringAI开发框架等关键技术。重点阐述了AI原生应用参考架构,包括Nacos配置管理、Higress AI网关、RocketMQ会话状态管理等核心组件解决方案。同时深入探讨了AI应用可观测性体系,包含OpenTelemetry全链路追踪、关键指标监控以及基于LoongSuite开源工具的数据采集评估方法,为构建高效可靠的AI应用提供了全景式技术参考。

一个内容严谨、方向前沿、极具实践价值的AI大模型技术分享站 1111

题解 | K-ary Heap-2019牛客暑期多校训练营第六场F题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 题解: 代码: #include <bits/stdc++.h> const int N = 3010; const int moder = (int) 1e9 + 7; typedef std::pair <in...

lastbye的博客 385

【python数据挖掘课程】二十八.基于LDA和pyLDAvis的主题挖掘及可视化分析

这是《Python数据挖掘课程》系列文章,前面很多文章都讲解了数据挖掘、机器学习,这篇文章主要讲解LDA和pyLDAvis算法,同时讲解如何读取CSV文本内容进行主题挖掘及可视化展示。文章比较基础,希望对你有所帮助,提供些思路,也是自己教学的内容。推荐大家购买作者新书《Python网络数据爬取及分析从入门到精通(分析篇)》,如果文章中存在错误或不足之处,还请海涵。 目录: 一.显示结果及安装 二.LDA主题挖掘 三.pyLDAvis可视化分析 四.小结

杨秀璋的专栏 1万+

用C#+Avalonia写跨平台串口工具:Windows/macOS/Linux通吃,还能解析Modbus+画实时曲线

不管是串口还是蓝牙,核心操作都是“打开连接、发数据、收数据、关连接”,先定义一个// 通信设备接口:统一串口/蓝牙的操作// 连接状态变化事件(UI层订阅)// 接收数据事件(收到数据后触发)// 通信配置(不同设备配置不同,用泛型)// 通信设备接口:统一串口/蓝牙的操作 public interface ICommDevice : IDisposable {// 连接状态变化事件(UI层订阅) event Action < bool > OnConnectionChanged;

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 1005

题解 | Trees in the Pocket II-2019牛客暑期多校训练营第三场E题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 题解: 代码: #include<bits/stdc++.h> #define rep(i,n) for(int i=1;i<=n;++i) #define eb emplace_back using nam...

lastbye的博客 379

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

题解 | tree-2019牛客暑期多校训练营第四场G题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 题解: 代码: #include<bits/stdc++.h> using namespace std; typedef unsigned int u32; typedef pair<int,int> pii;...

lastbye的博客 367

老版QQ原生表情gif动态

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

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

题解 | Removing Stones-2019牛客暑期多校训练营第三场G题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 题解: 代码: #include<cstdio> #include<cstring> #include<algorithm> #include<cassert> using namespa...

lastbye的博客 365

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

题解 | Gifted Composer-2019牛客暑期多校训练营第十场C题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 示例2: 题解: 示例1: #include <bits/stdc++.h> using namespace std; typedef long long LL; const int MAXN = 1 << ...

lastbye的博客 352

题解 | Androgynos-2019牛客暑期多校训练营第六场E题

题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss 题目描述: 输入描述: 输出描述: 示例1: 题解: 代码: #include <bits/stdc++.h> using std::min; const int max_N = (int)2e3 + 21; bool map[max_N][max_N]; in...

lastbye的博客 338
上一篇: 题解 | Road Construction-2019牛客暑期多校训练营第十场G题
下一篇: 题解 | Travel Dream-2019牛客暑期多校训练营第十场I题
牛客竞赛
博客等级 码龄7年 9粉丝 97原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值