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 ...
随机推荐
- 微信和WeChat的合并月活跃账户达6.97亿
腾讯最新财报显示,微信和WeChat的合并月活跃账户于2015年底达6.97亿,同比增长39%.2016年初春节假期期间,通过微信支付收发的红包数量仅在6天内就超过320亿,同比增长9倍. 腾讯网络广 ...
- Swift Tour 随笔总结 (4)
Switch的一个例子: let vegetable = "red pepper" switch vegetable { case "celery": let ...
- Mac SVN <CornerStone>的安装和配置
cornerstone需要注意的地方 cornerstone文件夹的删除必须在 cornerstone软件里面删, 否则commit就会显示 up of date, 同步不了 http://www.t ...
- 北工大耿丹学院16级计科院3班C语言课程助教学期总结
很荣幸得到邹老师,周老师,以及北工大耿丹学院各位老师的认可,担任计科院3班C语言课程助教,班主任为李光杰老师,很感谢李老师一学期的帮助,使得我更好的担任助教一职.我班学生31名,很愉快的与同学们度过一 ...
- Android5.0版本之后切换听筒模式
5.0以前Android听筒模式和扬声器模式这样就管用 扬声器://关闭麦克风 mAudioManager.setMicrophoneMute(false); // 打开扬声器 mAudioMa ...
- python的类变量与实例变量
python的类内部定义的变量 ,形式上没有区分实例变量和类变量(java的静态变量),测试结果如下:
- MySQL性能优化的最佳经验
今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数据 ...
- 【VirtualBox】VirtualBox的桥接网络模式,为啥网络不稳定?
网桥模式访问外网非常慢,经常卡死,ping时断时续 七搞八搞,反复重启了几次 TMD 就好了,也不知道什么情况,VirtualBox还是不太好使啊..... 网桥模式 设置 如下: 参考资料: ht ...
- Django的Context和RequestContext
参考:http://www.dannysite.com/blog/38/ Django的模板渲染中,Context可以用来传递数据,一个Context是一系列变量和值的集合,它和Python的字典有点 ...
- 【转】Mybatis/Ibatis,数据库操作的返回值
该问题,我百度了下,根本没发现什么有价值的文章:还是看源代码(详见最后附录)中的注释,最有效了!insert,返回值是:新插入行的主键(primary key):需要包含<selectKey&g ...