LUXURY 8
Time Limit:3000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius.
He has a n × n chessboard. Each cell of the chessboard has a number written on it. Gargari wants to place two bishops on the chessboard in such a way that there is no cell that is attacked by both of them. Consider a cell with number x written on it, if this cell is attacked by one of the bishops Gargari will get x dollars for it. Tell Gargari, how to place bishops on the chessboard to get maximum amount of money.
We assume a cell is attacked by a bishop, if the cell is located on the same diagonal with the bishop (the cell, where the bishop is, also considered attacked by it).
Input
The first line contains a single integer n(2 ≤ n ≤ 2000). Each of the next n lines contains n integers aij(0 ≤ aij ≤ 109) — description of the chessboard.
Output
On the first line print the maximal number of dollars Gargari will get. On the next line print four integers: x1, y1, x2, y2(1 ≤ x1, y1, x2, y2 ≤ n), where xi is the number of the row where the i-th bishop should be placed, yi is the number of the column where the i-th bishop should be placed. Consider rows are numbered from 1 to n from top to bottom, and columns are numbered from 1 to nfrom left to right.
If there are several optimal solutions, you can print any of them.
Sample Input
4
1 1 1 1
2 1 1 0
1 1 1 0
1 0 0 1
12
2 2 3 2
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
Let's denote as the number of bits set ('1' bits) in the binary representation of the non-negative integer x.
You are given multiple queries consisting of pairs of integers l and r. For each query, find the x, such that l ≤ x ≤ r, and is maximum possible. If there are multiple such numbers find the smallest of them.
Input
The first line contains integer n — the number of queries (1 ≤ n ≤ 10000).
Each of the following n lines contain two integers li, ri — the arguments for the corresponding query (0 ≤ li ≤ ri ≤ 1018).
Output
For each query print the answer in a separate line.
Sample Input
3
1 2
2 4
1 10
1
3
7
Hint
The binary representations of numbers from 1 to 10 are listed below:
110 = 12
210 = 102
310 = 112
410 = 1002
510 = 1012
610 = 1102
710 = 1112
810 = 10002
910 = 10012
1010 = 10102
一个纯粹的贪心,可以按位一步一步贪。
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and sdoesn't contain any palindrome contiguous substring of length 2 or more.
Paul has found a tolerable string s of length n. Help him find the lexicographically next tolerable string of the same length or else state that such string does not exist.
Input
The first line contains two space-separated integers: n and p (1 ≤ n ≤ 1000; 1 ≤ p ≤ 26). The second line contains string s, consisting of n small English letters. It is guaranteed that the string is tolerable (according to the above definition).
Output
If the lexicographically next tolerable string of the same length exists, print it. Otherwise, print "NO" (without the quotes).
Sample Input
3 3
cba
NO
3 4
cba
cbd
4 4
abcd
abda
Hint
String s is lexicographically larger (or simply larger) than string t with the same length, if there is number i, such that s1 = t1, ..., si = ti,si + 1 > ti + 1.
The lexicographically next tolerable string is the lexicographically minimum tolerable string which is larger than the given one.
A palindrome is a string that reads the same forward or reversed.
一道构造题,构造题真是。。。。。
要做这道题,有个结论非常重要,那就是只有“部分对称” , 才会有可能性造成“整体堆成”,所以只要破坏所有“部分对称“,就行了。
而部分对称只有两种形式”aa” , “aba”
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the following problem at the work.
Given a sequence of n integers p1, p2, ..., pn. You are to choose k pairs of integers:
[l1, r1], [l2, r2], ..., [lk, rk] (1 ≤ l1 ≤ r1 < l2 ≤ r2 < ... < lk ≤ rk ≤ n; ri - li + 1 = m),
in such a way that the value of sum is maximal possible. Help George to cope with the task.
Input
The first line contains three integers n, m and k(1 ≤ (m × k) ≤ n ≤ 5000). The second line contains n integers p1, p2, ..., pn(0 ≤ pi ≤ 109).
Output
Print an integer in a single line — the maximum possible value of sum.
Sample Input
5 2 1
1 2 3 4 5
9
7 1 3
2 10 7 18 5 33 0
61
LUXURY 8的更多相关文章
- 每日英语:Why Chinese Companies Lack Homegrown Luxury Brand Power
Chinese companies build iPads, high-speed trains and world-class telecom gear, but they can't seem t ...
- LUXURY 7
A.Little Pony and Expected Maximum Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:% ...
- .Net中的AOP系列之构建一个汽车租赁应用
返回<.Net中的AOP>系列学习总目录 本篇目录 开始一个新项目 没有AOP的生活 变更的代价 使用AOP重构 本系列的源码本人已托管于Coding上:点击查看. 本系列的实验环境:VS ...
- Quality 是什么?
Quality 是什么? 通常,我们谈及 Quality(质量)时,最常见的问题就是:Quality 是什么? 有很多业界先驱和研究人员已经回答了这个问题,我在这里并不会再给出一个新的答案.在学习总结 ...
- 【热文】 为什么很多硅谷工程师偏爱 OS X,而不是 Linux 或 Windows?
校对:伯乐在线 - 黄利民 链接: 1. Why do most of the developers in Silicon Valley prefer OS X over Linux or Windo ...
- EF里单个实体的增查改删以及主从表关联数据的各种增删 改查
本文目录 EF对单个实体的增查改删 增加单个实体 查询单个实体 修改单个实体 删除单个实体 EF里主从表关联数据的各种增删改查 增加(增加从表数据.增加主从表数据) 查询(根据主表找从表数据.根据从表 ...
- *HDU 2451 数学
Simple Addition Expression Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- 《Entity Framework 6 Recipes》中文翻译系列 (36) ------ 第六章 继承与建模高级应用之TPC继承映射
翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 6-12 TPC继承映射建模 问题 你有两张或多张架构和数据类似的表,你想使用TP ...
- 【十大经典数据挖掘算法】CART
[十大经典数据挖掘算法]系列 C4.5 K-Means SVM Apriori EM PageRank AdaBoost kNN Naïve Bayes CART 1. 前言 分类与回归树(Class ...
随机推荐
- python模块
模块介绍 为什么用模块 在代码量庞大的时候,如果靠一个脚本来进行函数式编程,对于脚本的可读性及后期脚本的维护带来极大的不便,而且无法分辨函数间的调用关系,所以,可以将一组功能类似的函数单独放在一个py ...
- ( 译、持续更新 ) JavaScript 上分小技巧(一)
感谢好友破狼提供的这篇好文章,也感谢写这些知识点的作者们和将他们整理到一起的作者.这是github上的一篇文章,在这里本兽也就只做翻译,由于本兽英语水平和编程能力都不咋地,如有不好的地方也请多理解体谅 ...
- HDU 1874 畅通工程续(最短路/spfa Dijkstra 邻接矩阵+邻接表)
题目链接: 传送门 畅通工程续 Time Limit: 1000MS Memory Limit: 65536K Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路. ...
- [JavaEE]理解ThreadLocal
转http://www.iteye.com/topic/103804 首先,ThreadLocal 不是用来解决共享对象的多线程访问问题的,一般情况下,通过ThreadLocal.set() 到线程中 ...
- oracle报错:ORA-28000: the account is locked
连接数据库的时候报: ORA-28000: the account is locked 解决方法: cmd-进入命令行 C:\Users\0>sqlplus /nolog SQL*Plus: R ...
- 无法启动此程序,因为计算机中丢失MSVCP110.dll
安装Visual C++ Redistributable for Visual Studio 2012 有arm.x86.x64有三个版本. 如果应用程序为debug版本而不是release版本,可能 ...
- spring---aop 配置
第一种:注解配置AOP 注解配置AOP(使用 AspectJ 类库实现的),大致分为三步: 1. 使用注解@Aspect来定义一个切面,在切面中定义切入点(@Pointcut),通知类型(@Befor ...
- JAVA内存机制
Java程序运行时,数据会分区存放,JavaStack(Java栈). heap(堆).method(方法区). 一.JVM内存模型 1.Java栈Java栈的区域很小,只有1M,特点是存取速度很快, ...
- TCP 介绍
TCP介绍 TCP(Transmission Control Protocol 传输控制协议)是一种面向连接的.可靠的.基于字节流的传输层通信协议,由IETF的RFC 793定义.在简化的计算机网络O ...
- 泛在传感器网络(Ubiquitous Sensor Network; USN)
http://wiki.mbalib.com/wiki/%E6%B3%9B%E5%9C%A8%E4%BC%A0%E6%84%9F%E5%99%A8%E7%BD%91%E7%BB%9C 什么是泛在传感器 ...