A Game of Robots - Got a problem with the logic

A Game of RobotsWhere is the logic going wrong. Give me a counter example.

while(t--){
	string s;
	vector < pair<int,int> > robot;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]!='.'){
			
			int a = (int) s[i] - '0';
			int x,y;		
			x = i-a;
			y = i+a;
			
			if(x<0)
				x=0;
				
			if(y>=s.length())
				y=s.length()-1;
				
			robot.push_back(make_pair(x,y));
		}
	}
	
	int flag=0;
	
	for(int i=0;i<robot.size();i++){
		for(int j=0;j<robot.size() && i!=j && flag==0;j++){
			if(robot[j].first>=robot[i].first || robot[j].second<=robot[i].second ){
				flag=1;
			}
		}
	}
	
	if(flag)
		cout<<"unsafe"<<endl;
	else
		cout<<"safe"<<endl;
		
	//print(robot);
}

There are many cases where your code is giving giving ‘unsafe’ as output when it shouldn’t , for eg - .2…2. , …1…3. and many other cases too.