Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include "testlib.h"
  2.  
  3. #include <iostream>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <string>
  7. #include <cstring>
  8. #include <queue>
  9. #include <math.h>
  10. #include <map>
  11. #include <set>
  12. #include <stdio.h>
  13. #include <complex>
  14. #define ll long long
  15. #define ff first
  16. #define ss second
  17. #define pii pair<int, int>
  18. using namespace std;
  19.  
  20. /*
  21. generate ticket of this kind:
  22. 1 2 3 4
  23. 5 6 7 8
  24. 9 10 11 12
  25. */
  26.  
  27. int main(int argc, char *argv[])
  28. {
  29.     registerGen(argc, argv, 1);
  30.     if (argc < 5)
  31.     {
  32.         printf("Usage: gen_ordered [n] [m] [q] [k]\n");
  33.         return 0;
  34.     }
  35.  
  36.     int n = atoi(argv[1]);
  37.     int m = atoi(argv[2]);
  38.     int q = atoi(argv[3]);
  39.     int k = atoi(argv[4]);
  40.     q = min(q, n * m);
  41.  
  42.     printf("%d %d %d %d\n", n, m, q, k);
  43.  
  44.     for (int i = 0; i < n; ++i)
  45.     {
  46.         for (int j = 0; j < m; ++j)
  47.         {
  48.             if (j != 0)
  49.                 putchar(' ');
  50.             printf("%d", min(k, i * m + j + 1));
  51.         }
  52.         putchar('\n');
  53.     }
  54.    
  55.     int cnt = 0;
  56.     for (int j = m; j > 0; --j)
  57.         for (int i = n; i > 0; --i)
  58.         {
  59.             if (cnt == q)
  60.                 return 0;
  61.             printf("%d %d\n", i, j), cnt++;
  62.         }
  63.     return 0;
  64. }
  65. /*
  66. 211701YWCWR
  67. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement