A. Vitaly and Strings

题意:两个字符串s,t,是否存在满足:s < r < t 的r字符串
字符转处理:字典序排序
很巧妙的方法,因为s < t,只要找比t字典序稍微小一点的和s比较就行了
具体方法和数字减1相类似,从"个位"减1,如果是0,从前面借1
!strcmp (t, s):如果t < s 或者 t > s (不可能)则输出,t == s 则输出NO

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
using namespace std; const int MAXN = 1e6 + 10;
const int INF = 0x3f3f3f3f; int main(void)
{
//freopen ("A.in", "r", stdin); char s[110], t[110]; while (~scanf ("%s %s", &s, &t))
{
int cnt = strlen (s) - 1;
while (t[cnt] == 'a' && cnt >= 0)
{
t[cnt] = 'z';
cnt--;
}
t[cnt]--;
(!strcmp (t, s)) ? puts ("No such string") : printf ("%s\n", t);
} return 0;
}

B. Tanya and Postcard

字符串处理:字符查找
记录s,t各自的大小写字母的数量,然后累加完全匹配的cnty和不完全匹配的cntw
这道题题目我没读懂,cntw不完全匹配意思是:只是大小不相同

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <set>
using namespace std; const int MAXN = 2e5 + 10;
const int INF = 0x3f3f3f3f; int main(void)
{
//freopen ("B.in", "r", stdin); char s[MAXN], t[MAXN];
int m1[30], m2[30], m3[30], m4[30]; while (cin >> s >> t)
{
memset (m1, 0, sizeof (m1));
memset (m2, 0, sizeof (m2));
memset (m3, 0, sizeof (m3));
memset (m4, 0, sizeof (m4));
for (int i=0; s[i]!='\0'; ++i)
{
if (s[i]>='a' && s[i]<='z')
m1[s[i] - 'a']++;
else
m2[s[i]-'A']++;
}
for (int i=0; t[i]!='\0'; ++i)
{
if (t[i]>='a' && t[i]<='z')
m3[t[i] - 'a']++;
else
m4[t[i]-'A']++;
}
int cnty = 0, cntw = 0;
for (int i=0; i<26; ++i)
{
int d = min (m1[i], m3[i]);
m1[i] -= d;
m3[i] -= d;
cnty += d;
d = min (m2[i], m4[i]);
m2[i] -= d;
m4[i] -= d;
cnty += d;
}
for (int i=0; i<26; ++i)
{
int d = min (m1[i], m4[i]);
m1[i] -= d;
m4[i] -= d;
cntw += d;
d = min (m2[i], m3[i]);
m2[i] -= d;
m3[i] -= d;
cntw += d;
} cout << cnty << " " << cntw << endl;
} return 0;
}

C. Anya and Smartphone

无算法
统计划屏的次数,如果在第一屏则不用,只要每次交换与前面数字的顺序就行了
注意:ans开long long
好吧,这道题是最水的,主要是题目很难读懂,可以从Note里猜出题目意思

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
using namespace std; const int MAXN = 1e5 + 10;
const int INF = 0x3f3f3f3f; int num[MAXN];
int pos[MAXN]; int main(void)
{
//freopen ("C.in", "r", stdin); int n, m, k; while (~scanf ("%d%d%d", &n, &m, &k))
{
int x;
for (int i=1; i<=n; ++i)
{
scanf ("%d", &x);
pos[x] = i;
num[i] = x;
}
long long ans = 0;
for (int i=1; i<=m; ++i)
{
scanf ("%d", &x); int p = pos[x];
ans += (p / k);
if (p % k) ans += 1;
if (p == 1) continue; int y = num[p-1];
num[p-1] = x;
num[p] = y;
pos[y]++; pos[x]--;
} printf ("%I64d\n", ans);
} return 0;
}

  

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

  1. Codeforces Round #293 (Div. 2) D. Ilya and Escalator 概率DP

    D. Ilya and Escalator time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  2. Codeforces Round #293 (Div. 2) C. Anya and Smartphone 数学题

    C. Anya and Smartphone time limit per test 1 second memory limit per test 256 megabytes input standa ...

  3. Codeforces Round #293 (Div. 2) B. Tanya and Postcard 水题

    B. Tanya and Postcard time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  4. Codeforces Round #293 (Div. 2) A. Vitaly and Strings

    A. Vitaly and Strings time limit per test 1 second memory limit per test 256 megabytes input standar ...

  5. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  6. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  7. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  8. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  9. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

随机推荐

  1. thinkphp中I方法

    概述 正如你所见到的一样,I方法是ThinkPHP众多单字母函数中的新成员,其命名来自于英文Input(输入),主要用于更加方便和安全的获取系统输入变量,可以用于任何地方,用法格式如下:I('变量类型 ...

  2. 【NGUI】grid下面的item的重复利用

    http://blog.csdn.net/u012091672/article/details/21159075解决的问题 使用grid放置item的时候,每次数据可能都不一样,但是每次都删除grid ...

  3. Instance Variables in ruby

    Dogs have many shared characteristics, like the abilities to wag their tails and drink water from a ...

  4. ICA

    参考:http://www.cnblogs.com/jerrylead/archive/2011/04/19/2021071.html 对高斯分布的样本点效果不好.数学真是博大精深啊

  5. django-cms 代码研究(二)bugs?

    djangocms集成到现有项目中后,发现了几个问题: 1. 现有项目的url匹配失效,下面requests请求被交给djangocms处理了 url(r'^admin/', include(admi ...

  6. jquery博客收集的IE6中CSS常见BUG全集及解决方案

    今天的样式调的纠结,一会这边一会那么把jquery博客折腾的头大,浏览器兼容性.晚上闲着收集一些常见IE6中的BUG 3像素问题及解决办法 当使用float浮动容器后,在IE6下会产生3px的空隙,有 ...

  7. 【消息队列MQ】各类MQ比较

    目录(?)[-] RabbitMQ Redis ZeroMQ ActiveMQ JafkaKafka 目前业界有很多MQ产品,我们作如下对比: RabbitMQ 是使用Erlang编写的一个开源的消息 ...

  8. global-local-static-object

    [本文链接] http://www.cnblogs.com/hellogiser/p/global-local-static-object.html [分析] 1.生命周期问题:static变量在固定 ...

  9. Android Studio "diamond operator is not supported" 处理方法

    低版本的android编译环境是不支持使用java7语法的,如果使用了,就会产生上述问题,如果你的android环境较新,那么可以使用以下方法: 在build.gradle的android标签下加入以 ...

  10. codeforces A. New Year Candles 解题报告

    题目链接:http://codeforces.com/problemset/problem/379/A 题目意思:给定a支蜡烛(每支蜡烛可以燃烧1小时),可以在燃尽的a支蜡烛中看能组成多少组b支蜡烛, ...