//专门用于记录日常刷的codeforces上面的题目
1.PawnChess(简单)
1 #include <iostream> 2 #include <string> 3 #include <algorithm> 4 #include <vector> 5 #include <map> 6 #include <set> 7 #include <cstdio> 8 #include <cstdlib> 9 #include <cstring> 10 11 using namespace std; 12 13 char ch[10][10]; 14 15 int main() 16 { 17 for (int i = 0; i < 8; ++i) 18 scanf("%s", ch[i]); 19 int a = 10, b = 10; 20 for (int i = 0; i < 8; ++i) 21 { 22 for (int j = 0; j < 8; ++j) 23 { 24 if (ch[i][j] != ‘.‘) 25 { 26 if (ch[i][j] == ‘B‘) 27 { 28 int cnt = 0; 29 int k; 30 for (k = i+1; k < 8; ++k) 31 { 32 if (ch[k][j] != ‘B‘ && ch[k][j] != ‘W‘) cnt++; 33 else break; 34 } 35 if (k == 8) b = min(b, cnt); 36 } 37 if (ch[i][j] == ‘W‘) 38 { 39 int cnt = 0; 40 int k; 41 for (k = i-1; k >= 0; --k) 42 { 43 if (ch[k][j] != ‘B‘ && ch[k][j] != ‘W‘) cnt++; 44 else break; 45 } 46 if (k < 0) a = min(a, cnt); 47 } 48 } 49 } 50 } 51 puts(a > b ? "B" : "A"); 52 53 return 0; 54 }
时间: 2024-09-30 10:08:48