by nnicool » Fri Sep 08, 2006 7:09 pm
I don't know why WA..
I can't find any mistakes in my code..
-----------------------
#include <iostream>
#define swap(a,b){a^=b;b^=a;a^=b;}
using namespace std;
int main()
{
long cnt,pos,tmp,T,min,max,CASES,TOTAL,size;
char G[1000001];
char buf,ch;
CASES = 0;
while(!cin.eof())
{
if(cin.eof())
break;
cnt = pos = 0;
CASES++;
cin.getline(G,1000000);
size = strlen(G);
buf = G[0];
G[0] = (char)0;
for(tmp = 0; tmp < size-1;tmp++)
{
cnt++;
ch = G[cnt];
if(ch == buf)
G[cnt] = pos;
else
{
G[cnt] = ++pos;
buf = ch;
}
}
cin >> T;
cout << "Case " << CASES << ":" << endl;
for(cnt = 0; cnt < T;cnt++)
{
cin >> min >> max;
if ( min > max )
swap(min,max);
if(size-1 < max || min < 0)
cout << "No" << endl;
else
{
if(G[min] == G[max])
{
cout << "Yes" << endl;
}
else
cout << "No" << endl;
}
}
cin.get();
}
return 0;
}
----------------
if ther are complex test cases , plz ...