Advertisement
Salvens

I

Aug 15th, 2023
986
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <array>
  4. #include <vector>
  5. #include <numeric>
  6. #include <random>
  7. #include <chrono>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11.  
  12. using namespace std;
  13.  
  14. #define int long long
  15.  
  16. const int INF = 1e18 + 7;
  17. const int MAXN = 1e4 + 1000;
  18. const int N = 1e5 + 10;
  19.  
  20. int make_xor(int n, int m, int k) {
  21.     int ans = 0;
  22.     for (int i = 0; i < n; ++i) {
  23.         ans ^= 2;
  24.     }
  25.     for (int i = 0; i < m; ++i) {
  26.         ans ^= 3;
  27.     }
  28.     ans ^= k;
  29.     return ans;
  30. }
  31.  
  32. signed main() {
  33.     ios_base::sync_with_stdio(false);
  34.     cin.tie(nullptr);
  35.  
  36.     int n, m;
  37.     cin >> n >> m;
  38.     if (make_xor(n, m, 0) == 0) {
  39.         cout << 2 << '\n';
  40.     } else {
  41.         cout << 1 << '\n';
  42.         vector<pair<int, int>> ans;
  43.         if (n) {
  44.             if (make_xor(n - 1, m, 1) == 0) {
  45.                 ans.emplace_back(2, 1);
  46.             }
  47.             if (make_xor(n - 1, m, 0) == 0) {
  48.                 ans.emplace_back(2, 2);
  49.             }
  50.         }
  51.         if (m) {
  52.             if (make_xor(n, m - 1, 2) == 0) {
  53.                 ans.emplace_back(3, 1);
  54.             }
  55.             if (make_xor(n, m - 1, 1) == 0) {
  56.                 ans.emplace_back(3, 2);
  57.             }
  58.             if (make_xor(n, m - 1, 0) == 0) {
  59.                 ans.emplace_back(3, 3);
  60.             }
  61.         }
  62.         cout << ans.size() << '\n';
  63.         for (auto [x, y]: ans) {
  64.             cout << x << ' ' << y << '\n';
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement