Home > Software engineering >  Hihocoder 1120 LOST IN THE CITY
Hihocoder 1120 LOST IN THE CITY

Time:11-03

 # include 
#include
#include
Using namespace STD.
The class direction
{
Public:
Int x;
Int y;
Direction (int x, int y) : x (x), y (y) {}
Bool operator<(direction & amp; Str2);
Boolean operator==(direction & amp; Str1);
};
Bool direction: : operator==(direction & amp; Str1)
{
If (x==str1. X& & Y==str1. Y)
return true;
The else return false;
}
Bool direction: : operator<(direction & amp; Str2)
{
If (x> Str2. X) return false;
If (xIf (x==str2. X)
{
If (yThe else return false;
}
}

The class lost
{
String map [200];
String sur [3].
Int row;
Int col;

Public:
Int x;
Int y;
List Li;
Lost (string str1 [200], string sur1 [3], int n, int m);
Void matching ();
Void matching1 ();
};
Lost: : lost (string str1 [200], string sur1 [3], int n, int m)
{
for(int i=0; iThe map [I]=str1 [I];
Sur [0]=sur1 [0];
Sur [1]=sur1 [1].
Sur [2]=sur1 [2];
The row=n;
Col=m;
}
Void lost: : matching1 ()
{
for(int i=0; i{
For (int j=row - 1; J - 2 & gt;=0; J -)
{
If (map [j] [I]==sur [0] [0] & amp; & The map [1] [I]==sur [0] [1] & amp; & The map [j - 2] [I]==sur [0] [2] & amp; &
The map [j] [I + 1)==sur [1] [0] & amp; & The map [1] [I + 1)==sur [1] [1] & amp; & The map [j - 2] [I + 1)==sur [1] [2] & amp; &
The map [j] [I + 2]==sur [2] [0] & amp; & The map [1] [I + 2]==sur [2] [1] & amp; & The map [j - 2] [I + 2]==sur [2] [2] & amp; &
I + 2 & lt; Col& & J - 2 & gt;=0)
{
Direction * dir=new direction (j, I + 2);
Li. Push_back (* dir);
The delete dir.
}
}
For (int j1=row - 3; J1 & gt;=0; J1 -)
{
If (map [j1] [I]==sur [0] [0] & amp; & The map [j1 + 1] [I]==sur [0] [1] & amp; & The map [j1 + 2] [I]==sur [0] [2] & amp; &
The map [j1] [I - 1]==sur [1] [0] & amp; & The map [j1 + 1] [I - 1]==sur [1] [1] & amp; & The map [j1 + 2] [I - 1]==sur [1] [2] & amp; &
The map [j1] [I - 2)==sur [2] [0] & amp; & The map [j1 + 1] [2] I -==sur [2] [1] & amp; & The map [j1 + 2] [I - 2]==sur [2] [2] & amp; &
I - 2 & gt;=0 & amp; & J1 + 2 & lt; The row)
{
Direction * dir=new direction (j1 + 2, I);
Li. Push_back (* dir);
The delete dir.
}
}
}
}
Void lost: : matching ()
{
Int size=col;
For (int k=0; K{
for(int i=0; i{
Int i1=I;
Int i2=I;
Int j=0;
If (sur [0] [0]==map [k] [i1])
{
While (map [k] [i1]==sur [0] [j] & amp; & j<3 & amp; & I1 & lt; The size)
{
I1 + +;
j++;
}
If (j==3 & amp; & K + 2 & lt; The row)
{
If (map [k + 1] [I]==sur [1] [0] & amp; & The map [k + 1] [I + 1)==sur [1] [1] & amp; & The map [k + 1] [I + 2]==sur [1] [2] & amp; &
The map [k + 2] [I]==sur [2] [0] & amp; & The map [k + 2] [I + 1)==sur [2] [1] & amp; & The map [k + 2] [I + 2]==sur [2] [2])
{
Direction * dir=new direction (k + 2, I + 2);
Li. Push_back (* dir);
The delete dir.
}
}
j=0;
While (map [k] [i2]==sur [0] [j] & amp; & j<3 & amp; & I2 & gt;=0)
{
I2 -;
j++;
}
If (j==3 & amp; & K - 2 & gt;=0)
{
If (map [k - 1] [I]==sur [1] [0] & amp; & The map [k - 1] [I - 1]==sur [1] [1] & amp; & The map [k - 1] [2] I -==sur [1] [2] & amp; &
The map [k - 2] [I]==sur [2] [0] & amp; & The map [k - 2] [I - 1]==sur [2] [1] & amp; & The map [k - 2] [I - 2]==sur [2] [2])
{
Direction * dir=new direction (k, I);
Li. Push_back (* dir);
The delete dir.
}
}

}
}
}

}
Void main ()
{
Int N, M;
String STR [200].
String sur [3].
Cin> N> M;
for(int i=0; iCin> STR [I];
Cin> Sur [0].
Cin> Sur [1].
Cin> Sur [2].
Lost lo (STR, sur, N, M);
Lo. Matching ();
Lo. Matching1 ();
Lo. Li. Unique ();
Lo. Li. Sort ();
List : : iterator cur=lo. Li. The begin ();
While (cur!=lo. Li. End ())
{
coutCur++;
}

}

Why do I enter the program will display the output results well beyond the right answer

CodePudding user response:

Please place the order with the Debug step through it and see, it should be easy to find a place to go wrong

CodePudding user response:

I use VC debugging through, the result is right, but in hiho coder to submit said after the results well beyond the right answer,
  • Related