D - 粉碎叛乱F - 其他起义
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
If Adam’s i:th card beats Eve’s i:th card, then Adam gets one point.
If Eve’s i:th card beats Adam’s i:th card, then Eve gets one point.
A card with higher value always beats a card with a
lower value: a three beats a two, a four beats a three and a two, etc.
An ace beats every card except (possibly) another ace.
If the two i:th cards have the same value, then the
suit determines who wins: hearts beats all other suits, spades beats all
suits except hearts, diamond beats only clubs, and clubs does not beat
any suit.
For example, the ten of spades beats the ten of diamonds but not the Jack of clubs.
This ought to be a game of chance, but lately Eve is
winning most of the time, and the reason is that she has started to use
marked cards. In other words, she knows which cards Adam has on the
table before he turns them face up. Using this information she orders
her own cards so that she gets as many points as possible.
Your task is to, given Adam’s and Eve’s cards, determine how many points Eve will get if she plays optimally.
Input
single positive integer N giving the number of test cases. After that
line follow the test cases.
Each test case starts with a line with a single positive
integer k <= 26 which is the number of cards each player gets. The
next line describes the k cards Adam has placed on the table, left to
right. The next line describes the k cards Eve has (but she has not yet
placed them on the table). A card is described by two characters, the
first one being its value (2, 3, 4, 5, 6, 7, 8 ,9, T, J, Q, K, or A),
and the second one being its suit (C, D, S, or H). Cards are separated
by white spaces. So if Adam’s cards are the ten of clubs, the two of
hearts, and the Jack of diamonds, that could be described by the line
TC 2H JD
Output
gets if she picks the optimal way to arrange her cards on the table.
Sample Input
1
JD
JH
2
5D TC
4C 5H
3
2H 3H 4H
2D 3D 4D
Sample Output
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define mem(x,y) memset(x,y,sizeof(x))
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
int a[],b[];
char s[];
int getnum(){
int x=;
if(s[]=='A')x=;
else if(s[]=='T')x=;
else if(s[]=='J')x=;
else if(s[]=='Q')x=;
else if(s[]=='K')x=;
else if(s[]>=''&&s[]<='')x=s[]-'';
x=x*;
if(s[]=='C')x+=;
else if(s[]=='D')x+=;
else if(s[]=='S')x+=;
else if(s[]=='H')x+=;
return x;
}
int main(){
int T,N;
scanf("%d",&T);
while(T--){
scanf("%d",&N);
for(int i=;i<N;i++){
scanf("%s",s);
a[i]=getnum();
}
for(int i=;i<N;i++){
scanf("%s",s);
b[i]=getnum();
}
// for(int i=0;i<N;i++)printf("%d ",a[i]);puts("");
// for(int i=0;i<N;i++)printf("%d ",b[i]);puts("");
sort(a,a+N);sort(b,b+N);
int ans=;
for(int i=,j=;i<N&&j<N;){
if(b[i]>=a[j]){
i++;j++;ans++;
}
else i++;
}
printf("%d\n",ans);
}
return ;
}
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu
Description
Your task is counting the segments of different colors you can see at last.
Input
The first line of each data set contains exactly one integer n, 1 <= n <= 8000, equal to the number of colored segments.
Each of the following n lines consists of exactly 3 nonnegative integers separated by single spaces:
x1 x2 c
x1 and x2 indicate the left endpoint and right endpoint of the segment, c indicates the color of the segment.
All the numbers are in the range [0, 8000], and they are all integers.
Input may contain several data set, process to the end of file.
Output
Each line of the output should contain a color index that can be seen
from the top, following the count of the segments of this color, they
should be printed according to the color index.
If some color can't be seen, you shouldn't print it.
Print a blank line after every dataset.
Sample Input
5
0 4 4
0 3 1
3 4 2
0 2 2
0 2 3
4
0 1 1
3 4 1
1 3 2
1 3 1
6
0 1 0
1 2 1
2 3 1
1 2 0
2 3 0
1 2 1
Sample Output
1 1
2 1
3 1
1 1
0 2
1 1
题解:暴力;
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define mem(x,y) memset(x,y,sizeof(x))
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e6+;
int tree[MAXN],pre[MAXN];
int main(){
int N,x,y,z;
while(~scanf("%d",&N)){
mem(tree,-);mem(pre,);
for(int i=;i<N;i++){
scanf("%d%d%d",&x,&y,&z);
for(int j=x;j<y;j++)tree[j]=z;
}
for(int i=;i<=;i++){
if(tree[i]==-)continue;
pre[tree[i]]++;
while(tree[i+]==tree[i])i++;
}
for(int i=;i<=;i++){
if(!pre[i])continue;
printf("%d %d\n",i,pre[i]);
}
puts("");
}
return ;
}
D - 粉碎叛乱F - 其他起义的更多相关文章
- 每日英语:China Destroys Six Tons of Confiscated Ivory
BEIJING—Chinese government officials destroyed more than six tons of ivory that had been illegally s ...
- Mysql_以案例为基准之查询
查询数据操作
- C#强力粉碎文件代码分享,升级中用到
360的文件粉碎机还是很强大的,在我们客户端winform升级的时候,必须将有些文件进行强力删除后下载更新,如果删除失败很有可能整个 程序就无法更新到最新的版本,所以这里参考了网上的资料整理了一个文件 ...
- 在 C# 里使用 F# 的 option 变量
在使用 C# 与 F# 混合编程的时候(通常是使用 C# 实现 GUI,F#负责数据处理),经常会遇到要判断一个 option 是 None 还是 Some.虽然 Option module 里有 i ...
- 如果你也会C#,那不妨了解下F#(7):面向对象编程之继承、接口和泛型
前言 面向对象三大基本特性:封装.继承.多态.上一篇中介绍了类的定义,下面就了解下F#中继承和多态的使用吧.
- 如果你也会C#,那不妨了解下F#(2):数值运算和流程控制语法
本文链接:http://www.cnblogs.com/hjklin/p/fs-for-cs-dev-2.html 一些废话 一门语言火不火,与语言本身并没太大关系,主要看语言的推广. 推广得好,用的 ...
- 使用F#开发ASP.NET Core应用程序
.NET Core 里的F# 在.NET Core刚发布时,就已经添加了对F#的支持.但因为当时F#组件还不完整,而一些依赖包并没有放在Nuget上,而是社区自己放到MyGet上,所以在使用dotne ...
- 如果你也会C#,那不妨了解下F#(6):面向对象编程之“类”
前言 面向对象的思想已经非常成熟,而使用C#的程序员对面向对象也是非常熟悉,所以我就不对面向对象进行介绍了,在这篇文章中将只会介绍面向对象在F#中的使用. F#是支持面向对象的函数式编程语言,所以你用 ...
- 如果你也会C#,那不妨了解下F#(5):模块、与C#互相调用
F# 项目 在之前的几篇文章介绍的代码都在交互窗口(fsi.exe)里运行,但平常开发的软件程序可能含有大类类型和函数定义,代码不可能都在一个文件里.下面我们来看VS里提供的F#项目模板. F#项目模 ...
随机推荐
- Servlet 的基本架构
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpSer ...
- Maven+SpringMVC+MyBatis 上传图片
上传文件我一直都觉得很难,好吧,所有涉及文件操作的我都觉得不容易.然后今天尝试了从网页上传图片保存到服务器.这个例子的前提是搭建好了服务器端框架:Maven+Spring MVC+MyBatis.当然 ...
- Hadoop 相关问题
1.MR Job 输入非常多,启动map 非常多,如何提高MapTask 启动速度(附加条件:集群很空闲,资源多多): 参考答案: a.重写调度器算法,降低时间复杂度 b.Out-of-bound h ...
- 如何实现HTTPSERVER
Write your own http server author : Kevin Lynx Why write your own? 看这个问题的人证明你知道什么是http server,世界上有很多 ...
- [LeetCode]题解(python):129-Sum Root to Leaf Numbers
题目来源: https://leetcode.com/problems/sum-root-to-leaf-numbers/ 题意分析: 一棵树,从跟节点到叶子节点比如1->2那么这个叶子代表12 ...
- Java Socket 入门1
由程序逻辑可以看到 这是一个 客户端和服务端一对一聊天的程序 首先由服务端说第一句话然后对话才开始 且只能客户端一行话 服务端再一行话 这样往复进行 客户端若想不等服务端回应继续说话是不行的 服 ...
- 射频识别技术漫谈(13)——Mifare S50与Mifare S70
Mifare S50和Mifare S70又常被称为Mifare Standard.Mifare Classic.MF1,是遵守ISO14443A标准的卡片中应用最为广泛.影响力最大的的一员.而Mif ...
- VC编程之设置客户区背景图片
在很多系统中出于美观的需要常常要设置背景图片.下面我介绍一种在客户区设置背景图片的简单方法. 1 .将背景bmp 图片导入到工程,资源ID 这里假设为 IDB_BITMAP1 2 .在视图类添加如下代 ...
- android LinearLayout和RelativeLayout实现精确布局
先明确几个概念的区别: padding margin:都是边距的含义,关键问题得明白是什么相对什么的边距padding:是控件的内容相对控件的边缘的边距. margin :是控件边缘相对父空间的边距 ...
- 【转】 IE6 IE7 IE8 css bug兼容性解决方法总结归纳
1:li边距“无故”增加 任何事情都是有原因的,li边距也不例外. 先描述一下具体状况:有些时候li边距会突然增 加很多,值也不固定(只在IE6/IE7有这种现象),让人摸不着头脑,仔细“研究”发现是 ...