silentkiler029

cf-1395-B

Aug 12th, 2020 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. /*    BISMILLAHIR-RAHMANIR-RAHIM
  2.  ____________________________________
  3. |                                    |
  4. |       SHANTO_SUST_SWE-19_029       |
  5. |____________________________________|
  6. */
  7.  
  8. #include <bits/stdc++.h>
  9.  
  10. using namespace std;
  11.  
  12. #define ll          long long
  13. #define fastio      ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
  14. #define pb          push_back
  15. #define Pi          acos(-1.0)
  16. #define r0          return 0
  17. #define endl        "\n"
  18. #define show(x)     cout << x << endl
  19. #define take(x)     cin >> x
  20. #define debug       1
  21.  
  22. int main()
  23. {
  24.     int n, m, x, y, k;
  25.     char ch;
  26.     cin >> n >> m >> x >> y;
  27.  
  28.     int i, j;
  29.     cout << x << " " << y << endl;
  30.     for(i = y + 1; i <= m; i++) {
  31.         cout << x << " " << i << endl;
  32.     }
  33.     for(i = y - 1; i > 0; i--) {
  34.         cout << x << " " << i << endl;
  35.     }
  36.  
  37.     for(i = 1; i < x; i++) {
  38.         if (i % 2) {
  39.             for(j = 1; j <= m; j++) {
  40.                 cout << i << " " << j << endl;
  41.             }
  42.             ch = 'R';
  43.         }
  44.         else {
  45.             for(j = m; j > 0; j--) {
  46.                 cout << i << " " << j << endl;
  47.             }
  48.             ch = 'L';
  49.         }
  50.     }
  51.  
  52.     if(ch == 'R') k = 1;
  53.     else k = 0;
  54.  
  55.     for(i = x + 1; i <= n; i++) {
  56.         if (k % 2 == 0) {
  57.             for(j = 1; j <= m; j++) {
  58.                 cout << i << " " << j << endl;
  59.             }
  60.             k++;
  61.         }
  62.         else {
  63.             for(j = m; j > 0; j--) {
  64.                 cout << i << " " << j << endl;
  65.             }
  66.             k++;
  67.         }
  68.     }
  69.  
  70.  
  71.     r0;
  72. }
  73.  
  74. //ALHAMDULILLAH
  75.  
  76.  
Add Comment
Please, Sign In to add comment