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. webpack 编译图片文件 file-loader

    1.安装插件 npm i file-loader --save-dev  npm i url-loader --save-dev  npm install image-webpack-loader - ...

  2. HDU 5005(Compromise-双人目标为最大化不同值的博弈)

    Compromise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total ...

  3. 基于Redis的消息队列php-resque

    转载:http://netstu.5iunix.net/archives/201305-835/ 最近的做一个短信群发的项目,需要用到消息队列.因此开始了我对消息队列选型的漫长路. 为什么选型会纠结呢 ...

  4. sqlserver学习笔记(六)—— sqlserver内置函数(字符串、日期)

    sqlserver中有很多内置函数,这里总结了一些常用的 一.关于字符串的函数: 1.CHARINDEX 寻找一个指定字符串在另一个字符串中的起始位置 SELECT CHARINDEX('world‘ ...

  5. vector 类简介和例程

    一.标准库的vector类型 vector是同一种类型的对象的集合 vector的数据结构很像数组,能非常高效和方便地访问单个元素 vector是一个类模板(class template) vecto ...

  6. 如何编写安全的PHP代码

    转于:http://www.nowamagic.net/php/php_HowToWriteSafePhpCode.php

  7. JVM虚拟机(四):JVM 垃圾回收机制概念及其算法

    垃圾回收概念和其算法 谈到垃圾回收(Garbage Collection)GC,需要先澄清什么是垃圾,类比日常生活中的垃圾,我们会把他们丢入垃圾箱,然后倒掉.GC中的垃圾,特指存于内存中.不会再被使用 ...

  8. docker 下 alpine 镜像设置时区的有效办法

    在使用Docker的时候,由于很多基础linux镜像都比较大,alpine这个仅仅几兆的linux基础镜像受到了很多人喜欢,笔者也不例外,可是由于alpine中的一些配置及命令与常见的centos等系 ...

  9. Android_WebServices_源代码分析

    本博文为子墨原创,转载请注明出处! http://blog.csdn.net/zimo2013/article/details/38037989 在Android_WebServices_介绍一文中, ...

  10. 异步FIFO的FPGA实现

    本文大部分内容来自Clifford E. Cummings的<Simulation and Synthesis Techniques for Asynchronous FIFO Design&g ...