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. 如何更改firefox默认搜索引擎?一步搞定!

    由于开发设计的需要,ytkah平时习惯使用firefox作为默认浏览器,火狐浏览器可添加的扩展功能比较,比如firebug.nofollow.seoquake等,还有比较友好的功能就是选中关键词拖动直 ...

  2. Ultra-QuickSort

    Ultra-QuickSort Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 44489   Accepted: 16176 ...

  3. cc表示Cocos核心,ccs代表CocoStudio,ccui代表CocoStudio的UI控件

    cc表示Cocos核心,ccs代表CocoStudio,ccui代表CocoStudio的UI控件

  4. previous_changes方法

    [27] pry(main)> c = Channel.find 6 => #<Channel id: 6, title: "会员", cid: "96 ...

  5. Coursera台大机器学习课程笔记13 -- Regularization

    这一节讲的是正则化,在优化中一直会用到正则化项,上课的时候老师一句话代过,没有作过多的解释.听完这节课后, 才明白好大学和野鸡大学的区别有多大.总之,这是很有收获的一节课. 首先介绍了为什么要正则化, ...

  6. myeclipse2014安装反编译插件

    一.在线安装方式: Eclipse Class Decompiler整合了目前最好的2个Java反编译工具Jad和JD-Core,并且和Eclipse Class Viewer无缝集成,能够很方便的使 ...

  7. HDOJ 1856

    #include<cstdio> #include<cstdlib> typedef struct ufse *ufset; struct ufse { ]; ]; }UFS; ...

  8. 又一款linux提权辅助工具

    又一款linux提权辅助工具 – Linux_Exploit_Suggester 2013-09-06 10:34 1455人阅读 评论(0) 收藏 举报 https://github.com/Pen ...

  9. svn 设置

    \Release *\Debug *\bin *\Bin *\obj *\_ReSharper* *\.hg *.ReSharper *.resharper *\Generated_Code *\VB ...

  10. ali2015校园招聘笔试大题

    [本文链接] http://www.cnblogs.com/hellogiser/p/ali-2015-questions.html 1. 写一个函数,输入一个二叉树,树中每个节点存放了一个整数值,函 ...