-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwashington.cpp
More file actions
72 lines (57 loc) · 1.84 KB
/
washington.cpp
File metadata and controls
72 lines (57 loc) · 1.84 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// NOTE: it is recommended to use this even if you don't understand the following code.
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
// uncomment the two following lines if you want to read/write from files
// ifstream cin("input.txt");
// ofstream cout("output.txt");
int T;
cin >> T;
vector<string> S(3), D(3);
for (int i = 0; i < T; ++i) {
cin >> S[0] >> S[1] >> S[2];
cin >> D[0] >> D[1] >> D[2];
int L = 0;
// INSERT YOUR CODE HERE
if (S[0][1] == D[0][1]) { // Calcolo differenza orizzontale (colonne A, B, C, D...)
L += abs(S[1][0] - D[1][0]);
} else {
L += (S[1][0]-65) + (D[1][0]-65);
}
/*if (stoi(S[2]) != 0 && stoi(D[2]) != 0) {
if (S[0][0] == D[0][0]) { // Calcolo differenza verticale (righe 0, 1, 2, 3...)
L += abs(stoi(S[2]) - stoi(D[2]));
} else {
if (S[0][0] == 'N') {
L += stoi(S[2]) + (26- stoi(D[2]));
} else {
L += (26 - stoi(S[2])) + stoi(D[2]);
}
}
} else if (stoi(S[2]) == 0) {
if (D[0][0] == 'N') {
L += stoi(D[2]);
} else {
L += 26 - stoi(D[2]);
}
} else if (stoi(D[2]) == 0) {
if (S[0][0] == 'N') {
L += stoi(S[2]);
} else {
L += 26 - stoi(S[2]);
}
}*/
if (S[0][0] == 'S' && S[2][0] != '0') {
S[2] = to_string(stoi(S[2]) - 26);
}
if (D[0][0] == 'S' && D[2][0] != '0') {
D[2] = to_string(stoi(D[2]) - 26);
}
L += abs(stoi(S[2]) - stoi(D[2]));
cout << L << endl;
}
return 0;
}