题目传送门

水 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. Unity游戏开发之“屏幕截图”

    原地址:http://sygame.lofter.com/post/117105_791680 在unity游戏开发中,可能会遇到在游戏中截屏的效果.这儿提供两种截屏方法.(方法二提供显示截图缩略图代 ...

  2. cocos2d调度器(定时执行某函数)

    调度器(scheduler) 继承关系 原理介绍 Cocos2d-x调度器为游戏提供定时事件和定时调用服务.所有Node对象都知道如何调度和取消调度事件,使用调度器有几个好处: 每当Node不再可见或 ...

  3. 基于 MeanShift 算法的目标跟踪问题研究

    参考:http://www.cnblogs.com/tornadomeet/archive/2012/03/15/2398769.html MeanShift 算法作为一种基于特征的跟踪方法,基本思想 ...

  4. Linux中启动和停止jar包的运行

    脚本一: startTest.sh内容如下: #!/bin/sh java -jar Test.jar &       #注意:必须有&让其后台执行,否则没有pid生成 echo $! ...

  5. DataSnap 用TStream 传递大数据 返回流大小为-1的情况

    DataSnap可以直接传递和返回TStream类型的参数,这点是很方便的.但是很多人发现好像大小稍微大点就工作不正常了,就变相使用其它类型转换来转换去,这样便利性就失去了. 官方有篇博客很详细的介绍 ...

  6. VMware的四种网络连接方式

    mkdir  /mn/cdrom mount /dev/cdrom /mnt/cdrom Bridge:这种方式最简单,直接将虚拟网卡桥接到一个物理网卡上面,和linux下一个网卡 绑定两个不同地址类 ...

  7. css form 表单组对齐

    2014年7月1日 15:31:17 第一次写css,见谅 css: .form-box .form-group .form-label {text-align: right; width: 200p ...

  8. 【python】2048

    来源:https://www.shiyanlou.com/courses/368 实验楼的2048程序,在linux下可实现通过终端游戏. 主要学习的知识点: 1.状态机函数实现,用字典将状态和函数相 ...

  9. 连续自然数和(codevs 1312)

    题目描述 Description 对于一个自然数M,求出所有的连续的自然数段,使得这些连续自然数段的全部数字和为M.eg:1998+1999+2000+2001+2002=10000,所以从1998到 ...

  10. java 学习之路

    一.基础篇 1.1 JVM 1.1.1. Java内存模型,Java内存管理,Java堆和栈,垃圾回收 http://www.jcp.org/en/jsr/detail?id=133 http://i ...