题目传送门

水 A - Wizards' Duel

题目都没看清就写了,1e-4精度WA了一次。。。

/************************************************
* Author :Running_Time
* Created Time :2015/10/25 16:27:20
* 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; int main(void) {
int L, p, q;
scanf ("%d%d%d", &L, &p, &q);
double ans = L * (p * 1.0) / (p + q);
printf ("%.5f\n", ans); return 0;
}

构造 B - Rebranding

题意:要求字符串的所有C1字符变成C2,C2变成C1,输出最后的结果

分析:想了一会,试了并查集,未果,YY,未果。最后想了一个很奇怪的方法,就是每次记录C1的最原始的字符rt[C1],它将转换为C2,即to[rt[C1]] = C2

/************************************************
* Author :Running_Time
* Created Time :2015/10/25 16:27:20
* 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 = 2e6 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
char s[N];
int to[30], rt[30]; int main(void) {
int n, m; scanf ("%d%d", &n, &m); getchar ();
scanf ("%s", &s); getchar ();
char c1, c2;
memset (to, -1, sizeof (to));
for (int i=0; i<26; ++i) rt[i] = i;
for (int i=1; i<=m; ++i) {
scanf ("%c %c", &c1, &c2); getchar ();
int tmp = rt[c2-'a'];
to[rt[c1-'a']] = c2 - 'a';
to[rt[c2-'a']] = c1 - 'a';
rt[c2-'a'] = rt[c1-'a'];
rt[c1-'a'] = tmp;
}
for (int i=0; i<n; ++i) {
if (to[s[i]-'a'] == -1) printf ("%c", s[i]);
else printf ("%c", 'a' + to[s[i]-'a']);
}
puts (""); return 0;
}

  

找规律 C - Median Smoothing

题意:由01构成的序列,每一次a[i] = (a[i-1], a[i], a[i+1])的第二大,问多少次序列会稳定

分析:列出(a[i-1], a[i], a[i+1])的所有组合,发现只有010和101是不稳定的,所以找出这样的连续的最长的串,操作次数就是max_len / 2

/************************************************
* Author :Running_Time
* Created Time :2015/10/25 16:27:20
* File Name :C.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 = 5e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int a[N]; int main(void) {
int n; scanf ("%d", &n);
for (int i=1; i<=n; ++i) {
scanf ("%d", &a[i]);
}
int ans = 0;
for (int i=2; i<n; ++i) {
if (a[i] != a[i-1]) {
int j = i;
while (j < n && a[j] != a[j+1] && a[j] != a[j-1]) j++;
ans = max (ans, (j - i + 1) >> 1);
int p = i, q = j - 1;
while (p <= q) {
a[p++] = a[i-1];
a[q--] = a[j];
}
i = j;
}
}
printf ("%d\n", ans);
for (int i=1; i<=n; ++i) {
printf ("%d%c", a[i], i == n ? '\n' : ' ');
} //cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; return 0;
}

  

Codeforces Round #327 (Div. 2)的更多相关文章

  1. Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

    A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...

  2. Codeforces Round #327 (Div. 2) E. Three States BFS

    E. Three States Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/probl ...

  3. Codeforces Round #327 (Div. 2) D. Chip 'n Dale Rescue Rangers 二分 物理

    D. Chip 'n Dale Rescue Rangers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...

  4. Codeforces Round #327 (Div. 2) C. Median Smoothing 找规律

    C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/p ...

  5. Codeforces Round #327 (Div. 2) B. Rebranding 水题

    B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...

  6. Codeforces Round #327 (Div. 1), problem: (A) Median Smoothing

    http://codeforces.com/problemset/problem/590/A: 在CF时没做出来,当时直接模拟,然后就超时喽. 题意是给你一个0 1串然后首位和末位固定不变,从第二项开 ...

  7. Codeforces Round #327 (Div. 2) B. Rebranding C. Median Smoothing

    B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. T ...

  8. Codeforces Round #327 (Div. 2)B(逻辑)

    B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  9. Codeforces Round #327 (Div. 2)-Wizards' Duel

    题意: 在一条长度为l的走廊,两个人站在走廊的左右两端分别以p,q的速度走来,问他们相遇时离左端的距离是多少? 思路: 非常简单的暴力题,不解释. 代码如下: #include <iostrea ...

随机推荐

  1. 常用 C 头文件

    ISO C 标准定义的头文件 头文件 说明 <assert.h> 验证程序断言 <complex.h> 复数算术运算支持 <ctype.h> 字符分类和映射支持 & ...

  2. NGUI之UICamera控制触摸,鼠标事件

    http://blog.csdn.net/onerain88/article/details/18963539 . UICamera 功能介绍 主要包括UI事件的监听,分发,覆盖范围为此Camera渲 ...

  3. svn提交时强制添加注释 (转)

    SVN提交时,如果没有注释,在查阅历史时,会非常不方便.因此我们需要有一个让程序员提交代码时,强制添加注释的规则.下面看看在SVN中怎么实现. 1. 推荐使用VisualSVN作为服务端(免费下载地址 ...

  4. 百度图片爬虫-python版-如何爬取百度图片?

    上一篇我写了如何爬取百度网盘的爬虫,在这里还是重温一下,把链接附上: http://www.cnblogs.com/huangxie/p/5473273.html 这一篇我想写写如何爬取百度图片的爬虫 ...

  5. 安装cuda时 提示toolkit installation failed using unsupported compiler解决方法

    在安装cuda的时候,有时候会提示toolkit installation failed using unsupported compiler.这是因为GCC版本不合适所导致的. 解决的方法很简单,直 ...

  6. javascript memoization递归优化

    memoize优化递归 function createRec(callback, cache) { cache = cache || []; var rec = function(n) { (n in ...

  7. django signal 浅析

    默认的signals极其参数 (django 1.6.5) 模型的(django/db/models/signal.py): from django.dispatch import Signal cl ...

  8. 【Hibernate】Hibernate系列5之检索策略

    检索策略 5.1.类级别检索策略 5.2.set多对多.一对多检索策略 5.3.多对一.一对一检索策略 HQL作用: http://zhidao.baidu.com/link?url=dnAdJWR7 ...

  9. Rotate List

    Given a list, rotate the list to the right by k places, where k is non-negative. Example Given 1-> ...

  10. cmd的rd命令简单解析

    我们知道在Windows下cmd命令行中"rd 文件夹名称"可以删除空目录,"del 文件名"可以删除文件,那么怎么删除一个非空文件夹呢,命令如下: 比如删除文 ...