1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
#include <iostream> #include <cstdio> using namespace std; int main() { int t; int row,col; char ch,c; scanf("%d%c",&t,&ch); while(t--) { scanf("%c%d%d%c",&ch,&row,&col,&c); if(ch=='r') { printf("%d\n",(row<=col?row:col)); } else if(ch=='k') { //knight alwsy attacks of the other color squares, so total non attacking //knighta are = half of the area //if total square is odd, i.e. dimensions are odd then total non attacking knights = half of the area +1 printf("%d\n",((row*col)+1)/2); } else if(ch=='K') { //for each 2x2 there is one King can be set printf("%d\n",((row+1)/2)*((col+1)/2)); } else if(ch=='Q') { printf("%d\n",(row<=col?row:col)); } } return 0; } |