Advertisement
MiinaMagdy

278 - Chess

Sep 5th, 2022
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll long long
  6. #define endl '\n'
  7. #define sz(x) int(x.size())
  8. #define all(x) x.begin(), x.end()
  9.  
  10. int main() {
  11.     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  12.    
  13.     int test;
  14.     cin >> test;
  15.     while (test--) {
  16.         int n, m;
  17.         char c;
  18.         cin >> c >> n >> m;
  19.         int ans = 0;
  20.         if (c == 'r' || c == 'Q') {
  21.             ans = min(n, m);
  22.         }
  23.         else if (c == 'k') { // knight
  24.             ans = (((n + 1) / 2) * ((m + 1) / 2)) + ((n / 2) * (m / 2));
  25.         }
  26.         else if (c == 'K') { // King
  27.             ans = ((n + 1) / 2) * ((m + 1) / 2);
  28.         }
  29.         cout << ans << endl;
  30.     }
  31. }
  32.  
Tags: UVA CP3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement