UESTC--1269--ZhangYu Speech(模拟)
Time Limit: 1000MS | Memory Limit: 65535KB | 64bit IO Format: %lld & %llu |
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:
- ZhangYu brother choose an index $x$ from $1$ to $n$.
- For all indices $y$ ( $y$ < $x$) calculate the difference $b_y = a_x - a_y$.
- 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
#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(模拟)的更多相关文章
- CDOJ 1269 ZhangYu Speech 数组处理
ZhangYu Speech Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submi ...
- CDOJ 1269 ZhangYu Speech
预处理打表,sum[i][j]表示1.....i这些数字中 j 有几个.然后就很好处理询问了. #include<stdio.h> #include<math.h> #incl ...
- 第七届ACM趣味程序设计竞赛第四场(正式赛) 题解
Final Pan's prime numbers 题目连接: http://acm.uestc.edu.cn/#/problem/show/1272 题意 给你n,要求你在[4,n]范围内找到一个最 ...
- UESTC 1074 秋实大哥搞算数 栈模拟
秋实大哥搞算数 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit S ...
- 论文翻译:2021_Towards model compression for deep learning based speech enhancement
论文地址:面向基于深度学习的语音增强模型压缩 论文代码:没开源,鼓励大家去向作者要呀,作者是中国人,在语音增强领域 深耕多年 引用格式:Tan K, Wang D L. Towards model c ...
- cdoj 25 点球大战(penalty) 模拟题
点球大战(penalty) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/2 ...
- 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 ...
- 2017年中国大学生程序设计竞赛-中南地区赛暨第八届湘潭市大学生计算机程序设计大赛题解&源码(A.高斯消元,D,模拟,E,前缀和,F,LCS,H,Prim算法,I,胡搞,J,树状数组)
A------------------------------------------------------------------------------------ 题目链接:http://20 ...
- Pat1071: Speech Patterns
1071. Speech Patterns (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HOU, Qiming Peo ...
随机推荐
- 字符串比较——compareTo函数
package com.day03.ifelse; import java.math.BigInteger; /** * @author 王恒 * @datetime 2017年4月7日 下午3:13 ...
- .net中的母版页中使用FindControl的使用
前几天,遇到一个字段比较多的用户填写的页面(数据库表中就将近100个字段),怎么讲这些input的标签的值,保存数据库了?(使用的是母版页下面的aspx,不包括前段获取input的值,传给后台) 作为 ...
- 备忘录模式(Memento)C++实现
备忘录模式 意图: 在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态.这样以后就可将改对象恢复到原先保存的状态. 适用性: 1.必须保存一个对象在某一个时刻的部分状态,这样以 ...
- java MD5加密的工具类
import java.security.MessageDigest; /** * MD5加密工具类 * @author zwq */ public class MD5Util { /** * MD5 ...
- 利用JavaScript实现文本框改文字功能
<html> <head> <meta charset="utf-8"> <title>无标题文档</title> &l ...
- GCC G++ Make CMake自我科普
Linux下gcc g++ make cmake 联系和区别 C/C++程序从编写到可执行一般经历这几个阶段 编写源代码 编译器编译代码生成目标文件,如.o文件 链接器链接目标文件和其他目标文件/库文 ...
- 【Oracle】Rman简介
1.备份和恢复功能的用途: –保护数据 -介质故障 -用户错误 -应用程序错误 –数据保存和历史数据保留 –数据传输 2.典型的备份和恢复任务 –通过配置数据库实现可恢复 –定义备份计划 –对不同类型 ...
- SqlServer数据库表导入SqlLite数据库表保持日期时间类型字段的格式
在写查询功能的过程中遇到一个这样的问题:按日期范围查询,sql语句是:where dt>=用户选择起始日期&&dt<=用户选择结束日期.数据库中的数据如图1,我选择的测试数 ...
- 『MicroPython』Hello uPy
官网买了几乎全套.一路曲折:7月10号下单,13号发货,14号法兰克福过关,23号到北京,25号到上海,27号到沪C:沪C邮局投3次未果,中彩票一样终于打通了投递部电话才在次日28号“妥投”:又因出差 ...
- chrome模拟微信
这里有一个模拟器,既可以设置模拟很多型号的手机设备,也可以伪造你想要的HTTP_USER_AGENT.选择USER_AGENT,选other,微信的HTTP_USER_AGENT是: 在iPhone下 ...