Codeforces Round #329 (Div. 2)
推迟了15分钟开始,B卡住不会,最后弃疗,rating只涨一分。。。
水(暴力枚举) A - 2Char
/************************************************
* Author :Running_Time
* Created Time :2015/11/4 星期三 21:33:17
* File Name :A.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos (-1.0);
char s[110][1010];
int len[110];
bool ok[110];
vector<char> vec[110]; int main(void) {
int n; scanf ("%d", &n);
for (int i=1; i<=n; ++i) {
scanf ("%s", s[i] + 1);
len[i] = strlen (s[i] + 1);
}
memset (ok, true, sizeof (ok));
int vis[30];
for (int i=1; i<=n; ++i) {
memset (vis, 0, sizeof (vis));
int tot = 0;
for (int j=1; j<=len[i]; ++j) {
if (!vis[s[i][j]-'a']) {
vec[i].push_back (s[i][j]);
vis[s[i][j]-'a'] = 1; tot++;
}
else continue;
if (tot > 2) {
ok[i] = false; break;
}
}
} int ans = 0;
for (char a='a'; a<='z'; ++a) {
for (char b='a'; b<='z'; ++b) {
int tmp = 0;
for (int i=1; i<=n; ++i) {
if (!ok[i]) continue;
bool flag = true;
for (int j=0; j<vec[i].size (); ++j) {
char c = vec[i][j];
if (c != a && c != b) {
flag = false;
}
}
if (flag) tmp += len[i];
}
ans = max (ans, tmp);
}
} printf ("%d\n", ans); //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; return 0;
}
sorting B - Anton and Lines
题意:给了一些直线,问是否在横坐标(x1, x2)范围内有相交的点
分析:很好想到每条直线与x = x1以及x = x2的直线的交点,那么满足相交的条件是y11 < y12 && y12 > y22,也就是逆序对。这样少掉了正好在x1或x2相交的情况,一种方法是L += EPS, R -= EPS,还有一种是排序。还有升级版的问题
/************************************************
* Author :Running_Time
* Created Time :2015/11/4 星期三 21:33:17
* File Name :B_2.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos (-1.0);
struct Y {
double y1, y2;
bool operator < (const Y &r) const {
return y1 < r.y1;
}
}y[N];
/*
快速读入输出(读入输出外挂)!--黑科技
使用场合:huge input (1e6以上)
*/
inline int read(void) {
int f = 1, ret = 0; char ch = getchar ();
while ('0' > ch || ch > '9') {
if (ch == '-') f = -1;
ch = getchar ();
}
while ('0' <= ch && ch <= '9') {
ret = ret * 10 + ch - '0';
ch = getchar ();
}
return ret * f;
} int main(void) {
int n; scanf ("%d", &n);
double x1, x2; scanf ("%lf%lf", &x1, &x2);
x1 += EPS; x2 -= EPS;
double k, b;
for (int i=1; i<=n; ++i) {
scanf ("%lf%lf", &k, &b);
y[i].y1 = k * x1 + b;
y[i].y2 = k * x2 + b;
}
sort (y+1, y+1+n);
bool flag = false;
for (int i=2; i<=n; ++i) {
if (y[i].y2 < y[i-1].y2) {
flag = true; break;
}
}
if (flag) puts ("YES");
else puts ("NO"); // cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; return 0;
}
/************************************************
* Author :Running_Time
* Created Time :2015/11/4 星期三 21:33:17
* File Name :B.cpp
************************************************/ #include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std; #define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos (-1.0);
struct Y {
ll y1, y2;
bool operator < (const Y &r) const {
return y1 < r.y1 || (y1 == r.y1 && y2 < r.y2);
}
}y[N];
/*
快速读入输出(读入输出外挂)!--黑科技
使用场合:huge input (1e6以上)
*/
inline int read(void) {
int f = 1, ret = 0; char ch = getchar ();
while ('0' > ch || ch > '9') {
if (ch == '-') f = -1;
ch = getchar ();
}
while ('0' <= ch && ch <= '9') {
ret = ret * 10 + ch - '0';
ch = getchar ();
}
return ret * f;
} int main(void) {
int n; scanf ("%d", &n);
int x1, x2; scanf ("%d%d", &x1, &x2);
ll k, b;
for (int i=1; i<=n; ++i) {
k = read (); b = read ();
y[i].y1 = k * x1 + b;
y[i].y2 = k * x2 + b;
}
sort (y+1, y+1+n);
bool flag = false;
for (int i=2; i<=n; ++i) {
if (y[i].y2 < y[i-1].y2) {
flag = true; break;
}
}
if (flag) puts ("YES");
else puts ("NO"); // cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; return 0;
}
Codeforces Round #329 (Div. 2)的更多相关文章
- 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 ...
- Codeforces Round #329 (Div. 2) D. Happy Tree Party 树链剖分
D. Happy Tree Party Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/p ...
- Codeforces Round #329 (Div. 2)B. Anton and Lines 贪心
B. Anton and Lines The teacher gave Anton a large geometry homework, but he didn't do it (as usual ...
- Codeforces Round #329 (Div. 2) D. Happy Tree Party LCA/树链剖分
D. Happy Tree Party Bogdan has a birthday today and mom gave him a tree consisting of n vertecie ...
- Codeforces Round #329 (Div. 2) A. 2Char 暴力
A. 2Char Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/593/problem/A De ...
- Codeforces Round #329 (Div. 2)A 字符串处理
A. 2Char time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...
- Codeforces Round #329 (Div. 2) D. Happy Tree Party(LCA+并查集)
题目链接 题意:就是给你一颗这样的树,用一个$y$来除以两点之间每条边的权值,比如$3->7$,问最后的y的是多少,修改操作是把权值变成更小的. 这个$(y<=10^{18})$除的权值如 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- 域名在微信朋友圈内分享需要ICP备案 杜绝不良信息传播
就在刚刚,腾讯微信团队发布公告表示域名在朋友圈内分享需要ICP备案,杜绝打击不良互联网信息的传播.公告称根据互联网管理相关规定,即日起在微信朋友圈内分享的域名,请在2014年12月31日前完成ICP备 ...
- 支持高并发的IIS Web服务器常用设置 II
适用的IIS版本:IIS 7.0, IIS 7.5, IIS 8.0 适用的Windows版本:Windows Server 2008, Windows Server 2008 R2, Windows ...
- spring原理
1.spring框架什么时候被加载? (1)ApplicationContext ac = new ClassPathXmlApplicationContext("applicationCo ...
- angular js 自定义指令
我们有些时候需要把后台返回过来的带有html标签的字符串binding到界面中一个指定的div或者其他的控制器中. 使用普通ng-bind不会自动解析出html语句. js中这样定义: app.dir ...
- 开发Web Service的几种方式
本文作者在学习使用Java开发Web Service(不包括Restful)时,由于不知道Java有这么多框架支持开发Web Service一度陷入迷惘,不知道这些框架各有 什么不同,各有什么优缺点. ...
- 基础知识《二》java的基本类型
一.java基本数据类型 Java基本类型共有八种,基本类型可以分为三类,字符类型char,布尔类型boolean以及数值类型byte.short.int.long.float.double.数值类型 ...
- spring3 + mybatis + maven:junit测试错误
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c ...
- python - easy_install的安装和使用
为什么要装easy_install?正常情况下,我们要给Python安装第三方的扩展包,我们必须下载压缩包,解压缩到一个目录,然后命令行或者终端打开这个目录,然后执行python setup.py i ...
- cas单点登录用户名为中文的解决办法
当用户名为中文时,登录后返回的用户名乱码.解决这个问题只需要在客户端的CAS Validation Filter中添加下配置就行了. <init-param> <param-name ...
- Maven发布web项目到tomcat
在java开发中经常要引入很多第三方jar包:然而无论是java web开发还是其他java项目的开发经常会由于缺少依赖包引来一些不必要的异常.常常也是因为这样的原因导致许多简单的缺包和版本问题耗费大 ...