Bzoj3943 [Usaco2015 Feb]SuperBull
3943: [Usaco2015 Feb]SuperBull
Time Limit: 10 Sec Memory Limit: 128 MB
Submit: 300 Solved: 185
Description
Input
Output
Sample Input
3
6
9
10
Sample Output
HINT
Source
/*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int mxn=;
int read(){
int x=,f=;char ch=getchar();
while(ch<'' || ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>='' && ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int n;
int w[mxn];
long long ans;
int dis[mxn];
void Prim(){
for(int i=;i<=n;i++)dis[i]=w[i]^w[];
dis[]=-;
for(int i=;i<n;i++){
int mx=,pos=;
for(int j=;j<=n;j++){if(dis[j]>mx)mx=dis[j],pos=j;}
ans+=mx;dis[pos]=-;
for(int j=;j<=n;j++){
if(dis[j]!=-)dis[j]=max(dis[j],w[j]^w[pos]);
}
}
return;
}
int main(){
n=read();
for(int i=;i<=n;i++)w[i]=read();
Prim();
printf("%lld\n",ans);
return ;
}
Bzoj3943 [Usaco2015 Feb]SuperBull的更多相关文章
- 【BZOJ3943】[Usaco2015 Feb]SuperBull 最小生成树
[BZOJ3943][Usaco2015 Feb]SuperBull Description Bessie and her friends are playing hoofball in the an ...
- 【BZOJ3943】[Usaco2015 Feb]SuperBull 最大生成树
[BZOJ3943][Usaco2015 Feb]SuperBull Description Bessie and her friends are playing hoofball in the an ...
- [bzoj3943][Usaco2015 Feb]SuperBull_Kruskal
SuperBull bzoj-3943 Usaco-2015 Feb 题目大意:贝西和她的朋友们在参加一年一度的“犇”(足)球锦标赛.FJ的任务是让这场锦标赛尽可能地好看.一共有N支球队参加这场比赛, ...
- 【bzoj3943】[Usaco2015 Feb]SuperBull
题目描述 Bessie and her friends are playing hoofball in the annual Superbull championship, and Farmer Jo ...
- BZOJ 3943: [Usaco2015 Feb]SuperBull 最小生成树
Code: // luogu-judger-enable-o2 #include<bits/stdc++.h> #define setIO(s) freopen(s".in&qu ...
- BZOJ 3943 [Usaco2015 Feb]SuperBull:最大生成树
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3943 题意: 有n只队伍,每个队伍有一个编号a[i]. 每场比赛有两支队伍参加,然后选一支 ...
- 【BZOJ3940】【BZOJ3942】[Usaco2015 Feb]Censoring AC自动机/KMP/hash+栈
[BZOJ3942][Usaco2015 Feb]Censoring Description Farmer John has purchased a subscription to Good Hoov ...
- 3942: [Usaco2015 Feb]Censoring [KMP]
3942: [Usaco2015 Feb]Censoring Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 375 Solved: 206[Subm ...
- bzoj3940: [Usaco2015 Feb]Censoring
AC自动机.为什么洛谷水题赛会出现这种题然而并不会那么题意就不说啦 .终于会写AC自动机判断是否是子串啦...用到kmp的就可以用AC自动机水过去啦 #include<cstdio> #i ...
随机推荐
- mongoVUE1.5.3 破解方法
MongoVUE是个免费软件,但超过15天后功能受限.可以通过删除以下注册表项来解除限制: [HKEY_CURRENT_USER\Software\Classes\CLSID\{B1159E65-82 ...
- 替换空格-请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
class Solution { public: void replaceSpace(char *str,int length) { char *tmp; ; int i; ;i<length; ...
- Linux Linux程序练习十一(网络编程大文件发送UDP版)
//网络编程发送端--大文件传输(UDP) #include <stdio.h> #include <stdlib.h> #include <string.h> # ...
- 使用ajax跨域withCredentials的作用
默认情况下,跨源请求不提供凭据(cookie.HTTP认证及客户端SSL证明等).通过将withCredentials属性设置为true,可以指定某个请求应该发送凭据.如果服务器接收带凭据的请求,会用 ...
- JavaScript开发规范要求
http://www.cnblogs.com/webflash/archive/2010/06/11/1756255.html 作为一名开发人员(WEB前端JavaScript开发),不规范的开发不仅 ...
- 修改Matlab 2012b默认工作路径
MATLAB的路径有多种,这里只讲一下启动时设置成MATLAB的用户的默认工作路径. 本人不想去改MATLAB的原来系统文件,而是尽量利用startup.m.这个文件默认在'/home/r/文档/MA ...
- EL表达式 (详解)
L表达式 1.EL简介 1)语法结构 ${expression} 2)[]与.运算符 EL 提供.和[]两种运算符来存取数据. 当要存取的属性名称中包含一些 ...
- LINUX信息安全系统设计基础第一周学习总结
Linux系统简介 一.实验内容 了解 Linux 的历史,Linux 与 Windows 的区别等入门知识. 二.实验要求 阅读linux简介与历史 三.实验步骤 二.Linux 与 Window ...
- MMDrawerController第三方库的使用(根据导航item+滚动条progressView实现的手势滑动切换视图的)
https://github.com/mutualmobile/MMDrawerController MMDrawerControlleris边抽屉导航容器视图控制器用来支持越来越多的应用程序利用抽屉 ...
- C#基础之枚举
1.认识Enum 以前一直以为Enum是值类型,在VS中查看Enum的定义时才发现它是一个抽象的类.但是这个类很奇怪,Enum继承了ValueType这个很熟悉的值类型基类,它是唯一一个继承自Valu ...