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#项目模 ...
随机推荐
- Ajax异步请求XMLHttpRequest对象Get请求
$(function () { $("#btnGetDate").click(function () { var xhr; //第一步:创建异步请求的核心的对象: if (XMLH ...
- 关于两次指针(struct型)传参数的问题
这两天被struct传参给郁闷死了.今天终于解决了. 比如有一个struct如下: struct _ns1__Add_USCORESensorDataArray{ struct xsd__base64 ...
- python列表类型中的陷阱
在python中对列表使用重复运算符*进行操作时,只是简单的进行了浅复制,内部的结构并没有复制过来,所以下面的例子结果是这样的: >>> lists =[[]]*3 >> ...
- C#读取网页
public bool getweb(string strURL,out string buf) { buf=""; try { //Uri url=new Uri(strURL, ...
- Git远程仓库的使用(三)
1)git remote add : 添加远程仓库 git remote add origin git@github.com:用户名.仓库名.git 2) git push –u origin mas ...
- Best practice for Invoke other scripts or exe in PowerShell
Recently, I find I used many different type method to invoke other scripts or exe in PowerShell. May ...
- ios 学习笔记(8) 控件 按钮(UIButton)的使用方法
在实际开发中,对于开发者来说,更多的还是使用“自定义”按钮.将“按钮”对象的类型设置成UIButtonTypeCustom.这样一来,按钮的所有元素都将由开发者来配置和自定义. 对于一个自定义按钮来说 ...
- 使用RUBY生成二维码
二维码现在貌似已经成为一个项目必不可少的总分了,最近在做的微信项目,更是大大的依赖于二维码,微信公众平台提供的临时二维码,局限太多,只能带一个ID,做不了太多有意义的整个,因为我们很多的二维码是需要自 ...
- 电脑bios到底是什么?
没有哪个玩电脑的人不知道电脑bios,但是真正能明白bios是什么的?身边却没几个,甚至大多数电脑维修站的人员对bios也不够详细了解.一般人不去关心bios是因为它离我们的电脑真正使用仍有一段距离. ...
- 转:基于node的web开发框架Express入门
JavaScript 标准参考教程(alpha) 草稿二:Node.js Express框架 GitHub TOP Express框架 来自<JavaScript 标准参考教程(alpha)&g ...