10324 - Zeros and Ones
Problem N
Zeros and Ones
Input: standard input
Output: standard output
Time Limit: 2 seconds
Memory Limit: 32 MB
Given a string of 0's and 1's up to 1000000 characters long and indices i and j, you are to answer a question whether all characters between position min(i,j) and position max(i,j) (inclusive) are the same.
Input
There are multiple cases on input. The first line of each case gives a string of 0's and 1's. The next line contains a positive integer n giving the number of queries for this case. The next n lines contain queries, one per line. Each query is given by two non-negative integers, i and j. For each query, you are to print Yes if all characters in the string between position min(i,j) and position max(i,j) are the same, and No otherwise.
Output
Each case on output should start with a heading as in the sample below. The input ends with an empty string that is a line containing only the new line character, this string should not be processed. The input may also with end of file. So keep check for both.
Sample Input
0000011111
3
0 5
4 2
5 9
01010101010101010101010101111111111111111111111111111111111110000000000000000
5
4 4
25 60
1 3
62 76
24 62
1
1
0 0
Sample Output
Case 1:
No
Yes
Yes
Case 2:
Yes
Yes
No
Yes
No
Case 3:
Yes
#include<stdio.h>
#include<string.h>
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
char a[1000005];
int check(int x,int y)
{
int z;
for(z=x;z<=y;z++)
if(a[x]!=a[z])
return 0;
return 1;
}
int main()
{
int n,i,j,k,count=1;
while(scanf("%s",a)!=EOF)
{
printf("Case %d:\n",count++);
scanf("%d",&n);
for(k=0;k<n;k++)
{
scanf("%d%d",&i,&j);
if(check(min(i,j),max(i,j)))
puts("Yes");
else
puts("No");
}
}
return 0;
}
10324 - Zeros and Ones的更多相关文章
- UVA - 10324 Zeros and Ones
Description Given a string of 0's and 1's up to 1000000 characters long and indices i and j, you are ...
- Trailing Zeros
Write an algorithm which computes the number of trailing zeros in n factorial. Have you met this que ...
- Case of the Zeros and Ones 分类: CF 2015-07-24 11:05 15人阅读 评论(0) 收藏
A. Case of the Zeros and Ones time limit per test 1 second memory limit per test 256 megabytes input ...
- Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones 水题
A. Case of the Zeros and Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...
- lintcode :Trailing Zeros 尾部的零
题目: 尾部的零 设计一个算法,计算出n阶乘中尾部零的个数 样例 11! = 39916800,因此应该返回 2 挑战 O(logN)的时间复杂度 解题: 常用方法: 也许你在编程之美中看到,通过求能 ...
- UVa 12063 (DP) Zeros and Ones
题意: 找出长度为n.0和1个数相等.没有前导0且为k的倍数的二进制数的个数. 分析: 这道题要用动态规划来做. 设dp(zeros, ones, mod)为有zeros个0,ones个1,除以k的余 ...
- Codeforces 556A Case of the Zeros and Ones(消除01)
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Andr ...
- A. Case of the Zeros and Ones----解题报告
A. Case of the Zeros and Ones Description Andrewid the Android is a galaxy-famous detective. In his ...
- Case of the Zeros and Ones
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Andrew ...
随机推荐
- C#2.0--集合--转载车老师
集合在编程的过程中用的是非常的多,如GridViewRowCollection.ConnectionStringSettingsCollection.NameValueCollection等等.一般来 ...
- 删除workspace下的vss的scc文件
public class DeleteAA { public static void main(String[] args) { DeleteAA aa=new DeleteAA(); aa.dele ...
- UC网盘被关停 将与阿里淘盘合并?(案例说明云盘的成本才是重点,技术不是问题;与巨头竞争是重点)
UC网盘被关停 将与阿里淘盘合并? 二八2016-03-18 08:05:36阿里巴巴 网盘 产品阅读(0)评论(12) UC网盘项目组日前发布公告称将停止网盘存储服务,原因为配合国家对云盘传播淫秽色 ...
- WPF/Silverlight深度解决方案:(一)解锁被Storyboard束缚的关联属性
原文 WPF/Silverlight深度解决方案:(一)解锁被Storyboard束缚的关联属性 如果您在使用WPF/Silverlight进行相关动画开发中使用了Storyboard,并对关联属性进 ...
- jQuery ajax表单提交实现局部刷新
jQuery Ajax 异步提交 Form 表单,如果使用 get 请求,注意中文乱码问题,jquery 会先使用 iso8859-1 解码,然后发给服务器,如果使用 post 请求,则直接将中文内容 ...
- spring mvc MultipartFile 上传文件错误解决
Field error in object 'xxxx' on field 'xxxx': rejected value [20129259128131.jpg]; codes [typeMismat ...
- VC socket Connect 超时时间设置
设置connect超时很简单,CSDN上也有人提到过使用select,但却没有一个令人满意与完整的答案.偶所讲的也正是select函数,此函数集成在winsock1.1中,简单点讲,"作用使 ...
- 在webx.ml中 配置struts2 后 welcome-file-list 失效的解决办法
struts2 <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.a ...
- 【开发手记一】老生常谈:简简单单配置ZED板开发环境
说明:整理之前项目博客,此系列之前发表于与非网 http://www.openhw.org/module/forum/thread-552476-1-1.html 在拿到开发板和配套教材之前,我们小组 ...
- APK扩展文件介绍、功能及用法
APK扩展文件介绍 Android Market (Google Play Store)中每一个APK文件的最大限制是50MB.假设您的程序中包括大量的数据文件,曾经您仅仅能把这些数据文件放到自己的s ...