Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu

Submit
Status

Description

as we all know, ZhangYu(Octopus vulgaris) brother has a very famous speech - “Keep some distance from me”.


ZhangYu brother is so rich that everyone want to contact he, and scfkcf is one of them.


One day , ZhangYu brother agreed with scfkcf to contact him if scfkcf could beat him.


There are $n$ digits(lets give them indices from $1$ to $n$ and name them $a_1, a_2 … a_N$) and some queries.

for each query:

  1. ZhangYu brother choose an index $x$ from $1$ to $n$.
  2. For all indices $y$ ( $y$ < $x$) calculate the difference $b_y = a_x - a_y$.
  3. Then ZhangYu brother calculate $B_1$ ,the sum of all by which are greater than $0$ , and scfkcf calculate $B_2$ , the sum of all by which are less than $0$.

if $B_1 > |B_2|$ , ZhangYu brother won and did not agree with scfkcf to contact him;


else if $B_1$ is equals to $|B_2|$ , ZhangYu brother would ignore the result;

else if $B_1$ < $|B_2|$ , ZhangYu brother lost and agreed with scfkcf to contact him.

Input

The first line contains two integers $n$, $m$ $(1 \le n,m \le 100000)$ denoting the number of digits and number of queries. The second line contains $n$ digits (without spaces) $a_1, a_2, …, a_n$.$(0 \le a_i \le 9)$


Each of next $m$ lines contains single integer $x$ $(1 \le x \le n)$ denoting the index for current query.

Output

For each of $m$ queries print “Keep some distance from me” if ZhangYu won, else print
“Next time” if ZhangYu brother ignored the result, else print
“I agree”
if ZhangYu brother lost in a line - answer of the query.

Sample Input

10 3

0324152397

1

4

7

Sample Output

Next time

Keep some distance from me

I agree

Hint

It's better to use “scanf” instead of “cin” in your code.

Source

第七届ACM趣味程序设计竞赛第四场(正式赛)

每次统计x前边的0--9个数,然后输入x之后直接调用,要不然会超时

#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 1010
#define MAXM 100010
#define INF 0x3f3f3f
int num[MAXM];
char s[MAXM];
int p[20],sum[MAXM*10];
struct node
{
int p[20];
}d[MAXM*10];
int main()
{
int n,t;
while(scanf("%d%d\n",&n,&t)!=EOF)
{
scanf("%s",s+1);
memset(sum,0,sizeof(sum));
for(int i=1;i<=n;i++)
{
num[i]=s[i]-'0';
for(int j=0;j<=9;j++)
d[i].p[j]=d[i-1].p[j];
d[i].p[num[i]]=d[i-1].p[num[i]]+1;
}
while(t--)
{
int x;
scanf("%d",&x);
int b1,b2;
b1=b2=0;
// if(num[x]==0)
// printf("Next time\n");
// else
// {
for(int i=0;i<=9;i++)
{
if(d[x-1].p[i])
{
if(num[x]-i>0)
b1+=(num[x]-i)*d[x-1].p[i];
else
b2+=(num[x]-i)*d[x-1].p[i];
}
}
if(b1>fabs(b2))
printf("Keep some distance from me\n");
else if(b1==fabs(b2))
printf("Next time\n");
else printf("I agree\n");
// }
}
}
return 0;
}

