nhap96

test UVa 1235

May 9th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. #define fileName string ("")
  2.  
  3. #define TEST_GENERATOR
  4.  
  5. #define INP (fileName + ".inp").c_str ()
  6. #define OUT (fileName + ".out").c_str ()
  7. #define ERR (fileName + ".err").c_str ()
  8.  
  9. /* ---------------------------------------------------------------------------------------- */
  10.  
  11. #include <algorithm>
  12. #include <iostream>
  13. #include <numeric>
  14. #include <sstream>
  15. #include <cstdlib>
  16. #include <climits>
  17. #include <cstring>
  18. #include <iomanip>
  19. #include <limits>
  20. #include <bitset>
  21. #include <locale>
  22. #include <cstdio>
  23. #include <vector>
  24. #include <cmath>
  25. #include <stack>
  26. #include <queue>
  27. #include <deque>
  28. #include <ctime>
  29. #include <list>
  30. #include <map>
  31. #include <set>
  32.  
  33. using namespace std;
  34.  
  35. #define fi first
  36. #define se second
  37. #define mp make_pair
  38. #define pb push_back
  39. #define pp pop_back
  40. #define rp(i, n) for (int i = 0; i < (n); ++i)
  41. #define rd(i, n) for (int i = (n); i--;)
  42. #define rs(i, x) rp (i, sz (x))
  43. #define rr(i, x) rd (i, sz (x))
  44. #define fr(i, a, b) for (int i = (a); i <= (b); ++i)
  45. #define fd(i, a, b) for (int i = (a); i >= (b); --i)
  46. #define fe(i, x) for (__typeof ((x).begin ()) i = (x).begin (); i != (x).end (); ++i)
  47. #define fer(i, x) for (__typeof ((x).rbegin ()) i = (x).rbegin (); i != (x).rend (); ++i)
  48. #define cd(x) while ((x)--)
  49. #define srt(v) sort (all (v))
  50. #define srt(v) sort (all (v))
  51. #define srtr(v) sort (allr (v))
  52. #define mn(x, y) x = min (x, y)
  53. #define mx(x, y) x = max (x, y)
  54. #define all(x) (x).begin (), (x).end ()
  55. #define allr(x) (x).rbegin (), (x).rend ()
  56. #define sz(x) ((int) (x).size ())
  57. #define cl(x) memset (x, 0, sizeof (x))
  58. #define sqr(x) ((x) * (x))
  59.  
  60. const double pi = acos(-1.0);
  61. typedef unsigned long long llu;
  62. typedef long long ll;
  63. typedef pair <int, int> ii;
  64. typedef pair <int, ii> iii;
  65. typedef vector <string> vs;
  66. typedef vector <ii> vii;
  67. typedef vector <int> vi;
  68. typedef vector <vi> vvi;
  69. typedef vector <vii> vvii;
  70. typedef vector <bool> vb;
  71. typedef vector <vb> vvb;
  72. struct disjoint_set
  73. {
  74. vi pset; int _sz;
  75. inline int size () {return _sz;}
  76. inline void init (const int &n) {pset.resize (n); rp (i, n) pset [i] = i; _sz = n;}
  77. disjoint_set () {};
  78. disjoint_set (const int &n) {init (n);}
  79. int find (const int &x) {return (x == pset [x] ? x : pset [x] = find (pset [x]));}
  80. inline bool same (const int &x, const int &y) {return (find (x) == find (y));}
  81. inline bool join (const int &x, const int &y) {int xx = find (x), yy = find (y); if (xx == yy) return false; --_sz; pset [xx] = yy; return true;}
  82. };
  83. template <class T> inline string ns (const T &number) {stringstream ss; ss << number; return ss.str ();}
  84. template <class T> inline T sn (const string &s) {stringstream ss (s); T result; return ss >> result ? result : 0;}
  85. template <class T> inline T pow2 (const int &x) {return (T) 1 << x;}
  86. template <class T> inline int log2 (T x) {int res = 0; while (x >>= 1) ++res; return res;}
  87. template <class T> inline T rand () {int cnt = sizeof (T) * 8 / 15 + 1; T res = 0; cd (cnt) res = (res << 15) | rand (); return res;}
  88. template <class T> inline T rand (T x, T y) {if (x > y) swap (x, y); T diff = y - x + 1, tmp = rand <T> () % diff; if (tmp >= 0) return tmp + x; return tmp + diff + x;}
  89. template <class T> inline T _abs (const T &x) {return (x >= 0 ? x : -x);}
  90. template <class T> inline T gcd (T x, T y) {x = _abs (x); y = _abs (y); if (!x || !y) return 0; T tmp; while (y) {tmp = y; y = x % y; x = tmp;} return x;}
  91. template <class T> inline T lcm (T x, T y) {x = _abs (x), y = _abs (y); return (x && y ? x / gcd (x, y) * y : 0);}
  92. template <class T> struct BIT
  93. {
  94. vector <T> tree; int _sz; inline int size () {return _sz;}
  95. inline void init (const int &n) {_sz = n; tree.assign (n + 1, 0);} BIT () {} BIT (const int &n) {init (n);}
  96. inline void add (int i, const T &v) {for (; i <= _sz; i += i & -i) tree [i] += v;}
  97. inline T sum (int i) {T s = 0; for (; i; i -= i & -i) s += tree [i]; return s;}
  98. inline T sum (const int &i, const int &j) {return sum (j) - sum (i - 1);}
  99. };
  100. #define mod
  101.  
  102. /* ---------------------------------------------------------------------------------------- */
  103.  
  104. bool mark [10000];
  105.  
  106. int main ()
  107. {
  108. srand (time (NULL));
  109. #ifndef ONLINE_JUDGE
  110. #ifdef TEST_GENERATOR
  111. freopen (INP, "w", stdout);
  112. #else
  113. freopen (INP, "r", stdin);
  114. freopen (OUT, "w", stdout);
  115. //freopen (ERR, "w", stderr);
  116. #endif
  117. #endif
  118. int t = rand (1, 20);
  119. printf ("%d\n", t);
  120. cd (t)
  121. {
  122. int n = rand (1, 500); printf ("%d", n);
  123. cl (mark);
  124. cd (n)
  125. {
  126. int tmp;
  127. do tmp = rand (1, 9999); while (mark [tmp]);
  128. mark [tmp] = true;
  129. cout << " " << setfill ('0') << setw (4) << tmp;
  130. }
  131. putchar ('\n');
  132. }
  133. return 0;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment