CF GYM 100548 International Collegiate Routing Contest(2014ACM西安现场赛Problem I)

CF GYM 100548 Color(2014ACM西安现场赛Problem F) 知识点: 组合数学-容斥原理,快速幂,逆元。 题目大意: 共有m 种颜色,为n盆排成一直线的花涂色。要求相邻花的颜色不相同,且使用的颜色恰好是k种。问一共有几种涂色方案(结果除10e9+7取余数)。 解题思路: 首先可以将m 与后面的讨论分离。从m 种颜色中取出k 种颜色涂色,取色部分有C(m, k) 种情况; 然后通过尝试可以发现,第一个有k种选择,第二个因不能与第一个相同,只有(k-1) 种选择,第三个也只需与第二个不同,也有(k-1) 种选择。总的情况数为k ×(k-1)^(n-1)。但这仅保证了相 阅读详情

ProblemI. International Collegiate Routing Contest


Description

You may know thatBluegao University (formly Bluefly University) is famous ofnetworking technology. One day, their headmaster Yuege received aspecial router, along with a task about routing table.

In this problem,routing table is a (probably) big table with several items, each itemrepresents a subnet. The router has limited function, it can onlydeal with two next-hops and one main routing table. Packets will besend to next hop A if there exists a subnet containing thedestination of the packet in the main routing table. Otherwise theywill be send to next hop B.

You may know that,IPv4 uses 32-bit (four-byte) addresses, which limits the addressspace to 4294967296 (2^32) addresses. IPv4 addresses may be writtenin any notation expressing a 32-bit integer value, for humanconvenience, they are most often written in the dot-decimal notation,which consists of four octets of the address expressed individuallyin decimal and separated by periods. But their binary notation isalso very useful. For example, IP address 128.2.142.23 can beexpressed in dot-binary notation as10000000.00000010.10001110.00010111.

A subnet is a blockof adjacent IP addresses with exactly same binary prefix, and usuallywritten as the first IP address in its address space together withthe bit length of prefix, like “202.120.224.0/24”. If an IPaddress is in the range of an subnet, we say that this subnetcontains the IP address.

Yuege’s task isto invert the behaviour of his router, make all packets currentlyrouted to hop A route to hop B, and vice versa. Also he wants to keepthe size of the main routing table as small as possible, forperformance.

In short, for agiven routing table (i.e. a bunch of subnets), we need to get its“complement”, i.e. calculate a minimum set of subnets which haveno intersection with given subnets, and their union must be the wholeIPv4 address space.

Remember thatBluegao University is famous of networking tech, as headmaster ofBluegao University, Yuege definitely knows how to solve such problem,but he is too lazy to code, so he turns to you for help.


Input

The first line ofthe input gives the number of test cases, T. T test cases follow.

For each test case,the first line contains an integer n (0 ≤ n ≤ 30000), the numberof subnets. Next n lines, each contains a subnet in the format ofa.b.c.d/l, a, b, c, d, l are all integers, 0 ≤ a, b, c, d < 256,0 ≤ l ≤ 32.

Note that even if l= 32, the “/32” part should not be omitted. And if l = 0, the IPaddress part must be “0.0.0.0”.


Output

For each test case,first output one line “Case #x:”, where x is the case number(starting from 1). Then on the second line print an integer nindicates the number of subnets in your answer. Next n lines eachline contains a subnet in the same format as input. You may outputthem in any order.


Samples

Sample Input

Sample Output

3

0

1

0.0.0.0/1

1

128.0.0.0/1

Case #1:

1

0.0.0.0/0

Case #2:

1

128.0.0.0/1

Case #3:

1

0.0.0.0/1



知识点:

Trie树,二进制。

题目大意:

输入IPv4地址空间中的一些子网号,构成一个网络集合。

输出最小的一个网络集合,要求其与输入集合没有交集,且相对IPv4地址空间全集,是输入集合的补集。输出集合包含的子网号,格式遵循网络规范。


解题思路:

每个IP地址由32位二进制组成。整个地址空间可以表现为一棵二叉树(简化的Trie树),如下图所示:











图中表示的是以下4个子网的覆盖情况:

0.0.0.0/1 (二进制前1位是0)

32.0.0.0/3(二进制前3位是001)

128.0.0.0/2 (二进制前2位是10)

224.0.0.0/3 (二进制前3位是111)

