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 ...
随机推荐
- man命令中的文本操作
转自:http://www.cnblogs.com/chengmo/archive/2010/10/26/1861809.html 下面说下less命令操作: 光标移动操作: e ^E j ^N ...
- android图片缩小和放大Matrix
/**Bitmap放大的方法*/ private static Bitmap big(Bitmap bitmap) { Matrix matrix = new Matrix(); matrix.pos ...
- esc设置多站点 域名解析
你的域名是:a.com IP: 1.1.1.1 一 设置域名解析: 1.a.com 解析到 1.1.1.1 2.a.com 解析到 2.2.2.2 LOOP 二 到服务器上: 在1站点设置主机 ...
- 观察器observes与对象初始化
Demo.Person2 = Ember.Object.extend({ init: function() { alert('lljsd'); this.set('salutation', " ...
- ArcGis 统计方法
from:http://blog.sina.com.cn/s/blog_4177d50b0100fjbg.html 概述 一般常用的统计功能例如:唯一字段统计.数据行数统计.数据值求和统计等. 1.基 ...
- openstack虚拟机迁移的操作记录
需求说明:计算节点linux-node1.openstack:192.168.1.8 计算节点linux-node2.openstack:192.168.1.17 这两个计算节点在同一个控制节点下( ...
- S2小测--索引--视图
1. 关于Sql server 视图 视图是一个虚拟表,我们在查询视图的时候,实际上是对基础表的查询.视图不仅可以作为SELECT查询的目标,也可以作为修改语句的目 标.理论上它可以像普通的物理表一 ...
- [Elixir007] on_definition规范函数定义时的各种潜规则
1.需求 写一个基于memcache的cache模块, 需要在key前面加上特定的前缀, 所以user cache的原始的store函数应该写成 # user.exdef store(user_id, ...
- .net mvc Bundle 问题解决方案
使用.net MVC4 开发Web项目时,可以利用"Bundle"对Css.JS文件进行压缩打包,一方面可以减少数据加载的次数,另一方面可以减少数据传输量,但在实际使用中却遇到了问 ...
- python学习三
输入与输出 print()在括号中加上字符串,就可以向屏幕上输出指定的文字. >>>print('hello world')hello world print()函数也可以接受多个字 ...