UESTC--1269--ZhangYu Speech(模拟)的更多相关文章

  1. CDOJ 1269 ZhangYu Speech 数组处理

    ZhangYu Speech Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submi ...

  2. CDOJ 1269 ZhangYu Speech

    预处理打表,sum[i][j]表示1.....i这些数字中 j 有几个.然后就很好处理询问了. #include<stdio.h> #include<math.h> #incl ...

  3. 第七届ACM趣味程序设计竞赛第四场(正式赛) 题解

    Final Pan's prime numbers 题目连接: http://acm.uestc.edu.cn/#/problem/show/1272 题意 给你n,要求你在[4,n]范围内找到一个最 ...

  4. UESTC 1074 秋实大哥搞算数 栈模拟

    秋实大哥搞算数 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit S ...

  5. 论文翻译:2021_Towards model compression for deep learning based speech enhancement

    论文地址:面向基于深度学习的语音增强模型压缩 论文代码:没开源,鼓励大家去向作者要呀,作者是中国人,在语音增强领域 深耕多年 引用格式:Tan K, Wang D L. Towards model c ...

  6. cdoj 25 点球大战(penalty) 模拟题

    点球大战(penalty) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/2 ...

  7. 2015 UESTC Winter Training #8【The 2011 Rocky Mountain Regional Contest】

    2015 UESTC Winter Training #8 The 2011 Rocky Mountain Regional Contest Regionals 2011 >> North ...

  8. 2017年中国大学生程序设计竞赛-中南地区赛暨第八届湘潭市大学生计算机程序设计大赛题解&源码(A.高斯消元,D,模拟,E,前缀和,F,LCS,H,Prim算法,I,胡搞,J,树状数组)

    A------------------------------------------------------------------------------------ 题目链接:http://20 ...

  9. Pat1071: Speech Patterns

    1071. Speech Patterns (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HOU, Qiming Peo ...

随机推荐

  1. 前端(小程序)项目Aes.js/Md5.js加密的处理方法

    做项目中需要对前端数据加密传输这个时候需要用到前端加密的算法主要是:Aes.js,Md5.js 一.Vue项目用到的aes.js加密. 1.直接在index.html引入aes.js或者在npm in ...

  2. VS2015启动显示无法访问此网站

    之前启动项目发生过几次,也忘了怎么解决了,今天记录一下:将应用文件夹下的vs目录删除,重新生成解决方案后,程序正常启动. 原文链接:https://blog.csdn.net/upi2u/articl ...

  3. [Offer收割]编程练习赛40

    不到一个小时AK,虽然是VP的,舒服,第一次.都简单的一比,没什么可说的. 查找三阶幻方 #pragma comment(linker, "/STACK:102400000,10240000 ...

  4. WPF自定义动画控件 风机

      一:创建WPF项目 二:在项目下添加文件Themes,在此文件下添加新项 ”资源词典“取名为 Generic.xaml  注意大小写,之前遇到因为大小写不对应,导致出错的情况Generic.xam ...

  5. 时间&物质&效率

    由于我的家庭是地道的农民家庭,在上学的时候,父母很辛苦的供我读初中,高中,大学. 现在我想说的是,用时间来换取效率是我求学时最大的遗憾. 举一个例子吧:每次回家坐火车,火车很费时间,假如我不缺钱,完全 ...

  6. WCF与 Web Service的区别是什么?各自的优点在哪里呢?

    这是很多.NET开发人员容易搞错的问题.面试的时候也经常遇到,初学者也很难分快速弄明白 Web service: .net技术中其实就指ASP.NET Web Service,用的时间比较长,微软其实 ...

  7. 使用Axis2方式发布webService实例说明

    1.简单的pojo方式: 不需要写配置文件,直接把class文件拷贝到axis2的WEB-INF目录下的poji文件夹下即可.但其局限性表现在,实现类不能有包声明,这在实际开发过程中使用较少,这里不做 ...

  8. 【Oracle】利用trace文件重建控制文件

    重建步骤: 1.生成trace文件: alter database backup controlfile to trace; 2.找到生成的trace文件: show parameter dump u ...

  9. ubuntu 16.04 php5 环境搭建

    Ubuntu 16.04默认安装php7.0环境,但是php7目前兼容性并不是很好,如果自行安装php5需要清除php7的已安装包,否则会报错. 移除默认及已安装的PHP包 sudo dpkg -l ...

  10. 如何快速在命令提示符(cmd)中打开指定的文件夹路径!

    按住shift键然后 右击,如图: