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. Airbnb创始人:屌丝的逆袭之路

    这位黑发小帅哥名叫Brian Chesky,是Airbnb的联合创始人. 如果在百度一下Airbnb,你就会看到如下事实:Airbnb,即Air Bed and Breakfast,中国名“空中食宿” ...

  2. dedecms安装步骤

    GD支持:PHP设置-PHP扩展-php_gd2 初始化数据体验包:点击下载:或者点击取消     如果是本地安装在数据库的在数据库用户名选择默认的(root),密码为空 主要是如果是基于远程服务器的 ...

  3. Linux - 重定向与管道

    标准输出重定向 ">" 操作符:覆盖目标文件内容 huey@huey-K42JE:~/huey/linux/cmdline$ date > foo huey@huey- ...

  4. Apache Shiro 使用手册

    http://kdboy.iteye.com/blog/1154644 (一)Shiro架构介绍 一.什么是Shiro  Apache Shiro是一个强大易用的Java安全框架,提供了认证.授权.加 ...

  5. let 与 expr Shell运算比较 let强强胜出

    Shell脚本中 整数运算一般通过 let 和 expr 这两个指令来实现,如对变量 s 加 1 可以写作:let "s = $s + 1" 或者 s=`expr $s + 1'两 ...

  6. jsf使用spring注入的bean

    jsf的后台bean中使用spring定义的service,需要使用@ManagedProperty,并且要具有该属性的getter/setter方法. package cn.catr.lm.idc. ...

  7. 在IIS里面调试asp.net程序

    写在前面,在IIS里面调试asp.net程序,要分程序类型考虑: 一.调试asp.net项目: 1.选择"项目名",右击"属性": 2.选中"Web& ...

  8. selenium简单代码入门

    #!/usr/bin/env python #-*- coding:utf-8 -*- import os,sys,string import time import unittest from se ...

  9. C语言经典案例

    题目:企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%:利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%:20万到40万 ...

  10. [cocos2d-x 2.0.4][iOS7]图片加载错误

    本篇文章由:http://www.sollyu.com/cocos2d-x-2-0-4-ios7-image-loading-errors/ 说明 错误提示 <Error>: CGBitm ...