2014 ACM-ICPC Beijing Invitational Programming Contest
点击打开链接
Happy Reversal
pid=34987" rel="nofollow" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="text-decoration:none;font-family:'Trebuchet MS', Helvetica, Arial, sans-serif;font-size:1.1em;border:1px solid rgb(204,204,204);background-color:rgb(238,238,238);font-weight:bold;color:rgb(68,68,68);display:inline-block;overflow:visible;">Prev
Submit Statuspid=34988" rel="nofollow" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="text-decoration:none;font-family:'Trebuchet MS', Helvetica, Arial, sans-serif;font-size:1.1em;border:1px solid rgb(204,204,204);background-color:rgb(238,238,238);font-weight:bold;color:rgb(68,68,68);display:inline-block;overflow:visible;">Statistics
Discusspid=34989" rel="nofollow" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="text-decoration:none;font-family:'Trebuchet MS', Helvetica, Arial, sans-serif;font-size:1.1em;border:1px solid rgb(204,204,204);background-color:rgb(238,238,238);font-weight:bold;color:rgb(68,68,68);display:inline-block;overflow:visible;">Next
+
-
NoneGraph Theory
2-SAT Articulation/Bridge/Biconnected Component
Cycles/Topological Sorting/Strongly Connected Component
Shortest Path
Bellman Ford Dijkstra/Floyd Warshall
Euler Trail/Circuit
Heavy-Light Decomposition
Minimum Spanning Tree
Stable Marriage Problem
Trees
Directed Minimum Spanning Tree
Flow/Matching Graph Matching
Bipartite Matching
Hopcroft–Karp Bipartite Matching
Weighted Bipartite Matching/Hungarian Algorithm
Flow
Max Flow/Min Cut
Min Cost Max Flow
DFS-like Backtracking with Pruning/Branch and Bound
Basic Recursion
IDA* Search Parsing/Grammar
Breadth First Search/Depth First Search
Advanced Search Techniques
Binary Search/Bisection
Ternary Search
Geometry
Basic Geometry Computational Geometry
Convex Hull
Pick's TheoremGame Theory
Green Hackenbush/Colon Principle/Fusion Principle
Nim
Sprague-Grundy Number
Matrix Gaussian Elimination
Matrix Exponentiation
Data Structures
Basic Data Structures
Binary Indexed Tree
Binary Search Tree
Hashing Orthogonal Range Search
Range Minimum Query/Lowest Common Ancestor
Segment Tree/Interval Tree
Trie Tree
Sorting Disjoint Set
String
Aho Corasick Knuth-Morris-Pratt
Suffix Array/Suffix Tree
Math
Basic Math Big Integer Arithmetic
Number Theory
Chinese Remainder Theorem
Extended Euclid
Inclusion/Exclusion
Modular Arithmetic
Combinatorics Group Theory/Burnside's lemma
Counting
Probability/Expected Value
Others Tricky
Hardest Unusual
Brute Force
Implementation Constructive Algorithms
Two Pointer
Bitmask Beginner
Discrete Logarithm/Shank's Baby-step Giant-step Algorithm
Greedy
Divide and Conquer
Dynamic Programming
Tag it!
after operation "NOT A", A will be 0110010).
Input
The length of each binary number is K.
Output
For each case, first output the case number as "Case #x: ", and x is the case number. Then you should output an integer, indicating the maximum result that Elfness can get.
Sample Input
2
5 6
100100
001100
010001
010001
111111
5 7
0001101
0001011
0010011
0111000
1001011
Sample Output
Case #1: 51
Case #2: 103
Source
给你n组由k个0或者1组成的二进制数。每一个数能够翻转。求两个数的最大差值。
//152 ms 1788 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
char s[107];
long long ans[20007];
int n,m;
long long getnum()
{
long long res=0,j=1;
for(int i=m-1;i>=0;i--,j*=2)
if(s[i]=='1')res+=j;
return res;
}
int main()
{
int t,cas=1;
scanf("%d",&t);
while(t--)
{
int k=0;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%s",s);
ans[k++]=getnum();
for(int j=0;j<m;j++)
if(s[j]=='1')s[j]='0';
else s[j]='1';
ans[k++]=getnum();
}
sort(ans,ans+k);
long long ans1=ans[k-1]-ans[1];
long long ans2=ans[k-2]-ans[0];
long long p=ans[0],q=ans[k-1];
long long e=1<<(m-1);
if((p^q)&e==e)
printf("Case #%d: %lld\n",cas++,max(ans1,ans2));
else printf("Case #%d: %lld\n",q-p);
}
return 0;
}
2014 ACM-ICPC Beijing Invitational Programming Contest的更多相关文章
- BNU 34990 Justice String 2014 ACM-ICPC Beijing Invitational Programming Contest
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=34990 DEBUG了非常久,还是legal的推断函数写错了... 此题做法.枚举Stri ...
- ACM ICPC, JUST Collegiate Programming Contest (2018) Solution
A:Zero Array 题意:两种操作, 1 p v 将第p个位置的值改成v 2 查询最少的操作数使得所有数都变为0 操作为可以从原序列中选一个非0的数使得所有非0的数减去它,并且所有数不能 ...
- ACM ICPC, Amman Collegiate Programming Contest (2018) Solution
Solution A:Careful Thief 题意:给出n个区间,每个区间的每个位置的权值都是v,然后找长度为k的区间,使得这个区间的所有位置的权值加起来最大,输出最大权值, 所有区间不重叠 思路 ...
- 2014 ACM/ICPC 北京邀请赛 部分 题解
题目链接:http://acm.bnu.edu.cn/bnuoj/problem.php?search=2014+ACM-ICPC+Beijing+Invitational+Programming+C ...
- hdu 5016 点分治(2014 ACM/ICPC Asia Regional Xi'an Online)
Mart Master II Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- The North American Invitational Programming Contest 2017 题目
NAIPC 2017 Yin and Yang Stones 75.39% 1000ms 262144K A mysterious circular arrangement of black st ...
- ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków
ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków Problem A: Rubik’s Rect ...
- The North American Invitational Programming Contest 2018 D. Missing Gnomes
A family of nn gnomes likes to line up for a group picture. Each gnome can be uniquely identified by ...
- The North American Invitational Programming Contest 2018 H. Recovery
Consider an n \times mn×m matrix of ones and zeros. For example, this 4 \times 44×4: \displaystyle \ ...
随机推荐
- 在tomcat发布项目遇到的问题
今天从SVN上把系统导入本地发生了异常,问题如下: java.math.BigInteger cannot be cast to java.lang.Long 百度一番后发现是因为使用Mysql8.0 ...
- HTTP PUT方法和POST方法的区别
这两个方法看起来都是讲一个资源附加到服务器端的请求,但其实是不一样的.一些狭窄的意见认为,POST方法用来创建资源,而PUT方法则用来更新资源.这个说法本身没有问题,但是并没有从根本上解释了二者的区别 ...
- hdu 2462(欧拉定理+高精度快速幂模)
The Luckiest number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- hdu 1575(矩阵快速幂)
Tr A Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- 蚂蚁金服CTO程立:金融级分布式交易的技术路径
总结: 强一致的微服务 oceanbase里面的投票选举以及多中心多地部署 单元化市异地多活的基础.支付宝是异地多活和容灾结合,而容灾的基础也是单元化.基于单元化进行单元的调度.部署.容灾. 混合云架 ...
- java中正则表达式要进行转义的字符。
/** * 转义正则特殊字符 ($()*+.[]?\^{},|) * * @param keyword * @return */public static String escapeExprSpeci ...
- 算法题1+2+...+N
题目:求1+2+-+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字以及条件判断语句(A?B:C). int solve(int n) { int i = 1 ...
- SSH错误:packet_write_wait: Connection to 10.57.19.250 port 22: Broken pipe
现象:ssh连接以后,服务器会主动断开连接,wireshark抓包,发线服务器会tcp rst,断开ssh连接 解决尝试:1.修改会话超时时间:2.客户端主动间隔性向服务器发送保活报文:3.服务端主动 ...
- Cocos2d-x学习笔记(18)(TestCpp源代码分析-2)
本章主要讲controller.h/cpp文件的分析,该文件主要用于演示样例场景管理类TestController,用于显示全部演示样例的菜单. //controller.cpp #include & ...
- vue2.0 自定义过滤器
2.0中已经废弃了过滤器,需要我们自定义 <div id="app"> {{message|uppercase}} </div> //过滤器 Vue.fil ...