Codeforces Round #327 (Div. 2)
题目都没看清就写了,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;
}
题意:要求字符串的所有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;
}
题意:由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)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #327 (Div. 2) B. Rebranding 水题
B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...
- Codeforces Round #327 (Div. 1), problem: (A) Median Smoothing
http://codeforces.com/problemset/problem/590/A: 在CF时没做出来,当时直接模拟,然后就超时喽. 题意是给你一个0 1串然后首位和末位固定不变,从第二项开 ...
- 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 ...
- Codeforces Round #327 (Div. 2)B(逻辑)
B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #327 (Div. 2)-Wizards' Duel
题意: 在一条长度为l的走廊,两个人站在走廊的左右两端分别以p,q的速度走来,问他们相遇时离左端的距离是多少? 思路: 非常简单的暴力题,不解释. 代码如下: #include <iostrea ...
随机推荐
- 成为Android高手必须掌握的28大项内容和10个建议
(一)成为Android高手必须掌握的8项基本要求 [1] Android操作系统概述1. Android系统架构. 2. Android利用设计理念. 3. ...
- i3D的一篇Unity教程中的笔记
原地址:http://blog.sina.com.cn/s/blog_72b936d80100wwej.html 以下是i3D的一篇Unity教程中的笔记. i3D的这篇教程是[i3D.Next-Ge ...
- 压缩 javascript 和 css
www.iwangzheng.com 目前我们项目中的 CSS/JS 文件比较多, 由于RAILS 3.0 没有提供asset pipeline功能,所以这样会制约我们的访问速度. 例如: 目前,我 ...
- 技术分享:WIFI钓鱼的入门姿势
简介 该实验先是搭建一个测试环境,然后创建一个假的无线接入点,把网络连接连接到假的接入点并且强迫用户连接假的无线点. 事先准备 1.无线网卡:无线网卡用于数据包的嗅探和注入. 2. Backtrack ...
- angular 监听ng-repeat结束时间
有些时候我们想要监听angular js中的 ng-repeat结束事件,从而好初始化一些我们的第三方或者其他需要初始化的js. 我们可以这样处理: js 中这样定义 : //监听事件 是否加载完毕a ...
- Python 命令详解
1. 新建一个 django-project django-admin.py startproject project-name 一个 project 一般为一个项目 2. 新建 app python ...
- 友盟消息推送和更新XML配置
<receiver android:name="com.umeng.message.NotificationProxyBroadcastReceiver" android:e ...
- 以Python角度学习Javascript(一)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAO4AAADZCAIAAACo85tgAAAgAElEQVR4Aey9SdAs13XnV/P8jW8e8D ...
- MongoDB概述&语法
Nosql DB 这是一个非关系型数据库. 通常我们的数据库有三类: 关系型数据库(RDBMS),联机分析处理数据库(OLAP),和菲关系型数据库(NoSql). MongoDB属于第三种,而且是一 ...
- NGINX userid 分析、解码
NGINX userid 分析.解码 生成userid的代码在 http/modules/ngx_http_userid_filter_module.c 大概550行左右. uid_set 是4个ui ...