#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
void solve(string imie, int a, int b) {
int c, d;
if (imie == "Algosia") {
c = a + 1;
d = b + 1;
if (c > 1000)
c = 1;
if (d > 1000)
d = 1;
// AB/BA
if (c == b || d == a)
{
++c;
++d;
}
if (c > 1000)
c = 1;
if (d > 1000)
d = 1;
cout << c << ' ' << d << endl;
}
else {
if (a == 1 && b == 1000) {
cout << 999 << ' ' << 1000 << endl;
}
else if (a == 1000 && b == 1) {
cout << 1000 << ' ' << 999 << endl;
}
else if (a + 1 == b || b + 1 == a) {
a -= 2; b -= 2;
a = (a + 1000) % 1000;
b = (b + 1000) % 1000;
cout << a << ' ' << b << endl;
}
/*else if (b + 1 == a) {
a -= 2; b -= 2;
a = (a + 1000) % 1000;
b = (b + 1000) % 1000;
cout << a << ' ' << b << '\n';
}*/
else {
--a; --b;
a = (a + 1000) % 1000;
b = (b + 1000) % 1000;
cout << a << ' ' << b << endl;
}
}
cout.flush();
}
int main()
{
cin.tie(0);cout.tie(0); ios_base::sync_with_stdio(0);
string imie;
int a, b;
cin >> imie;
cin >> a >> b;
solve(imie, a, b);
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #include <iostream> #include <vector> typedef long long ll; using namespace std; void solve(string imie, int a, int b) { int c, d; if (imie == "Algosia") { c = a + 1; d = b + 1; if (c > 1000) c = 1; if (d > 1000) d = 1; // AB/BA if (c == b || d == a) { ++c; ++d; } if (c > 1000) c = 1; if (d > 1000) d = 1; cout << c << ' ' << d << endl; } else { if (a == 1 && b == 1000) { cout << 999 << ' ' << 1000 << endl; } else if (a == 1000 && b == 1) { cout << 1000 << ' ' << 999 << endl; } else if (a + 1 == b || b + 1 == a) { a -= 2; b -= 2; a = (a + 1000) % 1000; b = (b + 1000) % 1000; cout << a << ' ' << b << endl; } /*else if (b + 1 == a) { a -= 2; b -= 2; a = (a + 1000) % 1000; b = (b + 1000) % 1000; cout << a << ' ' << b << '\n'; }*/ else { --a; --b; a = (a + 1000) % 1000; b = (b + 1000) % 1000; cout << a << ' ' << b << endl; } } cout.flush(); } int main() { cin.tie(0);cout.tie(0); ios_base::sync_with_stdio(0); string imie; int a, b; cin >> imie; cin >> a >> b; solve(imie, a, b); return 0; } |
English