推迟了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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #329 (Div. 2)A 字符串处理

    A. 2Char time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  7. Codeforces Round #329 (Div. 2) D. Happy Tree Party(LCA+并查集)

    题目链接 题意:就是给你一颗这样的树,用一个$y$来除以两点之间每条边的权值,比如$3->7$,问最后的y的是多少,修改操作是把权值变成更小的. 这个$(y<=10^{18})$除的权值如 ...

  8. 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 ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. dedecms如何自定义专题模板

    很多人看到别人的网站也是用dedecms建的,但是他们的专题做得很漂亮,也在想如何自定义dedecms专题模板呢? 其实很简单,只要在dedecms默认专题模板上做一些修改就好了 <!DOCTY ...

  2. 机器学习公开课笔记(8):k-means聚类和PCA降维

    K-Means算法 非监督式学习对一组无标签的数据试图发现其内在的结构,主要用途包括: 市场划分(Market Segmentation) 社交网络分析(Social Network Analysis ...

  3. vim中的查找和替换

    (文章是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com) 查找: Gsearch -F 'aa' -R  --include=*rb 替换: (1)在查找结果 ...

  4. Aptana插件安装到eclipse和myeclipse的详细过程

    刚开始学习Jquery,为了搭建好的环境是很重要的,所以我尝试了很多方式,下面之一. 一.要下载好Aptana 插件 官网: http://update1.aptana.org/studio/3.2/ ...

  5. 2015安徽省赛 D.锐雯上单不给就送

    题目描述 <英雄联盟>(简称LOL)是由美国Riot Games开发,腾讯游戏运营的英雄对战网游.<英雄联盟>除了即时战略.团队作战外,还拥有特色的英雄.自动匹配的战网平台,包 ...

  6. poj1094

    Sorting It All Out Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 29539   Accepted: 10 ...

  7. HDOJ 1863 prim算法 HDOJ 1879

    #include<cstdio> #include<cstring> #define inf 0xffffff ][]; int ans; void prim(int n) { ...

  8. css整个页面离顶部的距离

    body { padding:0; margin:0; font-size:12px; line-height:22px; } 说明: 整个页面离顶部的距离是22像素

  9. Heap:Sunscreen(POJ 3614)

    晒太阳 题目大意:一堆牛,为了避免晒太阳会灼烧自己,然后他们自己有自己的防晒指数(一个区间),防晒霜可以提高防晒因数SPF,大了不行小了不行,现在有一桶防晒霜,他们提供一定的SPF,但是最多可以提供k ...

  10. 小吃(codevs 3231)

    3231 小吃  时间限制: 1 s  空间限制: 16000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Description 这里简直是吃货的天堂,小吃太多了. ...