topic background
During a game of chess, if the same situation occurs continuously or intermittently for 3 or more times, any side can propose a draw.
Problem Description
Each chess situation can be represented by an 8×8 character array, where each bit corresponds to a grid on the board. k
Six kinds of chess pieces king, queen, rook, bishop, horse, and pawn are represented by letters , q
, r
, b
, n
, respectively p
, wherein capital letters correspond to white squares, and small letters correspond to black squares. There are no chess pieces on the chessboard to *
represent with characters. If each bit of the two character arrays is the same, it means that they correspond to the same situation.
Now that the situation after each chess move has been sorted out in the above-mentioned way, try to count how many times each situation occurs.
input format
Read data from standard input.
The first line of input contains a positive integer �, indicating that the game has a total of � moves.
In the next 8 × � lines, enter the situation after the 1st to �th moves in turn. Specifically, each line contains a string with a length of 8, and each 8-line string has a total of 64 characters corresponding to a situation.
output format
output to standard output.
Output a total of �� lines, each with an integer, indicating how many times this situation occurs.
sample input
8
********
******pk
*****r*p
p*pQ****
********
**b*B*PP
****qP**
**R***K*
********
******pk
*****r*p
p*pQ****
*b******
****B*PP
****qP**
**R***K*
********
******pk
*****r*p
p*p*****
*b**Q***
****B*PP
****qP**
**R***K*
******k*
******p*
*****r*p
p*p*****
*b**Q***
****B*PP
****qP**
**R***K*
******k*
******p*
*****r*p
p*pQ****
*b******
****B*PP
****qP**
**R***K*
********
******pk
*****r*p
p*pQ****
*b******
****B*PP
****qP**
**R***K*
********
******pk
*****r*p
p*p*****
*b**Q***
****B*PP
****qP**
**R***K*
********
******pk
******rp
p*p*****
*b**Q***
****B*PP
****qP**
**R***K*
Data
sample output
1
1
1
1
1
2
2
1
Data
Sample description
The positions after steps 6 and 7 are the same as the positions after steps 2 and 3 respectively. The position after step 8 corresponds to the picture above.
Subtasks
The input data satisfies �≤100.
hint
Judging repeated positions only involves string comparison, without considering the actual chess rules.
answer questions
It is to judge the number of repeated occurrences of the string. I integrate the 8x8 situation into a 64-character string, and record the number of occurrences before the string.
#include <iostream>
using namespace std;
int main(){
int step;
cin>>step;
string situation[step];
for(int i=0;i<step;i++){
string temp;
int line=8;
while(line--){
cin>>temp;
situation[i]+=temp;
}
int times=1;
for(int j=0;j<i;j++){
if(situation[j]==situation[i]){
times++;
}
}
cout<<times<<endl;
}
}