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#项目模 ...
随机推荐
- loadRunner 11.0 安装及破解
http://jingyan.baidu.com/article/20095761b31b58cb0621b463.html 破解时必须是管理员账户登录.
- Android应用开发基础篇(9)-----SharedPreferences
链接地址:http://www.cnblogs.com/lknlfy/archive/2012/02/27/2370319.html 一.概述 对于SharedPreferences,我吧它理解为一种 ...
- 在数组中找几个数的和等于某个数[LeetCode]
首先明确一点,这个方面的问题设计到的知识点是数组的查找的问题.对于类似的这样的查找操作的具体办法就是三种解决方法: 1.暴力算法,多个for循环,很高的时间复杂度 2.先排序,然后左右夹逼,但是这样会 ...
- php内核--SAPI概述
- django FileFIeld和ImageField 上传路径改写
def get_file_path(instance, filename): return 'file/document/%s/%s/%s' % (instance.period.code, inst ...
- MongoDB Query
每条数据格式如下 { "_id" : ObjectId("5383298561aa33a422d8603e"), "day" : " ...
- Linux远程连接与常用命令
要学linux ,一定得用命令界面的,怎么也得是shell语言,用就最难最原始的,用的人都是专家,历史最少也得30年,不管有三七二十一上来就敲ls ,先看看当前目录都有什么.一口专业的linux范儿, ...
- 城通网盘,千军万马,千脑网盘,119g网盘哪个适合做网赚?
转载请注明文章来自 [ofiicexie] 网盘网赚已经流行了有一段时间了,国内流行的几个网盘有城通,千军万马,千脑,119g,今天小编写以此文来比较分析一下这几个网盘的优缺点. 这里,我特意做了个这 ...
- 将dll放进exe[.Net]
原文:将dll放进exe[.Net] 两种方案: 1.使用ILMerge工具. 缺点:需离开工程,使用第三方工具(ILMerge). 2.将dll作为Resource放进exe,exe执行时动态加载( ...
- hpu校赛--雪人的高度(离散化线段树)
1721: 感恩节KK专场——雪人的高度 时间限制: 1 Sec 内存限制: 128 MB 提交: 81 解决: 35 [提交][状态][讨论版] 题目描述 大雪过后,KK决定在春秋大道的某些区间 ...