图中的红色节点代表网络覆盖的终结点,这一网络号覆盖红色节点下的完整一支;黄色节点也是包含在这个网络中的,

题目要求的就是树上没有被输入集合覆盖的分支。不能与红、黄节点有任何覆盖。


建立Trie树后,DFS遍历树上的分支,输出没有被覆盖的分支即可。


实现技巧:

使用bitset,简化十进制与二进制的转换。



参考代码:

#include <iostream>
#include <cstring>
#include <bitset>
#include <cstdio>
#include <vector>
using namespace std;

const int MAXN = 500010;
int n, nCase, cCase;
bool value[MAXN], root[MAXN];
int L[MAXN], R[MAXN], cnt;
bitset<32> bit(0);
vector<pair<bitset<32>, int> > ans;

void init() {
    memset(value, false, sizeof(value));
    memset(root, false, sizeof(root));
    memset(L, -1, sizeof(L));
    memset(R, -1, sizeof(R));
    cnt = 1;
    ans.clear();
}

void insert(const bitset<32> &bit_ip, int deep, int max_deep, int rt) {
    value[rt] = true;
    if (deep == max_deep) {
        root[rt] = true;
        return;
    }
    if (!bit_ip[32-deep-1]) {
        if (L[rt] == -1) L[rt] = ++cnt;
        insert(bit_ip, deep+1, max_deep, L[rt]);
    } else {
        if (R[rt] == -1) R[rt] = ++cnt;
        insert(bit_ip, deep+1, max_deep, R[rt]);
    }
}

void query(int deep, int rt) {
    if (root[rt]) return;
    if (rt == -1) {
        ans.push_back(make_pair(bit, deep));
        return;
    }
    bit[32-deep-1] = 1;
    query(deep+1, R[rt]);
    bit[32-deep-1] = 0;
    query(deep+1, L[rt]);
}

void input() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a[15];
        scanf("%d.%d.%d.%d/%d", &a[0], &a[1], &a[2], &a[3], &a[4]);

        long long ip = 0;
        for (int j = 0; j < 4; j++) {
            ip = (ip * 256) + a[j];
        }
        bitset<32> bit_ip(ip);
        insert(bit_ip, 0, a[4], 1);
    }
}

void solve() {
    printf("Case #%d:\n", ++cCase);
    if (n == 0) {
        printf("1\n0.0.0.0/0\n");
        return;
    }

    query(0, 1);

    printf("%d\n", ans.size());
    for (int k = 0; k < ans.size(); k++) {
        for (int i = 3; i >= 0; i--) {
            int a = 0;
            for (int j = 7; j >= 0; j--) {
                a = a * 2 + ans[k].first[i*8+j];
            }
            printf("%d", a);
            if (i) printf(".");
        }
        printf("/%d\n", ans[k].second);
    }
}

int main() {
    scanf("%d", &nCase);
    while (nCase--) {
        init();
        input();
        solve();
    }
    return 0;
}


利用恒源云在云端租用GPU服务器训练YOLOv10模型(包括Linux系统命令讲解) 为当涉及到深度学习的训练任务时,GPU的计算能力是不可或缺的。相对于传统的中央处理器(CPU),图形处理器(GPU)具有更强大的并行计算能力,能够显著加速深度学习模型的训练过程。深度学习算法通常涉及大量的矩阵运算和张量操作,而GPU的并行计算架构使得它们能够高效地执行这些计算,从而加速模型训练的速度。恒源云是一个经济高效的云计算平台,您可以通过恒源云的控制台或者命令行界面来管理实例、上传和下载数据、执行训练任务等。 阅读详情

相关推荐

DINOv2 基于自定义数据集进行图片分类预测

(前提是安装好pytorch)1. pip安装2. 下载dinov2提供的预训练模型,需要自行前往网站上查找dinov2模型进行下载。模型需要下载三个文件:下载完成后将上述三个文件放置在本地一个名为dinov2_base的文件夹中即可。

sinat_34770838的博客 6671

Problem I. International Collegiate Routing ContestGym - 100548I

题目意思是,说给予n个32位IP地址,每个地址的后面有一个K,每个K代表与当前所给的IP地址的前K位相同的话,就为同一IP地址,然后问你,最少再补充多少的IP地址使得能构成所有的IP地址。  思路:字典树的题目,对于每个32位的串,输入字典树中,如果当前K小于32那么就只导入到第K位,然后在当前节点做标记,建完树后,跑一遍DFS就可以了。 #include #include #includ

落风听雨 381

2025美赛数学建模C题完整原创论文来啦(含python代码及运行结果)

我论文很多的篇幅需要用来解释我为什么要这么做,基本就是手把手教你怎么做,并且我还要照顾每个人的水平,所有会有大量的黄字提醒,甚至写得有点唠叨,一些中间过程和结果分析展现得事无巨细,你们自己删减浓缩到25页。全文用Python求解,py不需要你搭建环境,我会录制一个操作复现视频,你无脑拖动我给你的代码点运行就可以,不需要你懂代码。本论文可以保证原创,保证高质量。大家好呀,从发布赛题一直到现在,总算完成了数学建模美赛本次题目。C题论文共64页,一些修改说明9页,正文55页,附录没粘贴。

smppbzyc的博客 1713

Codeforces GYM 100548 I - International Collegiate Routing Contest 2014 ACM Xian Regional Contest

比赛的时候愣是没看懂这一题是啥意思,最后队友写完了觉得有问题也木有submit== 前面说了一大串反转路由表,in short之后就是说取个当前子网集合的补集,全集是整个IPV4地址空间。我当时一直纠结main routing table as small as possible是为何,现在觉得是防止两个子网可以用一个子网代替的case吧,比如11100000.0.0.0/4+11110000.

TimeForMiracles 1354

QT窗体大小控制全攻略:从setFixedSize到事件过滤器的进阶用法

本文深入探讨了QT窗体尺寸控制的进阶实践,从基础的setFixedSize方法到结合事件过滤器实现智能动态适配。通过分析窗口状态变化、多显示器环境处理以及布局策略,提供了实现禁止缩放但支持最大化、多屏智能适配及动态约束等复杂场景的完整解决方案与核心代码示例。

weixin_29229261的博客 304

Dify保姆级教程:从零搭建AI知识库,让大模型真正懂你的文档

通用大模型的知识边界来自公开语料,面对企业内部制度、产品手册等私有内容,往往只能靠“猜”,由此产生幻觉。要解决这个问题,需要借助检索增强生成(RAG)技术,为模型配置一个外挂资料库。RAG的原理类似开卷考试:先对文档进行文本切分、向量化,再在提问时检索语义相关的片段,交由大模型生成答案。Dify作为开源AI知识库平台,将文档导入、分段设置、向量索引、召回测试等复杂链路封装成可视化操作,让产品经理、运营等非研发人员也能独立搭建企业级问答助手。本文从环境部署、模型接入、参数调优到多知识库维护,完整覆盖一条可落地

weixin_29039773的博客 228

CF GYM 100548 International Collegiate Routing Contest(2014ACM西安现场赛Problem I)不懂提

参考:http://blog.csdn.net/wujysh/article/details/43085233 ProblemI. International Collegiate Routing ContestDescriptionYou may know thatBluegao University (formly Bluefly University) is famous ofnetwork

now_ing的博客 377

github创建账号第一步始终出错

github创建账号总结:第一次注册GitHub,填好用户名邮箱密码后进入下一步就卡在哪里,上面还提示Unable to verify your captcha response等,进入网址的解决办法以及下载其他的浏览器也无法解决,用手机浏览器抱着试一试的心态竟然成功了,分享给大家。手机下载谷歌浏览器,进入GitHub正常注册,能向下继续,邮箱验证完以后再用电脑登陆就ok啦

计算机毕业论文源码,学生个人网页制作html源码。贴近用户做网络推广和互联网优化。 4386

Gym - 100548I International Collegiate Routing Contest (01字典树)

  题意:给你多个子网掩码,要你求一个最小的子网掩码补集。   解题思路:IPV4一共有 2^32个地址,实际上对应的就是一个完全字典树。现在给定的子网掩码,实际上就是给定了一个字典树,然后要你求这个字典树的补树,使得是一个完全字典树。实际上就是求这个字典树的所有补树形成的森林。 那么我们只要深搜即可。然后记录下答案,然后还原下答案即可。   #include &lt;bits/...

LP_Cong 614

端到端自动驾驶的精准测试场景开发

1. 背景介绍 自动驾驶技术的发展正在改变交通运输的未来,然而,要实现安全可靠的自动驾驶,需要进行大量的测试和验证。端到端自动驾驶系统的测试场景开发是实现这一目标的关键。本文将详细介绍端到端自动驾驶的精准测试场景开发,包括核心概念、算法原理、数学模型、项目实践,以及未来发展趋势。 2. 核心概念与联系

AGI×大数据,开启智能时代的认知跃迁;解码AGI,赋能数据驱动的智能革命。 1322

X书关键词协议搜索

【代码】X书关键词协议搜索。

Codeooo 博客 6387

2014 icpc 西安现场赛 I - International Collegiate Routing Contest

-0-马上上计网了,感觉没什么空再看笛卡尔树了2333来水篇博客 还一个多礼拜就要去西安当分母了。第一次当分母内心还有点小紧张2333 然后我们来看看这个强行银牌题。。 队友还是强啊,五分钟把铜牌题公式甩我脸上了然鹅QWQ 这个银牌题其实也不是很难(如果看得懂题的话) 首先把所有ip换成二进制表示,题目表示如果有效前缀相同那么他们在一个子网内。 那么怎么才算有效前缀呢。看/后面那个数字,

OneDay_pyf的博客 1014

YOLOv26与其他目标检测算法的对比分析

本文对YOLOv26与其他主流目标检测算法进行了全面对比分析。YOLOv26在COCO数据集上达到96.0% mAP@0.5和79.0% mAP@0.5:0.95,显著优于其他YOLO系列算法,同时保持85FPS的推理速度和35MB的轻量级模型。相比两阶段算法(如Faster R-CNN),YOLOv26在速度、模型大小和内存占用方面优势明显;相比Anchor-free算法(如CenterNet),YOLOv26在速度和模型压缩方面更优。其核心创新包括动态锚框分配、自注意力机制和轻量级设计,使其成为适用于复

一键难忘的博客 1003

西安现场赛 Problem I. International Collegiate Routing Contest

题目大意: 给你一些ip地址,ip地址的表示方式点分十进制加子网掩码,让你求出与给出的网络号没有重复网段并且所有网络号合并可以组成整个网络同时保证你列举 出来的网络数量最少,将网络地址输出。 这道题目模型是一棵树,问题可以抽象成询问需要加多少个节点使得树的每一个父亲都有两个儿子。 树的表示方法深度表示的ip中的第几位,一个节点遇到0到左儿子遇到1到右儿子,这样每个ip地址都可以用树上的一

ying_5的专栏 789

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

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

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

UVALive - 7043-International Collegiate Routing Contest

You may know that Bluegao University (formly Bluey University) is famous of networking technology. One day, their headmaster Yuege received a special router, along with a task about routing table. In

algzjh的博客 642

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

UVALive 7043 International Collegiate Routing Contest 字典树

题意:给你一些子网 让你计算出最少的子网数 使得两者的并集为所有的ip地址 并且二者没有交集 思路:貌似只要有关ip地址的都要上字典树... 对于每一个输入的网段 我们将其转化为二进制形式并保存在Trie树中 如果存储到子网掩码的最后一位 则将其接下来链接的0和1用一个特殊的标记标记上 代表从这往后地址都属于我这一网段的子网地址 然后查询那些没有被“堵住”的地址 如何查询呢 我用的是动态分配的写

s_h_r 975

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

gym 100548题解(2014年西安现场赛(回文树,01字典树,容斥))

Problem A. Built with Qinghuai and Ari Factor水题就是看是不是所有数字都是3的倍数水题就是看是不是所有数字都是3的倍数Problem F. Color容斥题,m个颜色里选k个,然后给一个长度n的路涂色,每格一个颜色,相邻不能相同,求方案数容斥题,m个颜色里选k个,然后给一个长度n的路涂色,每格一个颜色,相邻不能相同,求方案数 ans=C(m,k)×(k

Miracle_ma的专栏 1101

CF GYM 100548 The Problem to Make You Happy(2014ACM西安现场赛Problem H)

知识点: 有向图,博弈论,动态规划。 题目大意: Alice和Bob两人玩游戏。两人各有一个棋子,开始时在有向图中不同的点上。Bob先手,两人轮流移动棋子,每次只能将棋子移到相邻的点上(沿着图上的有向边),不断重复这样的过程,当那人无法移动时,他就输了(规则1)。 还有两条附加规则:任何时候,当两个棋子到达同一点时,Alice胜出(规则2)。如果游戏永远无法结束,Bob胜出(规则3)。 两人都遵循最优策略,轮流移动棋子,问最终谁会赢。图中没有自环和重边。 解题思路: 根据博弈论的性质,一个局面是必胜态的充

wujy的专栏 2493

gym-100548G-回文树

题意:给你两个字符串,问你这两个字符串中相同的回文子串的乘积和 解题思路:建立两颗树,然后一起遍历这两颗树就行了,因为是回文树的特点,如果当前两棵树都出现了某一回文子串,那么这回文子串的长度-2也一定出现了,按照这个规律,直接dfs遍历 #include<bits/stdc++.h> #include <cstdio> #include <cstring&...

weixin_30322405的博客 143

UVALive 7043 International Collegiate Routing Contest(字典树)

思路:读懂题目....这很关键.... #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int N=3*1e4+10; const int ma

围巾的ACM博客 754

CF GYM 100548 Last Defence(2014ACM西安现场赛Problem K)

知识点: Ad-Hoc,辗转相除法。 题目大意: 给定数列S的首两项,要求之后的各项满足Si= |Si−1 − Si−2|(前两项差值的绝对值)。问整个数列S中不同的数字个数。 解题思路: 首先容易发现,当i足够大时,最后一定会出现“xx0xx0...”这样的重复。所以不同数字个数一定是有限的。 究其原因,对于数y和x,y一定能写成kx+b的形式,在数列的生成过程中,会出现kx+b、x、(k-1)x+b、(k-2)x+b、x、...、2x+b、x、x+b、b、x,其中出现的不同数字个数就是(kx+b)/

wujy的专栏 2355

UVALive 7043 International Collegiate Routing Contest 字典树,递归

题目链接:这里 题意:给出n个IPv4的子网地址,格式是a-b-c-d/l,a b c d l都是十进制数,然后l是网络地址的长度,最长到32,要求输出最低限度的所有的未能划分出的子网地址,这些子网和给出的n个子网没有交集,这些地址和给出的n个地址能组成完整的网络地址。 解法:把所有的ip地址插进字典树,并且标记单词节点,之后然后暴力递归找所有未被包含在已有子网里的子网地址。其实就是trie树上

I good vegetable a! 466

ZOJ3822 ACM-ICPC 2014 亚洲区域赛牡丹江赛区现场赛D题Domination 概率DP

Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his frie

Puyuacm的专栏 2635

Gym100548H

2014西安赛区的H,是一道有向图上的博弈问题 首先我们要确定一下结束状态,一种是两点重合,还有一种是没法移动棋子 接下来我们把结束状态放在队列的队首,倒退之前的状态 我用1表示Alice必胜,2表示Bob必胜,3表示平局,分了4种情况 1、轮到Bob,状态为1,dp[x][y][1]=1,那么之前能到达y的点dp[x][v][0]=1 2、轮到Alice,状态为2,dp[x][y][0]

MatouKariya的专栏 579

GYM 100827 E.Hill Number(数位DP)

Description 定义hill number为各位数字从高位到低位先增再减,也可以只增或只减,现在给出一个整数s,首先判断s是否是一个hill number,如果是则统计所有不大于s的hill number数量 Input 第一行一整数T表示用例组数,每组用例输入一个长度不超过70位的数字串表示s Output 如果s不是一个hill number则输出-1,否则输出1~s中有多少h

ZSQ 1091

2015 ACM Amman Collegiate Programming Contest训练总结【12/12】

题目连接:戳我戳我 训练结果:Rank 43 Ac题数:12 总罚时:1363 A.水题.结构体排序。 B.O(n^2)枚举一下x和y,然后通过n-x-y来得到z,判定是否胜利的时候,我们维护一个前缀和就可以O(1)查询了。过程统计一下可行方案数即可。 C.贪心水题,我们从左往右看,如果有一个位子此时没有被原先的灯照亮,那么我们在这个位子的右边放置一个灯即可。

mengxiang000000 587
上一篇: CF GYM 100548 Last Defence(2014ACM西安现场赛Problem K)
下一篇: CF GYM 100548 Color(2014ACM西安现场赛Problem F)
wujy47
博客等级 码龄19年 16粉丝 60原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值