Home > Back-end >  Bosses to help look at the map I this problem is () use is there a problem?
Bosses to help look at the map I this problem is () use is there a problem?

Time:10-07


 # include 
#include
#include
#include
#include
using namespace std;
Int main () {
String A, B;
String x, y;
Cin> A> B;
Map s;
While (cin> X> Y) {
S [x]=y;
}
Queue A0;
Queue p;
A0. Push (A);
P.p ush (0);
While (! A0. Empty ()) {
If (A0. Front ()==B) {//when found output
Coutreturn 0;
}
If (p.f ront () & gt;=10) {
A0. Pop ();
P.p op ();
}
String t;
Int kai, len=0;
T=A0. Front ();
Map : : iterator it;
For (it=s.b do v.begin (); it!=s.e nd (); It++) {
If (kai=t.f ind (it - & gt; First, 0)) {
Len=it - & gt; First, the size ();
T.r eplace (kai, len, it - & gt; Second);
CoutA0. Push (t.s ubstr (0, kai) + it - & gt; Second + t.s ubstr (kai + len));
P.p ush (p.f ront () + 1);
}
}
A0. Pop ();
P.p op ();
}
Printf (" NO ANSWER! \n");

return 0;
}

CodePudding user response:

#include
#include
#include
#include
#include
using namespace std;
Int main () {
String A, B;
String x, y;
Cin & gt;> A. & gt;> B;
Map s;
While (cin & gt;> X & gt;> Y) {
S [x]=y;
}
Queue A0;
Queue p;
A0. Push (A);
P.p ush (0);
while (! A0. Empty ()) {
If (A0. back ()==B) {//when found output
Cout & lt; back ();
return 0;
}
If (p. back () & gt;=10) {
A0. Pop ();
P.p op ();
}
String t;
Int kai, len=0;
T=A0. back ();
Map : : iterator it;
For (it=s.b do v.begin (); It!=s.e nd (); It++) {
If ( (kai=t.f ind (it - & gt; The first))! {=1 )
Len=it - & gt; First, the size ();
T.r eplace (kai, len, it - & gt; Second);
Cout & lt; A0. Push (t) ;
P.p ush (p. back () + 1);
}
}
A0. Pop ();
P.p op ();
}
Printf (" NO ANSWER! \n");

return 0;
}

CodePudding user response:

reference 1st floor 燚 recognition response:
# include
#include
#include
#include
#include
using namespace std;
Int main () {
String A, B;
String x, y;
Cin & gt;> A. & gt;> B;
Map s;
While (cin & gt;> X & gt;> Y) {
S [x]=y;
}
Queue A0;
Queue p;
A0. Push (A);
P.p ush (0);
while (! A0. Empty ()) {
If (A0. back ()==B) {//when found output
Cout & lt; back ();
return 0;
}
If (p. back () & gt;=10) {
A0. Pop ();
P.p op ();
}
String t;
Int kai, len=0;
T=A0. back ();
Map : : iterator it;
For (it=s.b do v.begin (); It!=s.e nd (); It++) {
If ( (kai=t.f ind (it - & gt; The first))! {=1 )
Len=it - & gt; First, the size ();
T.r eplace (kai, len, it - & gt; Second);
Cout & lt; A0. Push (t) ;
P.p ush (p. back () + 1);
}
}
A0. Pop ();
P.p op ();
}
Printf (" NO ANSWER! \n");

return 0;
}

I see, thank you,
  • Related