Problem_A(593A):

题意:

  给n个单词, 每个单词由小写字母组成, 且长度<=1000.

  组成一篇文章的要求是:

    所有单词所用字母 <= 2

    即最多只能有两个不同的字母。

  求一篇文章的最长长度。

思路:

  首先注意到单词都是由小写字母组成,小写字母只有26个, 所以可以转换一下:

    如果一个单词所用字母超过2个, 那么我们舍弃它。因为它怎么都不可能会是一篇文章的组成部分。

    如果没有超过两个, 那么找出这两个单词, 记录它的长度即可。

  设f[i][j] = 只有字母为i + 'a' 和 j + 'a'的单词的长度,如果i == j则只有一个字母。

  答案则为 max(f[i][j] + f[i][i] + f[j][j] (f[i][j] > 0), f[i][i] + f[j][j])

代码:

  

 #include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define MAXN 100010
#define MAXM 100
#define dd {cout<<"debug"<<endl;}
#define pa {system("pause");}
#define p(x) {printf("%d\n", x);}
#define pd(x) {printf("%.7lf\n", x);}
#define k(x) {printf("Case %d: ", ++x);}
#define s(x) {scanf("%d", &x);}
#define sd(x) {scanf("%lf", &x);}
#define mes(x, d) {memset(x, d, sizeof(x));}
#define do(i, x) for(i = 0; i < x; i ++)
#define dod(i, x, l) for(i = x; i >= l; i --)
#define doe(i, x) for(i = 1; i <= x; i ++)
struct node
{
LL l;
LL r;
};
int n;
LL x[];
bool flag;
struct node f[MAXN];
bool cmp(struct node x, struct node y)
{
if(((x.l - y.l < ) && (x.r - y.r > )) || ((x.l - y.l > ) && (x.r - y.r < )))
flag = true;
if(x.l == y.l) return x.r < y.r;
return x.l < y.l;
} int main()
{
flag = false;
scanf("%d", &n);
scanf("%I64d %I64d", &x[], &x[]);
LL k, b;
for(int i = ; i < n; i ++)
{
scanf("%I64d %I64d", &k, &b);
f[i].l = x[] * k + b;
f[i].r = x[] * k + b;
}
sort(f, f + n, cmp);
printf("%s\n", flag? "YES" : "NO");
return ;
}

Problem_B(593B):

题意:

  给n条直线, 然后一个区间[x1, x2].

  问, 这n条直线之中, 是否会有直线在[x1, x2]这个区间上有交点。

思路:

  嗯....利用了奇淫技巧。

  正常的思路是这样的:

    先把每条直线在这个区间的值域[y1, y2]求出来。

    然后会发现, 如果两条直线在这里有交点的话, 必然是对应两端点之差的符号相反。

    即[y1, y2] [y3, y4]:

      y1 - y3 < 0 && y2 - y4 > 0 或者

      y1 - y3 > 0 && y2 - y4 < 0

  贪心即可, 然而个人比较懒, 利用sort偷了个懒。

代码:

  

 #include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define eps 1e-6
#define MAXN 100010
#define MAXM 100
#define dd {cout<<"debug"<<endl;}
#define pa {system("pause");}
#define p(x) {printf("%d\n", x);}
#define pd(x) {printf("%.7lf\n", x);}
#define k(x) {printf("Case %d: ", ++x);}
#define s(x) {scanf("%d", &x);}
#define sd(x) {scanf("%lf", &x);}
#define mes(x, d) {memset(x, d, sizeof(x));}
#define do(i, x) for(i = 0; i < x; i ++)
#define dod(i, x, l) for(i = x; i >= l; i --)
#define doe(i, x) for(i = 1; i <= x; i ++)
struct node
{
LL l;
LL r;
};
int n;
LL x[];
bool flag;
struct node f[MAXN];
bool cmp(struct node x, struct node y)
{
if(((x.l - y.l < ) && (x.r - y.r > )) || ((x.l - y.l > ) && (x.r - y.r < )))
flag = true;
if(x.l == y.l) return x.r < y.r;
return x.l < y.l;
} int main()
{
flag = false;
scanf("%d", &n);
scanf("%I64d %I64d", &x[], &x[]);
LL k, b;
for(int i = ; i < n; i ++)
{
scanf("%I64d %I64d", &k, &b);
f[i].l = x[] * k + b;
f[i].r = x[] * k + b;
}
sort(f, f + n, cmp);
printf("%s\n", flag? "YES" : "NO");
return ;
}

