#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
int wrap(const int a) {
if (a > 1000) {
return a - 1000;
}
return a;
}
int unwrap(const int a) {
if (a <= 0) {
return a + 1000;
}
return a;
}
int abs(const int a) {
return a > 0 ? a : -a;
}
int main() {
ios_base::sync_with_stdio(false);
string who;
cin >> who;
if (who == "Algosia") {
int a, b;
cin >> a >> b;
int dt = 1;
if (abs(a - b) == 1 || abs(a - b) == 999) {
dt = 2;
}
cout << wrap(a + dt) << " " << wrap(b + dt) << endl;
} else {
int c, d;
cin >> c >> d;
int dt = 1;
if (abs(c - d) == 1 || abs(c - d) == 999) {
dt = 2;
}
cout << unwrap(c - dt) << " " << unwrap(d - dt) << endl;
}
cout.flush();
return 0;
}
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 | #include <iostream> #include <vector> #include <bitset> using namespace std; int wrap(const int a) { if (a > 1000) { return a - 1000; } return a; } int unwrap(const int a) { if (a <= 0) { return a + 1000; } return a; } int abs(const int a) { return a > 0 ? a : -a; } int main() { ios_base::sync_with_stdio(false); string who; cin >> who; if (who == "Algosia") { int a, b; cin >> a >> b; int dt = 1; if (abs(a - b) == 1 || abs(a - b) == 999) { dt = 2; } cout << wrap(a + dt) << " " << wrap(b + dt) << endl; } else { int c, d; cin >> c >> d; int dt = 1; if (abs(c - d) == 1 || abs(c - d) == 999) { dt = 2; } cout << unwrap(c - dt) << " " << unwrap(d - dt) << endl; } cout.flush(); return 0; } |
English