【Link】:http://codeforces.com/contest/831/problem/B

【Description】



两个键盘的字母的位置不一样;

数字键的位置一样;

告诉你第一个键盘按某个键,在第二个键盘上对应哪个键(大写、小写字母)

然后给你一段由第一个键盘输入的文本,问如果用第二个键盘输入,会输出什么.

【Solution】



用map一一对应就好;



【NumberOf WA】



0



【Reviw】



这种对应关系的题,map无敌;



【Code】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0) typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef set<int> myset; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 2e3; struct abc{
int x,id;
}; int k,n,a[N+100],b[N+100],pre[N+100],ans,tot;
map <int,int> dic;
abc c[N*N+10]; bool cmp(abc a,abc b){
return a.x < b.x;
} int main(){
//Open();
//Close();
scanf("%d%d",&k,&n);
rep1(i,1,k)
scanf("%d",&a[i]);
pre[0] = 0;
rep1(i,1,k)
pre[i] = pre[i-1] + a[i];
rep1(i,1,n)
scanf("%d",&b[i]);
rep1(i,1,k){
rep1(j,1,n){
int x = b[j]-pre[i];
tot++;
c[tot].x = x,c[tot].id = j;
}
}
sort(c+1,c+1+tot,cmp);
rep1(i,1,tot){
int num = n;
int j = i;
while (j+1<=tot && c[j+1].x==c[i].x) j++;
rep1(k,i,j){
if (dic[c[k].id]!=i){
num--;
dic[c[k].id] = i;
}
}
if (num==0) ans++;
i = j;
}
printf("%d\n",ans);
return 0;
} /*
写完之后,明确每一步的作用
*/

【Codeforces Round #424 (Div. 2) B】Keyboard Layouts的更多相关文章

  1. 【Codeforces Round #424 (Div. 2) A】Unimodal Array

    [Link]:http://codeforces.com/contest/831/problem/A [Description] 让你判断一个数列是不是这样一个数列: 一开始是严格上升 然后开始全都是 ...

  2. 【Codeforces Round #424 (Div. 2) C】Jury Marks

    [Link]:http://codeforces.com/contest/831/problem/C [Description] 有一个人参加一个比赛; 他一开始有一个初始分数x; 有k个评委要依次对 ...

  3. 【Codeforces Round #424 (Div. 2) D】Office Keys

    [Link]:http://codeforces.com/contest/831/problem/D [Description] 有n个人,它们都要去一个终点,终点位于p; 但是,在去终点之前,他们都 ...

  4. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  5. 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes

    [题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...

  6. 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees

    [题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...

  7. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

  8. 【Codeforces Round #423 (Div. 2) C】String Reconstruction

    [Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...

  9. 【Codeforces Round #423 (Div. 2) B】Black Square

    [Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...

随机推荐

  1. POJ 2528 Mayor&#39;s posters 离散化和线段树题解

    本题就是要往墙上贴海报,问最后有多少可见的海报. 事实上本题的难点并非线段树,而是离散化. 由于数据非常大,直接按原始数据计算那么就会爆内存和时间的. 故此须要把数据离散化. 比方有海报1 6   7 ...

  2. zzulioj--1787--生活危机(vector+dfs 好题)

    1787: 生化危机 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 97  Solved: 29 SubmitStatusWeb Board Desc ...

  3. 38.angular的scope作用域

    转自:https://www.cnblogs.com/best/tag/Angular/ 1. Scope(作用域) 是应用在 HTML (视图) 和 JavaScript (控制器)之间的纽带. S ...

  4. BZOJ 2251 Trie树

    思路: i~n加到Trie树里 经过的边权+1 DFS一遍 搞定~ //By SiriusRen #include <cstdio> #include <cstring> #i ...

  5. 范型在java中的应用

    根据泛型在java中的不同位置,大致可以分为类泛型.方法泛型和接口泛型.以下三个Demo基本展现三种泛型的用法,其中接口泛型又分两种情况描述.类泛型和方法泛型 import java.util.Arr ...

  6. c# window服务-初学习

    window服务-初学习 一.工具: VS2015+NET Framework4.5. 二.操作: 1.新建windows服务的项目: 2.修改windows服务相关内容: 3.预览windows服务 ...

  7. 文本域内容在div中带换行显示

    function ReplaceSeperator(mobiles) { var i; var result = ""; var c; for (i = 0; i < mob ...

  8. 瞎折腾-CentOS 7.4 编译4.16.2版kernel 并安装

    CentOS 7.4下 原内核版本: 3.10.0-693.el7.x86_64 改后内核版本: 4.16.2 系统版本: CentOS-7-x86_64-Minimal-1708.iso 运行环境: ...

  9. BZOJ 3639: Query on a tree VII LCT_set维护子树信息

    用 set 维护子树信息,细节较多. Code: #include <cstring> #include <cstdio> #include <algorithm> ...

  10. appium 模拟实现物理按键点击

    appium自动化测试中,当确认,搜索,返回等按键通过定位点击不好实现的时候,可以借助物理按键来实现.appium支持以下物理按键模拟: 电话键 KEYCODE_CALL 拨号键 5 KEYCODE_ ...