Codeforces Round #329 div2的更多相关文章

  1. Codeforces Round #539 div2

    Codeforces Round #539 div2 abstract I 离散化三连 sort(pos.begin(), pos.end()); pos.erase(unique(pos.begin ...

  2. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

  3. Codeforces Round#320 Div2 解题报告

    Codeforces Round#320 Div2 先做个标题党,骗骗访问量,结束后再来写咯. codeforces 579A Raising Bacteria codeforces 579B Fin ...

  4. Codeforces Round #564(div2)

    Codeforces Round #564(div2) 本来以为是送分场,结果成了送命场. 菜是原罪 A SB题,上来读不懂题就交WA了一发,代码就不粘了 B 简单构造 很明显,\(n*n\)的矩阵可 ...

  5. Codeforces Round #361 div2

    ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...

  6. Codeforces Round #626 Div2 D,E

    比赛链接: Codeforces Round #626 (Div. 2, based on Moscow Open Olympiad in Informatics) D.Present 题意: 给定大 ...

  7. Codeforces Round #329(Div2)

    CodeForces 593A 题意:n个字符串,选一些字符串,在这些字符串中使得不同字母最多有两个,求满足这个条件可选得的最多字母个数. 思路:用c[i][j]统计文章中只有i,j对应两个字母出现的 ...

  8. CodeForces Round 192 Div2

    This is the first time I took part in Codeforces Competition.The only felt is that my IQ was contemp ...

  9. Codeforces Round #329 (Div. 2) B. Anton and Lines 逆序对

    B. Anton and Lines Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/pr ...

随机推荐

  1. 4.关于phpstudy for linux 的安装(LNMP)更好的环境请看8.LNMP环境

    phpstudy真的很坑爹! 所以我在后面重新写了一个LNMP环境的集成包应用! 首先,我们在自己本地开发的时候一般使用的虚拟机的权限账号都是最高的,也就是我们的root账户 PS:我已经更改镜像源为 ...

  2. CountDownLatch(闭锁)

    一.闭锁(Latch)    闭锁(Latch):一种同步方法,可以延迟线程的进度直到线程到达某个终点状态.通俗的讲就是,一个闭锁相当于一扇大门,在大门打开之前所有线程都被阻断,一旦大门打开所有线程都 ...

  3. ArrayBlockingQueue和LinkedBlockingQueue分析

        JAVA并发包提供三个常用的并发队列实现,分别是:ConcurrentLinkedQueue.LinkedBlockingQueue和ArrayBlockingQueue. Concurren ...

  4. Java8的新特性

        Java 8主要新特性包括如下几点: 一.接口的默认方法和静态方法 Java 8版之前,接口只有抽象方法,而在Java 8,为接口新增了两种类型的方法. 第一种是默认方法:在Java 8中,可 ...

  5. 第一个Servlet

    一,第一个Servlet的编写过程 1,建立JavaWeb应用目录 HelloServlet--web应用名称 classes:Servlet就放在此处 lib web.xml 2,classes目录 ...

  6. poj2337 欧拉路径

    poj2337 这道题昨天晚上开始做,今天才A.但是问题想透了, 发现其实没那么难 题目大意: 给你一些单词,如果一个单词的末尾字符与另一个单词首字符相同,则两个的单词可以连接.问是否可以把所有单词连 ...

  7. HW-找7(测试ok满分注意小于等于30000的条件)

    输出7有关数字的个数,包括7的倍数,还有包含7的数字(如17,27,37...70,71,72,73...)的个数 知识点 循环 运行时间限制 0M 内存限制 0 输入 一个正整数N.(N不大于300 ...

  8. Ext.Net学习笔记16:Ext.Net GridPanel 折叠/展开行

    Ext.Net学习笔记16:Ext.Net GridPanel 折叠/展开行 Ext.Net GridPanel的行支持折叠/展开功能,这个功能个人觉得还说很有用处的,尤其是数据中包含图片等内容的时候 ...

  9. ###g++编译器

    点击查看Evernote原文. #@author: gr #@date: 2014-07-20 #@email: forgerui@gmail.com 对g++编译器不是特别熟悉,希望借此熟悉一下. ...

  10. IOS之swift第一课基础代码

    import Foundation //import Foundation 导入模块,专业术语也是导入 包,库的 意思. var str = "Hello World" //声明一 ...