Comments
0
@ tgoulart , thnx so much this is the correct try  : (int) (pow( 10.0 , str.size()-1 )+EPS)

:)
On mamhh → Crazy Problem !!, 16 years ago
0
 
On mamhh → Crazy Problem !!, 16 years ago
0
thnx :)
On mamhh → Crazy Problem !!, 16 years ago
0
yes, it's correct :)
On mamhh → Crazy Problem !!, 16 years ago
0
exactly :) ,
On mamhh → Crazy Problem !!, 16 years ago
0
@ kumaranurag : exactly ;)  , it depends on the shape of digits , but u didn't tell me ur solution :D :P .

anyhow, I mean that I love those problems that basically depends on  logic , reasoning , strength of observation , etc...
On mamhh → Crazy Problem !!, 16 years ago
0
@fura2 : thnx so much for this problem , I will try it , and tell u results ;)
why do u think my cycle detection is wrong?  and what do u mean by "single bfs"?

iam using bfs

I got wrong answer in case no.7 ,,,problem - E -....plz any help

[code]

#include <string.h>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <map>
#include <set>
#include <sstream>

using namespace std;
#define all(c) c.begin(),c.end()
#define rep_(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for(i=0;i<n;i++)
#define forr(i,a,b) for(i=a;i<=b;i++)
#define forr_(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) ( a>b? b : a )
#define max(a,b) ( a>b? a : b )
#define sz size()
#define pb(a) push_back(a)
#define mset(a,v) memset(a,v,sizeof(a))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int,int> mi;
typedef vi::iterator it;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef pair<string,int> psi;
typedef vector<psi> vpsi;
typedef queue<int> qi;
typedef queue<pii> qpii;
typedef unsigned long long ubig;
typedef long long big;
typedef long double bigd;
template<class T> string tos(T x){stringstream ss; ss<<x; return ss.str();}
int Draw,Ivan,Zmey;
vpii v1,v2;
int i,h,t,r,m,n;
class Substitute
{
public:

};
void solve()
{
queue<pair<pair<int,int>,int> > q;
bool vis[1000][1000];
mset(vis,0);
pair<pair<int,int>,int> start(pair<int,int>(h,t),0),cur;
q.push(start);
int cc,ch,ct;
while(!q.empty())
{
cur=q.front();
cc=cur.second;
ch=cur.first.first;
ct=cur.first.second;
q.pop();
if(vis[ch][ct])
{
Draw=true;
}
else if(ch+ct>r)
{
Zmey=cc;
}
else if(!ch && !ct)
{
Ivan=cc;
return;
}
else
{
vis[ch][ct]=true;
int k,l;
rep( k , min(n,ch) )q.push(pair<pair<int,int>,int>(pair<int,int>(ch-(k+1)+v1[k].first,ct+v1[k].second),cc+1));
rep( l , min(m,ct) )q.push(pair<pair<int,int>,int>(pair<int,int>(ch+v2[l].first,ct-(l+1)+v2[l].second),cc+1));
}
}
}
int main()
{
cin>>h>>t>>r>>n;
v1.resize(n);
rep(i,n)cin>>v1[i].first>>v1[i].second;
cin>>m;
v2.resize(m);
rep(i,m)cin>>v2[i].first>>v2[i].second;
solve();
if(Ivan)cout<<"Ivan\n"<<Ivan<<endl;
else if(Draw)cout<<"Draw\n";
else cout<<"Zmey\n"<<Zmey<<endl;
return 0;
}

[/code]

I solved problem -E- using bfs, but i got wrong answer in test case no.7......can anyone help?