#include #include #include #include #include #include #include #include #include #define DN 15 #define LB 10 #define SM "MISSED" #define HT 0 #define BT 1 using namespace std; int dx[]={0,1}; int dy[]={1,0}; map shipLenght; vector shipTypes; class Board { private: map shots; bool isShot[DN][DN]; string type[DN][DN]; public: bool validate(int x,int y) { if(x<1 || y<1 || x>LB || y>LB) return 0; return 1; } Board() { for(int i=1; i<=LB; ++i) for(int j=1; j<=LB; ++j) { isShot[i][j]=0; type[i][j]=SM; } for(int i=0; i1) return 0; for(int i=0; isetShip(1, 2, 1, shipTypes[0]); cout<<1<<' '<<2<<' '<<1<<'\n'; cout.flush(); b->setShip(2, 4, 1, shipTypes[1]); cout<<2<<' '<<4<<' '<<1<<'\n'; cout.flush(); b->setShip(4, 6, 1, shipTypes[2]); cout<<4<<' '<<6<<' '<<1<<'\n'; cout.flush(); b->setShip(4, 8, 1, shipTypes[3]); cout<<4<<' '<<8<<' '<<1<<'\n'; cout.flush(); b->setShip(3, 10, 1, shipTypes[4]); cout<<3<<' '<<10<<' '<<1<<'\n'; cout.flush(); /* for(int i=0; isetShip(x,y,o,shipTypes[i])) { x=rand()%LB+1; y=rand()%LB+1; o=rand()%2; } cout<>res; if(res=="HIT") { int ok=1; for(int d=0; d<4 && ok; ++d) { int ii=i+xx[d],jj=j+yy[d]; for(;b->validate(ii,jj);ii+=xx[d],jj+=yy[d]) { cout<>res; if(res==SM) break; if(res.find("SANK")!=string::npos) { ok=0; break; } } } } } for(int i=1; i<=DN; ++i) for(int j=1; j<=DN; ++j) if(!hits[i][j] && (i+j)%3==2) { cout<>res; if(res=="HIT") { int ok=1; for(int d=0; d<4 && ok; ++d) { int ii=i+xx[d],jj=j+yy[d]; for(;b->validate(ii,jj);ii+=xx[d],jj+=yy[d]) { cout<>res; if(res==SM) break; if(res.find("SANK")!=string::npos) { ok=0; break; } } } } } } /* ooxooxooxo oxooxooxoo xooxooxoox ooxooxooxo oxooxooxoo xooxooxoox ooxooxooxo oxooxooxoo xooxooxoox ooxooxooxo */