Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- int q;
- cin >> q;
- for (int x = 0; x < q; x++)
- {
- string s;
- cin >> s;
- vector<int> pos(2, 0);
- for (int i = 0; i < 2; i++)
- {
- if (s[i] == '1' || s[i] == 'a')
- {
- pos[i] = 1;
- }
- if (s[i] == '2' || s[i] == 'b')
- {
- pos[i] = 2;
- }
- if (s[i] == '3' || s[i] == 'c')
- {
- pos[i] = 3;
- }
- if (s[i] == '4' || s[i] == 'd')
- {
- pos[i] = 4;
- }
- if (s[i] == '5' || s[i] == 'e')
- {
- pos[i] = 5;
- }
- if (s[i] == '6' || s[i] == 'f')
- {
- pos[i] = 6;
- }
- if (s[i] == '7' || s[i] == 'g')
- {
- pos[i] = 7;
- }
- if (s[i] == '8' || s[i] == 'h')
- {
- pos[i] = 8;
- }
- }
- /*for (int i = 0; i < 2; i++)
- {
- cout << pos[i] << " ";
- }
- cout << endl;*/
- int all = 8;
- while (true)
- {
- if ((pos[1] == 2 || pos[1] == 7) && (pos[0] == 2 || pos[0] == 7))
- {
- all = 4;
- break;
- }
- if ((pos[1] == 1 || pos[1] == 8) && (pos[0] == 1 || pos[0] == 8))
- {
- all = 2;
- break;
- }
- if ((pos[0] == 1 || pos[1] == 1) || (pos[0] == 8 || pos[1] == 8))
- {
- all = 4;
- break;
- }
- if ((pos[0] == 2 || pos[1] == 2) || (pos[0] == 7 || pos[1] == 7))
- {
- all = 6;
- break;
- }
- else {
- break;
- }
- }
- cout << all << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement