【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. poj3252-Round Number 组合数学

    题目: Round Numbers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8492   Accepted: 2963 ...

  2. .NET 框架简单介绍

    初学.NET肯定会有一系列的疑问,比方(下面为自己的疑问): 1) 何为. NET框架.它都包括哪些东西? 2) 程序集是什么.它是怎样在CLR(通用语言执行时)中执行的? 3) C#与VB.NET同 ...

  3. javascript常用收集一下

    事件源对象 event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElement.setCapture(); event.srcEl ...

  4. PHP安装curl扩展

    昨天在写文章的时候,突然出现了一个很顽皮的bug. 一直跳到404页面??? 于是我赶紧打开debug,看看什么情况! 弹出的错误是 :Call to undefined function Home\ ...

  5. kubernetes学习与实践篇(二) kubernetes1.5 的安装和集群环境部署

    kubernetes 1.5 的安装和集群环境部署 文章转载自:http://www.cnblogs.com/tynia/p/k8s-cluster.html 简介: Docker:是一个开源的应用容 ...

  6. P3514 [POI2011]LIZ-Lollipop(规律+瞎搞)

    题意 给一个只有1和2的序列,每次询问有没有一个子串的和为x ( 1≤n,m≤1 000 000 )kkk ( 1≤k≤2 000 000 ) 题解 我觉得是道好题. 主要是证明一个性质:假如有一个字 ...

  7. [洛谷P3932]浮游大陆的68号岛

    题目大意:有一行物品,每两个物品之间有一个距离.每个物品有一个价值.现在问你若干问题,每个问题问你把l~r所有物品全部搬到物品x处需要多少价值. 把物品a搬到物品b处的价值为物品a的价值乘a到b的距离 ...

  8. python中的装饰器decorator

    python中的装饰器 装饰器是为了解决以下描述的问题而产生的方法 我们在已有的函数代码的基础上,想要动态的为这个函数增加功能而又不改变原函数的代码 例如有三个函数: def f1(x): retur ...

  9. SCU 1095运送物资(最短路)

    SCU 1095运送物资(最短路) X国发生了内战.起义军得到了广大人民的支持.在一次战役中,反动军队结集了大量兵力,围攻起义军的主堡W城.为支援前线,后方各个供给基地城市纷纷准备将物资运往W城.各基 ...

  10. PatentTips - Compare and exchange operation using sleep-wakeup mechanism

    BACKGROUND Typically, a multithreaded processor or a multi-processor system is capable of processing ...