// When I started to answer this question, I had read the question for a long time and did not fully understand it. I felt that this question was too bad, and there were thousands of questions in the question! // At last, you only need to read others' problem-solving reports! In a two-dimensional square, there are three species: P, S, and R. They attack each other. P can defeat r, s can defeat P, and r can defeat S, every day, they will have a war. The square of the species that do not defeat will not occupy the species that win. Ask how the species on the square will be located after N days! // Note that the combat results are summarized at night. During the day, the battle is always on that square, their positions won't change once they pass the battle! This requires two-dimensional arrays to store the square! One is the location square used for combat, and the other is the location square used for combat // temporary results! For example, in the second case, the grid array stores the square location, while the TMP array stores the temporary square location! The battle on the first day is based on the Grid Array // The position on its square is not changed throughout the day, and the TMP array is used to store the results of each battle! # Include <iostream> # include <string> using namespace STD; char grid [110] [110]; // The basis for storing the battle char TMP [110] [110]; // store the temporary combat result int main () {int TC, R, C, N, I, j; CIN> TC; while (TC --) {CIN> r> C> N; for (I = 1; I <= r; I ++) for (j = 1; j <= C; j ++) {CIN> grid [I] [J]; TMP [I] [J] = grid [I] [J];} while (n --) {// battle every day, based on the storage of the grid array, the result is stored in the TMP array for (I = 1; I <= r; I ++) {for (j = 1; j <= C; j ++) {if (Grid [I] [J] = 'R') {If (I-1> 0 & grid [I-1] [J] ='s ') TMP [I-1] [J] = 'R'; If (J-1> 0 & grid [I] [J-1] ='s ') TMP [I] [J-1] = 'R'; if (I + 1 <= R & grid [I + 1] [J] ='s ') TMP [I + 1] [J] = 'R'; If (J + 1 <= C & grid [I] [J + 1] ='s ') TMP [I] [J + 1] = 'R';} else if (grid [I] [J] ='s ') {If (I-1> 0 & grid [I-1] [J] = 'P') TMP [I-1] [J] ='s '; if (J-1> 0 & grid [I] [J-1] = 'P') TMP [I] [J-1] ='s '; if (I + 1 <= R & & Grid [I + 1] [J] = 'P') TMP [I + 1] [J] ='s '; if (J + 1 <= C & grid [I] [J + 1] = 'P') TMP [I] [J + 1] ='s ';} else if (grid [I] [J] = 'P') {If (I-1> 0 & grid [I-1] [J] = 'R ') TMP [I-1] [J] = 'P'; If (J-1> 0 & grid [I] [J-1] = 'R ') TMP [I] [J-1] = 'P'; if (I + 1 <= R & grid [I + 1] [J] = 'R ') TMP [I + 1] [J] = 'P'; If (J + 1 <= C & grid [I] [J + 1] = 'R ') TMP [I] [J + 1] = 'P' ;}}// after each day's battle ends, the combat results are summarized and assigned to the grid array! For (I = 1; I <= r; I ++) for (j = 1; j <= C; j ++) grid [I] [J] = TMP [I] [J];} for (I = 1; I <= r; I ++) {for (j = 1; j <= C; j ++) cout <grid [I] [J]; cout <Endl;} If (TC! = 0) cout <Endl;} system ("pause ");}