http://codeforces.com/contest/465

rating+7,,简直。。。

感人肺腑。。。。。。。。。。。。。。。蒟蒻就是蒟蒻。。。。。。。。。

被虐瞎

a:inc ARG

题意:将串反过来后+1问有多少个位变化。。

。。我是模拟的。。

#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int N=105;
int a[N], n;
int main() {
read(n);
char s[N];
scanf("%s", s);
rep(i, n) a[i+1]=s[i]-'0';
a[1]+=1;
int t=a[1]/2, i=2, ans=1; a[1]%=2;
while(t && i<=n) {
a[i]+=t;
t=a[i]/2;
a[i]%=2;
i++;
++ans;
}
print(ans);
return 0;
}

b:Inbox (100500)

题意:对一个01序列有3种操作,要求将所有的1变成0,求最小步数

1.从目录到达任意位置。(到达的地方1变成0,如果是0那么不变)

2.回到目录

3.向前或想后走一步

显然的贪心。。。

对于一个相连的块,要到达下一个块,最佳方案就是回到目录再到下一个块的初始位置,需要2步(尽管他们距离1,向前走也是需要2步)

对于同一个块内的点,直接往前走就行。。

然后模拟累计。。

#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int N=1005;
int a[N], n;
int main() {
read(n);
for1(i, 1, n) read(a[i]);
int ans=-1;
for1(i, 1, n) {
while(a[i]==0 && i<=n) ++i;
if(i>n) break;
while(a[i]&&a[i+1] && i<=n) { ++i; ++ans; }
ans+=2;
}
if(ans==-1) ans=0;
print(ans);
return 0;
}

c:No to Palindromes!

题意:给你一个没有长度为2以上(包括2)的回文串的一个字符串,然后让你求比他大的所有排列且没有长度为2以上(包括2)的下一个最小的排列。

剩下的1个半小时都在搞这题。。。。。。。。。。T_T

神题。。

我dfs写渣

判重写渣

然后滚粗。

这里有个贪心。

串的任意部分都不能是回文=串中任意连续3个字符互不相同

那么如果从左往右找,那么只需要判断x-1和x-2与x不等即可

其次我们要保证字典序最小,所以我们从右向左依次尝试修改,只要找到不符合回文条件的点,就修改它。这样保证了前边的最小。。

而且能证明,后边一定能构造出一个不是回文的串。例如m=4,我可以构造abcabcabc。。。。。。。。。。。。(x-1和x-2与x不等)

#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << #x << " = " << x << endl
#define printarr(a, n, m) rep(aaa, n) { rep(bbb, m) cout << a[aaa][bbb]; cout << endl; }
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int N=2015;
char str[N];
int n, m; inline const char fix(const int &p) {
char i;
for(i=str[p]+1; i<'a'+m; ++i)
if(str[p-1]!=i && str[p-2]!=i) return i;
return 0;
}
int main() {
read(n); read(m);
scanf("%s", str);
int len=strlen(str);
int i;
for(i=len-1; i>=0; --i) {
char t=fix(i);
if(t) { str[i]=t; break; }
}
if(i==-1) { puts("NO"); return 0; }
for(++i; i<len; ++i) {
str[i]='a'-1;
char t=fix(i);
if(t) str[i]=t;
}
printf("%s", str);
return 0;
}

d:没看。。

e:没看。。

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

  1. Codeforces Round #265 (Div. 1) C. Substitutes in Number dp

    题目链接: http://codeforces.com/contest/464/problem/C J. Substitutes in Number time limit per test 1 sec ...

  2. Codeforces Round #265 (Div. 2) C. No to Palindromes! 构建无回文串子

    http://codeforces.com/contest/465/problem/C 给定n和m,以及一个字符串s,s不存在长度大于2的回文子串,如今要求输出一个字典比s大的字符串,且串中字母在一定 ...

  3. Codeforces Round #265 (Div. 2) E. Substitutes in Number

    http://codeforces.com/contest/465/problem/E 给定一个字符串,以及n个变换操作,将一个数字变成一个字符串,可能为空串,然后最后将字符串当成一个数,取模1e9+ ...

  4. Codeforces Round #265 (Div. 2) D. Restore Cube 立方体判断

    http://codeforces.com/contest/465/problem/D 给定8个点坐标,对于每个点来说,可以随意交换x,y,z坐标的数值.问说8个点是否可以组成立方体. 暴力枚举即可, ...

  5. Codeforces Round #265 (Div. 2) C. No to Palindromes! 构造不含回文子串的串

    http://codeforces.com/contest/465/problem/C 给定n和m,以及一个字符串s,s不存在长度大于2的回文子串,现在要求输出一个字典比s大的字符串,且串中字母在一定 ...

  6. Codeforces Round #265 (Div. 2) D. Restore Cube 立方体推断

    http://codeforces.com/contest/465/problem/D 给定8个点坐标.对于每一个点来说,能够任意交换x.y,z坐标的数值. 问说8个点能否够组成立方体. 暴力枚举就可 ...

  7. Codeforces Round #265 (Div. 2) E

    这题说的是给了数字的字符串 然后有n种的操作没次将一个数字替换成另一个字符串,求出最后形成的字符串的 数字是多大,我们可以逆向的将每个数推出来,计算出他的值和位数记住位数用10的k次方来记 1位就是1 ...

  8. Codeforces Round #265 (Div. 2) B. Inbox (100500)

    Over time, Alexey's mail box got littered with too many letters. Some of them are read, while others ...

  9. Codeforces Round #265 (Div. 1)

    D. World of Darkraft - 2 time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

随机推荐

  1. grid control 11.1.0.1 安装指南

    grid control 11.1.0.1 安装指南 废话少说,进入正题 系统版本号 [root@gridcontrol ~]# lsb_release -a LSB Version:    :bas ...

  2. OE context 传参数

    来自:http://shine-it.net/index.php/topic,16360.0.html 有个需求想many2one字段关联显示的value在各个模块显示不同的值. 如果直接该rel_n ...

  3. fopen /open,read/write和fread/fwrite区别

    fopen /open,read/write和fread/fwrite区别         转载URL:http://hi.baidu.com/%B9%C8%C9%F1%B2%BB%CB%C0jdp/ ...

  4. TCP 中出现RST的情况

    http://www.360doc.com/content/13/0702/10/1073512_297069771.shtml 原 几种TCP连接中出现RST的情况 发表于1年前(2013-05-0 ...

  5. ubuntu——主题更新,Ubuntu-tweak安装

    1.首先打开终端 2.在终端中输入sudo apt-add-repository ppa:tualatrix/ppa 回车后输入密码等一会,导入密钥 3.再输入sudo apt-get update ...

  6. OFBiz:初始RequestHandler

    RequestHandler,可以称之为请求处理器,在ControlServlet.init()中初始化: public class ControlServlet extends HttpServle ...

  7. 一个模块包含多目录和源文件,Makefile写法

    假设这样一种情况,一个内核模块有多个目录多个源文件组成,编译成模块是Makefile如何编写呢? 我这边测试通过的一种方法介绍一下.假设该模块的组成方式如下: module--> a.c     ...

  8. C++ bool和string转换

    直接贴代码吧.用g++能够编译.測试ok #include <iostream> #include <sstream> using namespace std; int mai ...

  9. Sphinx全文检索引擎测试

    数据表 1.documents CREATE TABLE `documents` ( `id` int(13) NOT NULL auto_increment, `group_id` int(11) ...

  10. Centos 开启telnet-service服务

    1. 查看linux版本信息: [loong@localhost ~]$ cat /etc/issue CentOS release 5.8 (Final) Kernel \r on an \m 2. ...