lolzzz

i got ac with same code........but believe i got wrong ans so many times.........
dunno y??????
Moderator: Board moderators
Code: Select all
/*** Remove after getting AC.
Thanks to Jaan Vaiya for his sample input ***/
Code: Select all
10000
4
0 1
0 2
0 3
0 4
Code: Select all
Case 1:
No
No
No
No
Code: Select all
/* Zeros and Ones */
#include <stdio.h>
struct DIGIT
{
char d;
struct DIGIT *next;
};
int add (struct DIGIT **, char);
int solve (struct DIGIT *, struct DIGIT *, int, int);
int main ()
{
/*FILE *in = freopen ("c.in", "r", stdin);/**/
struct DIGIT *zed = NULL, *fis = NULL;
char c='\0';
int cases=0;
while (c!=EOF&&(c=getchar())!=EOF)
{
struct DIGIT *zed = NULL, *fis = NULL;
cases++;
struct DIGIT *node;
node = (struct DIGIT *) malloc (sizeof(struct DIGIT));
node->d = c;
node->next = zed;
zed = node;
fis = node;
while ((c=getchar())!='\n')
add (&zed, c);
int query=0, query_r=0;
scanf("%d", &query);
printf("Case %d:\n", cases);
while (query_r++<query)
{
int a, b;
scanf("%d %d", &a, &b);
printf("%s\n", (solve(fis, zed, a,b))?"Yes":"No");
}
c = getchar();
}
return 0;
}
int add (struct DIGIT **p, char c)
{
struct DIGIT *node;
node = (struct DIGIT *) malloc (sizeof(struct DIGIT));
node->d = c;
(**p).next = node;
node->next = *p;
*p = node;
return 0;
}
int solve (struct DIGIT *p, struct DIGIT *q, int a, int b)
{
if (a==b)
return 1;
if (a>b)
{
int c=a;
a=b;
b=c;
}
int x=0;
while (x++<a)
{
p = p->next;
}
short va=0, flag=0;
while (a<b)
{
va = p->d - '0';
p = p->next;
if ((p->d-'0')!=va)
return 0;
a++;
}
return 1;
}
Code: Select all
#include <iostream>
#define MAXL 1000002
using namespace std;
char M[MAXL];
int L[MAXL];
int main(){
int casen = 1;
int n;
int last_fill, len;
int x, y;
char value;
while(cin >> M){
len = strlen(M);
cin >> n;
value = M[0];
last_fill = 0;
for (int i = 1 ; i < len ; i++){
if (value != M[i]){
for (int j = last_fill ; j < i ; j++){
L[j] = i - 1;
}
value = M[i];
last_fill = i;
}
}
if (last_fill < len - 1){
for (int i = last_fill ; i < len ; i++){
L[i] = len - 1;
}
}
cout << "Case " << casen++ << ":" << endl;
for (int i = 0 ; i < n ; i++){
cin >> x >> y;
if (L[x] >= y){
cout << "Yes" << endl;
}else
cout << "No" << endl;
}
}
}
Code: Select all
for (int i = 1 ; i < len ; i++){
if (value != M[i]){
for (int j = last_fill ; j < i ; j++){
L[j] = i - 1;
}
value = M[i];
last_fill = i;
}
}
Code: Select all
Removed
Code: Select all
#include<stdio.h>
#include<string.h>
char a[1000010];
int main()
{
freopen("G:\\in.txt","r",stdin);
freopen("G:\\out.txt","w",stdout);
int i,e,r=1,t,y,u,v;
while(gets(a))
{
printf("Case %d:\n",r);
r++;
v=1;
int z,q,w;
scanf("%d",&y);
while(v<=y)
{
scanf("%d%d",&i,&e);
if(i>e)
{
z=i;
i=e;
e=z;
}
if(a[i]==a[e])
{
u=1;
while(i<=e&&u==1)
{
if(a[i]==a[e])
{
i++;
}
else
u=0;
}
}
else
u=0;
if(u==1)
printf("Yes\n");
else
printf("No\n");
v++;
}
gets(a);
gets(a);
}
return 0;
}
Code: Select all
#include<stdio.h>
#include<string.h>
#define SIZE 1000002
#define MAX(i,j) (i>j)?i:j
#define MIN(i,j) (i<j)?i:j
int Find_Result(char [],long,long);
int main(void)
{
char str[SIZE];
long i,j;
int k,n,l;
l=0;
while(gets(str)){
if(strlen(str)==0)
break;
scanf("%d",&n);
l++;
for(k=0;k<n;k++)
{
scanf("%ld %ld",&i,&j);
i=MIN(i,j);
j=MAX(i,j);
if(k==0)
printf("Case %d:\n",l);
if(Find_Result(str,i,j))
printf("Yes\n");
else
printf("No\n");
}
gets(str);
}
return 0;
}
int Find_Result(char str[],long i,long j)
{
long k;
char ch;
ch=str[i];
for(k=i+1;k<=j;k++)
{
if(str[k]!=ch)
return 0;
}
return 1;
}
Code: Select all
#include <stdio.h>
#include <string.h>
#define indx 1000050
char a[indx],tmp,c;
int i,j,com,s,in[indx],cas=1,l;
int main()
{
while(gets(a))
{
l=strlen(a);
if(l==0)
break;
in[0]=0;
s=1;
while(s<l)
{
in[s]=in[s-1];
if(a[s]!=a[s-1])
in[s]++;
s++;
}
scanf("%d",&com);
printf("Case %d:\n",cas);
cas++;
while(com--)
{
scanf("%d %d",&i,&j);
if(i>j)
{
tmp=i;
i=j;
j=tmp;
}
if(j>l)
printf("No\n");
else if(in[j] == in[i])
printf("Yes\n");
else
printf("No\n");
}
getchar();
}
return 0;
}