Advertisement
Guest User

Untitled

a guest
Nov 14th, 2016
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <cstring>
  6. #include <deque>
  7. #include <stack>
  8. #include <stdio.h>
  9. #include <map>
  10. #include <set>
  11. #include <time.h>
  12. #include <string>
  13. #include <fstream>
  14. #include <queue>
  15. #include <bitset>
  16. #include <cstdlib>
  17. #define X first
  18. #define Y second
  19. #define mp make_pair
  20. #define pb push_back
  21. #define pdd pair<double,double>
  22. #define pii pair<ll,ll>
  23. #define PI 3.14159265358979323846
  24. #define MOD 1000000007
  25. #define MOD2 1000000009
  26. #define INF ((ll)1e+18)
  27. #define x1 fldgjdflgjhrthrl
  28. #define x2 fldgjdflgrtyrtyjl
  29. #define y1 fldggfhfghjdflgjl
  30. #define y2 ffgfldgjdflgjl
  31. #define N 200002
  32. #define SUM 23423
  33. #define MAG 1048576
  34. #define OPEN 0
  35. #define CLOSE 1
  36. typedef int ll;
  37. typedef long double ld;
  38. using namespace std;
  39. ll i,j,n,k,l,m,tot, flag,h,r, K,x1,y1,x2,y2,x3,y3,mmx,mmy,x,y,z,ysz;
  40. ll arr[55], b[55];
  41. vector<ll> f;
  42. ll ans[250][250], dp[52][202][2002];
  43. struct HashSet2
  44. {
  45. ll a[2500];
  46. ll getHash(long long x)
  47. {
  48. return (x&2048);
  49. }
  50. void Set(ll x)
  51. {
  52. ll y = getHash(x);
  53. while (a[y] != -1)
  54. y++;
  55. a[y] = x;
  56. }
  57. bool Get(ll x)
  58. {
  59. ll y = getHash(x);
  60. while (a[y] != -1 && a[y] != x)
  61. y++;
  62. return (a[y] == x);
  63. }
  64. } t2;
  65. long long getMyMagic(ll x, ll y, ll z, ll w)
  66. {
  67. return 1LL*x*270000000+y*900000+z*300+w;
  68. }
  69. ll getMyMagic2(ll n, ll m, ll k)
  70. {
  71. return n*6000000 + m*2500 + k;
  72. }
  73. bool check(ll l)
  74. {
  75. int n = f[l]/6000000;
  76. if (ans[l][0] == -1)
  77. return true;
  78. for (int i = 0; i < n; i++)
  79. if (ans[l][i] > arr[i])
  80. {
  81. return true;
  82. } else
  83. if (ans[l][i] < arr[i])
  84. return false;
  85. return true;
  86.  
  87. }
  88. void go(ll j, ll k)
  89. {
  90. //cout << i << " " << j << " " << k << endl;
  91. if (i == n)
  92. {
  93. ll ccur = getMyMagic2(i,j,k);
  94. if (t2.Get(ccur))
  95. {
  96. ll cur_pos;
  97. for (int l = 0; l < f.size(); l++)
  98. if (f[l] == ccur)
  99. cur_pos = l;
  100. bool flag = check(cur_pos);
  101. if (flag)
  102. {
  103. for (int l = 0; l < f.size(); l++)
  104. if (f[l] == ccur)
  105. {
  106. int nn = f[l]/6000000;
  107. for (int r = 0; r < nn; r++)
  108. ans[l][r] = arr[r];
  109. }
  110. }
  111. }
  112. return;
  113. }
  114. for (int l = 0;; l++)
  115. {
  116. int xx = k+(n-i)*i*l, yy = j+l*(n-i);
  117. if (xx > 2000 || yy > 200)
  118. break;
  119. if (dp[i+1][yy][xx] != n)
  120. {
  121. dp[i+1][yy][xx] = n;
  122. arr[i] = l;
  123. i++;
  124. go(yy, xx);
  125. i--;
  126. }
  127. }
  128. }
  129. int main() {
  130. //1 3 6 10 2+3+4+5+7+9 //1 3 6 10 15 2+3+4+5 5+7+9 3
  131. //freopen("input.txt","r",stdin);
  132. //freopen("output.txt","w",stdout);
  133. for (i = 0; i < 2500; i++)
  134. t2.a[i] = -1;
  135. ll tests;
  136. cin >> tests;
  137. while (tests--)
  138. {
  139. cin >> n >> m >> k;
  140. b[n] = 1;
  141. x = getMyMagic2(n,m,k);
  142. f.push_back(x);
  143. t2.Set(x);
  144. }
  145. for (i = 0; i < f.size(); i++)
  146. ans[i][0] = -1;
  147. for (n = 1; n <= 50; n++)
  148. if (b[n])
  149. {
  150. i=0;
  151. go(0,0);
  152. }
  153. for (int i = 0; i < f.size(); i++)
  154. {
  155. ll cur = f[i]/6000000;
  156. if (ans[i][0] == -1)
  157. cout << -1 << endl;
  158. else
  159. {
  160. for (j = 0; j < cur; j++)
  161. {
  162. if (j)
  163. ans[i][j] += ans[i][j-1];
  164. cout << ans[i][j] << " ";
  165. }
  166. cout << endl;
  167. }
  168. }
  169. /*for (i = 0; i < 50; i++)
  170. for (j = 0; j <= 200; j++)
  171. for (k = 0; k <= 2000; k++)
  172. if (dp[i][j][k] != -1)
  173. {
  174. //if (i <= 3 && j <= 3 && k <= 5)
  175. //cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
  176. ll cur_dp = dp[i][j][k];
  177. ll cur_sum = sum[i][j][k];
  178. for (l = cur_dp; k + l*i-cur_sum <= 2000 && l <= 200-j; l++)
  179. {
  180. if (dp[i+1][j+l][k+l*i-cur_sum] > l || dp[i+1][j+l][k+l*i-cur_sum] == -1)
  181. {
  182. dp[i+1][j+l][k+l*i-cur_sum] = l;
  183. lk[i+1][j+l][k+l*i-cur_sum] = k;
  184. sum[i+1][j+l][k+l*i-cur_sum] = cur_sum+l;
  185. }
  186. }
  187. }*/
  188. return 0;
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement