There are two rabbits, one in the upper left corner and the other in the upper right corner. The two rabbits have their own moving speed (hourly) and their initial moving direction.
Now there are three possible reasons for them to turn: hitting the wall while moving, turning around and taking the unfinished road. Collision: The two rabbits are rounded up at (that is, after processing the path for an hour). At the same point, rabbit A and rabbit B exchange directions with each other. Turn left: The two rabbits have their own steering time T. Every T hour, the rabbit will turn left, but the collision priority is higher than that of the rabbit. after the collision, the left turn problem will not be handled.
# Include <iostream> # include <algorithm> # include <cmath> # include <cstdio> # include <cstdlib> # include <cstring> # include <string> # include <vector> # include <set> # include <queue> # include <stack> # include <climits> // define MAX 100005 # define INF 0x7fffff # define REP (I, s, t) for (int I = (s); I <= (t); ++ I) # define ll long # define mem (a, B) memset (a, B, sizeof (a) # define mp (a, B) make_p Air (a, B) # define L (x) x <1 # define R (x) x <1 | 1 # define eps 1e-5 // # pragma comment (linker, "/STACK: 36777216") // The legendary plug-in using namespace std; int n; struct node {int x, y; int sp, turn; int dir, 2, 3} tom, jer; int dirx [] = {-,}; int diry [] = {, 0,-1}; int judge (char c) {if (c = 'n') return 0; if (c = 'E') return 1; if (c = 's') return 2; if (c = 'W') return 3;} void go (node & a, int d) {For (int I = 0; I <d; I ++) {if (. x = 1 &. dir = 0) {. dir = 2;} if (. x = n &. dir = 2) {. dir = 0;} if (. y = 1 &. dir = 3) {. dir = 1;} if (. y = n &. dir = 1) {. dir = 3;}. x =. x + dirx [. dir];. y =. y + diry [. dir] ;}} bool meet () {if (tom. x = jer. x & tom. y = jer. y) {swap (tom. dir, jer. dir); return true;} return false;} void move (node & a, int step, bool flag) {if (Flag = 0) {if (step % a. turn = 0 & step! = 0) a. dir --; if (a. dir <0) a. dir = 3;} int dir = a. dir; if (dirx [dir]! = 0) {int dx = abs (a. sp * dirx [dir]); go (a, dx);} if (diry [dir]! = 0) {int dy = abs (. sp * diry [dir]); go (a, dy) ;}} void solve (int h) {int step = 0; while (step